0 Replies Latest reply on Dec 4, 2007 11:06 AM by mjremijan

    Trouble accessing local EJB from webapp

    mjremijan

      It's been a while since I've worked in the EJB world (been doing a lot of just webapp development lately) so please bear with me.

      I am using jboss-4.2.1.GA and java version "1.5.0_11"

      I am working on a simple EJB project. I have 1 local session bean an 1 entity bean which is managed by the Java Persistence API. I pack this all up into an ear file and deploy it to jboss. I can see in the JNDIList the ejb is deployed:

      +- oak.oths.domain (class: org.jnp.interfaces.NamingContext)
       | +- AlumniEjb (class: org.jnp.interfaces.NamingContext)
       | | +- local (proxy: $Proxy172 implements interface org.oak.oths.domain.alumni.AlumniLocal,interface org.jboss.ejb3.JBossProxy,interface javax.ejb.EJBLocalObject)
      


      Now I have a webapp. This webapp is deployed as a seperate war file. Inside the webapp I do a JNDI lookup, find the object, but get a java.lang.ClassCastException when I try to typecast or PortableRemoteObject.narrow() it to the EJB's local interface, AlumniLocal.

      // This causes a ClassCastException!
      AlumniLocal local
       = (AlumniLocal)ctx.lookup("oak.oths.domain/AlumniEjb/local");
      


      I can loop over the interfaces which the class implements and it does indeed implement the AdminLocal interface so my question is why am I getting this ClassCastException? If the EJB is in an EAR file and the webapp is deployed as a seperate WAR file can the two not use Local interfaces?