1 Reply Latest reply on Nov 2, 2005 10:12 AM by Erik Sliman

    Cannot access EJB from war inside container

    Erik Sliman Apprentice

      We have an instance where an independently deployed unisolated war cannot access the EJBs in an unisolated ear. They are both in the same JBoss 4.0.2 instance.

      Applications running in their own JVMs have no problem accessing the EJBs remotely. The problem appears to be related to the use of the UCL, and perhaps Tomcat's classloading behavior.

      The first exception it throws is a class cast exception when trying to cast the home interface. The second time it tries, it throws

      2005-11-01 09:39:31,651 ERROR [com.nwms.emrweb.services.JNDIClientUtil] lookupHome(..)-NamingException: Could not create initial context for environment null
      javax.naming.NoInitialContextException: Cannot instantiate class: org.jnp.interfaces.NamingContextFactory [Root exception is java.lang.ClassNotFoundException: org/jnp/interfaces/NamingContextFactory]
       at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:657)
       at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:247)
       at javax.naming.InitialContext.init(InitialContext.java:223)
       at javax.naming.InitialContext.<init>(InitialContext.java:197)
       at com.nwms.emrweb.services.JNDIClientUtil.lookupHome(JNDIClientUtil.java:33)
       at com.nwms.emrweb.services.business.ejb.share.ProviderServiceUtil.getHome(ProviderServiceUtil.java:32)
       at com.nwms.emrweb.services.business.ejb.share.ProviderServiceUtil.getHome(ProviderServiceUtil.java:37)
       at com.nwms.emrweb.services.client.BusinessService.getProviderServiceHome(BusinessService.java:112)
       at com.nwms.emrweb.services.client.BusinessService.getProviderService(BusinessService.java:124)
       at com.nwms.emrweb.services.client.BusinessService.logout(BusinessService.java:333)
       at com.nwms.emr.context.CPRContext.deactivateUser(CPRContext.java:316)
       at com.nwms.emr.context.CPRContext.destroy(CPRContext.java:550)
       at com.nwms.emr.context.CPRContext.finalize(CPRContext.java:582)
       at java.lang.ref.Finalizer.invokeFinalizeMethod(Native Method)
       at java.lang.ref.Finalizer.runFinalizer(Finalizer.java:83)
       at java.lang.ref.Finalizer.access$100(Finalizer.java:14)
       at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:160)
      Caused by: java.lang.ClassNotFoundException: org/jnp/interfaces/NamingContextFactory
       at java.lang.Class.forName0(Native Method)
       at java.lang.Class.forName(Class.java:242)
       at com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.java:42)
       at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:654)
       ... 16 more


      I've never had to add jnp-client within a client app deployed in JBoss before, but for kicks, when I try it, it throws a socket timeout exception.

      I'm debugging in IntelliJ, and can breakpoint the app code when these exceptions are thrown, but have not been able to gleen any useful information, such as the host/port being accessed when the socket exception is thrown.

      There are only two instances of the remote home interface being deployed, one in the ear and another in a client jar in the war. The classes are exactly the same. It's compiled once and packaged into the EJB jar and the client jar. Opening the archives in WinRAR reveals that they have the same CRC and timestamp.

      Using name=Default,service=LoaderRepository from jmx-console reveals that the UCL is loading the class from the ear. It does not list the instance from the war, and I suspect this is because it is being loaded by Tomcat.

      This is a very critical bug. Please help if you can. I've spent two days on it so far and have run out of configuration permutations to try, including with and without the JBAS-1875 patch, with and without JAAS, etc,... Right now I'm trying to get it to work with the most common configuration.

      Thanks a bunch in advance!