problem using EJB by local interfaces


EJB programming & troubleshooting: problem using EJB by local interfaces

  1. problem using EJB by local interfaces (2 messages)

    Hi everyone

    I am new in ejb and I need to call an ejb by its local interfaces and I know that my app and ejb should be in the same VM and they are. when I use remote Interfaces its works just fine but the problem shows up when I try the code below in order to work locally

    Context ctx = new InitialContext(this.props);
    Object obj = ctx.lookup("ejb/MemberHome");
    MemberLocalHome home = (MemberLocalHome) obj;

    I am not sure if the code is right. when I run it I get a ClassCastException error. what is wrong?

    thanks and regards
  2. You have to modify your code just a bit, so that app server identifies the JNDI name and recognizes the EJB as a local interface. Just pre-append the JNDI name with this in your code "local:ejb" before ejb/MemberHome -> local:ejb/ejb/MemberHome. It will surely work. Good luck...
  3. thanks pampa. that solved the problem. I am using jboss and I should have done some changes in jboss.xml deployment descriptor in order to configure the jndi resources.