2 Replies Latest reply on Feb 16, 2005 9:27 AM by Giuseppe Pellegrino

    Problem looking up EJB in its own classloader, JBoss3.2.5

    joe Newbie

      We are having problems deploying EJB applications under a combined JBoss3.2.5/Tomcat5x server. What we want to do is be able to deploy multiple EARs which contain EJBs, and WARs which reference those EJBs. We would like to have some EARs which might provide EJBs which are common to several applications.

      We are having problems configuring our EARs and WARs, even in the simplest case, and are hoping someone may be able to help.

      In the simplest case what we want to deploy is something like this:

      JBoss Deploy Dir
      ----------------
      |
      |---Application1.ear
      | |
      | |---Application1Ejb.jar
      | | |---applicationlayer.User
      | | |---applicationlayer.UserBean
      | | |---applicationlayer.UserHome
      | |
      | |---Other.jar
      | |
      | |---META-INF
      | |---application.xml
      | |---jboss-app.xml
      | |---Manifest.mf
      |
      |---Client1.war
      | |
      | |---WEB-INF
      | |---web.xml
      | |---jboss-web.xml
      | |
      | |---classes
      | | |---client.TestServlet
      | |
      | |---lib
      | |---Application1EjbClientClasses.jar
      | | |---applicationlayer.User
      | | |---applicationlayer.UserHome
      | |
      | |---Other.jar

      In the above we have a web application, Client1.war, which invokes an EJB in an application, Application1.ear, by doing a Jndi lookup (we haven't coded local EJB classes).
      Both Application1 and Client1 contain their own version of some common code in Other.jar. In order for Client1 and Application1 to work correctly, they also need to be able to use code from their own version of Other.jar (that is packaged inside them) - this means they each need to be loaded by their own class loader. (Later, we might deploy another application, Application2.ear which also might want to lookup EJBs in Application1.ear.)

      We found several references which indicated several things needed to be
      configured to make things work. Currently we have:

      Excerpt from web.xml -
      <loader-repository>client1:loader=Client1.war</loader-repository>
      <ejb-ref>
      <ejb-ref-name>UserBean</ejb-ref-name>
      <ejb-ref-type>Session</ejb-ref-type>
      applicationlayer.UserHome
      applicationlayer.User
      </ejb-ref><ejb-ref>
      <ejb-ref-name>UserBean</ejb-ref-name>
      <jndi-name>jnp://localhost/UserBeanJndiName</jndi-name>
      </ejb-ref>
      Other.jar


      Excerpt from ejb-jar.xml -
      <enterprise-beans>

      <display-name>UserBean</display-name>
      <ejb-name>UserBean</ejb-name>
      applicationlayer.UserHome
      applicationlayer.User
      <ejb-class>applicationlayer.UserBean</ejb-class>
      <session-type>Stateless</session-type>
      <transaction-type>Bean</transaction-type>

      </enterprise-beans>

      Excerpt from jboss.xml -
      <enterprise-beans>

      <ejb-name>UserBean</ejb-name>
      <jndi-name>UserBeanJndiName</jndi-name>

      </enterprise-beans>

      Excerpt from jboss-app.xml -
      <loader-repository>application1:loader=Application1Ejb.ear</loader-repository>


      When we run the TestServlet with this configuration, we get the following error, which we haven't been able to resolve:
      2005-02-08 10:07:26,047 ERROR [org.jboss.ejb.plugins.LogInterceptor] EJBException: javax.ejb.EJBException: Invalid invocation, check your deployment packaging, method=public abstract applicationlayer.User applicationlayer.UserHome.create() throws java.rmi.RemoteException,javax.ejb.CreateException

      If we deploy Client1.war in a stand-alone Tomcat instance, and Application1.ear in a separate JBoss instance, then the Jndi lookup succeeds and everything works as expected.

      Also, if we deploy both Client1.war and Application1.ear in the combined JBoss/Tomcat using the default class loader (ie without the loader-repository tags), then the Jndi lookup succeeds and the servlet works (but only the first loaded Other.jar classes are visible, which is not what we want).

      This implies that the 'standard' part of the EJB packaging/lookup is correct, and that there is some JBoss-specific configuration that we are missing. We have tried several variations of things with no success.

      Can anyone suggest what the solution might be please?

        • 1. Re: Problem looking up EJB in its own classloader, JBoss3.2.
          joe Newbie

          I found the answer in the following link:
          http://www.jboss.org/wiki/Wiki.jsp?page=ClassLoadingConfiguration
          which seems to be a pretty much spot-on.

          The missing bit was in our config was in
          jboss-3.2.5\server\default\conf\jboss-service.xml -

          <!-- EAR deployer, remove if you are not using Web layers -->
          mbean code="org.jboss.deployment.EARDeployer" name="jboss.j2ee:service=EARDeployer"
          attribute name="Isolated">true</attribute
          attribute name="CallByValue">true</attribute

          After including the "Isolated" and "CallByValue" attributes, the Ejb Jndi lookup now works.

          There was also a mistake in the jndi-name published in the post - the port number should have been appended to "localhost".

          The Wiki page indicates there is a performance penalty for using "call by Value", but at least the client code runs unchanged.

          Thanks.



          • 2. Re: Problem looking up EJB in its own classloader, JBoss3.2.
            Giuseppe Pellegrino Newbie

            Hello, I have done the same thing, but after setting up the attributes as you have described, my application does not answer sure in useful time! Perhaps the marshalling and unmarshalling of the objects it's very inefficient!

            There is another solution for this problem???