8 Replies Latest reply on May 15, 2003 8:48 AM by frito

    ClassLoading issue with multiple deployments

    ben2

      Jboss version: Jboss-3.0.6

      I am getting a ClassNotFoundException when trying to access an EJB

      Ok I have the following deployments
      OracleBridge.ear <-Set of EJBs
      KronosBridge.ear <- Set of EJBs
      FormServer-Payroll.ear <- Web application that uses above EJBs

      I have added a jboss-app.xml in each of those deployments with the following lines in each one
      &lt;loader-repository&gt;fast.rit.edu:loader=OracleBridge.ear&lt;/loader-repository&gt;
      &lt;loader-repository&gt;fast.rit.edu:loader=KronosBridge.ear&lt;/loader-repository&gt;
      &lt;loader-repository&gt;fast.rit.edu:loader=FormServer-Payroll.ear&lt;/loader-repository&gt;


      I need these because of other deployments that exist on the server and have version problems.

      When a servlet in the Payroll app looks up an EJB I get this exception


      Exception:java.lang.ClassCastException
      at com.sun.corba.se.internal.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:296)
      at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:137)
      at edu.rit.fast.formserver.payroll.TotalizerForm.getKronosServices(TotalizerForm.java:181)
      at edu.rit.fast.formserver.payroll.TotalizerForm.defaultAction(TotalizerForm.java:110)
      at edu.rit.fast.formserver.BasicFASTForm.getStream(BasicFASTForm.java:103)
      at org.apache.cocoon.producer.AbstractProducer.getDocument(AbstractProducer.java:96)
      at org.apache.cocoon.Engine.handle(Engine.java:359)
      at org.apache.cocoon.Cocoon.service(Cocoon.java:190)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
      at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:360)
      at org.mortbay.jetty.servlet.WebApplicationHandler.dispatch(WebApplicationHandler.java:280)
      at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:553)
      at org.mortbay.http.HttpContext.handle(HttpContext.java:1656)
      at org.mortbay.jetty.servlet.WebApplicationContext.handle(WebApplicationContext.java:549)
      at org.mortbay.http.HttpContext.handle(HttpContext.java:1606)
      at org.mortbay.http.HttpServer.service(HttpServer.java:862)
      at org.jboss.jetty.Jetty.service(Jetty.java:543)
      at org.mortbay.http.HttpConnection.service(HttpConnection.java:752)
      at org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:916)
      at org.mortbay.http.HttpConnection.handle(HttpConnection.java:769)
      at org.mortbay.http.SocketListener.handleConnection(SocketListener.java:202)
      at org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:289)
      at org.mortbay.util.ThreadPool$PoolThread.run(ThreadPool.java:455)





        • 1. Re: ClassLoading issue with multiple deployments
          frito

          The interfaces for the bean access are coming from different classloaders (in fact different repositories as you specified in your jboss-app.xml) .

          You have to deploy all client ressources (Homeinterfaces, Remoteinterfaces) in a jar (or ear) in the standard repository. Every deployed application wil have access on these interfaces.
          Read http://prdownloads.sourceforge.net/jboss/ClassLoading.pdf?download for further infomration.

          Greetings,
          Frito

          • 2. Re: ClassLoading issue with multiple deployments
            frito

            btw, you have to use the <ejb-client-jar> tag in your ejb-jar.xml deployment descriptor, too...

            Greetings,
            Frito

            • 3. Re: ClassLoading issue with multiple deployments
              ben2

              First thank you very much for your reply, I think I understand the problem a little better.

              I am a little unclear on where I put the EJB client jar then because I think I did what you said and I am having the same problem.

              Here is my deployments now

              OracleBridge.ear
              +OracleBridge-ejb.jar
              +META-INF\MANIFEST.MF
              Class-Path: <some libraries>
              +META-INF\ejb-jar.xml
              <ejb-client-jar>OracleBridge-client.jar</ejb-client-jar>
              +OracleBridge-client.jar
              +<some libraries>
              +application.xml
              +jboss-app.xml
              <loader-repository>fast.rit.edu:loader=OracleBridge.ear</loader-repository>


              KronosBridge.ear
              +KronosBridge-ejb.jar
              +META-INF\MANIFEST.MF
              Class-Path: <some libraries>
              +META-INF\ejb-jar.xml
              <ejb-client-jar>KronosBridge-client.jar</ejb-client-jar>
              +KronosBridge-client.jar
              +<some libraries>
              +application.xml
              +jboss-app.xml
              <loader-repository>fast.rit.edu:loader=KronosBridge.ear</loader-repository>

              FormServer-Payroll.ear
              +FormServer-Payroll-web.war
              +<all web files>
              +WEB-INF\MANIFEST.MF
              Class-Path: OracleBridge-client.jar KronosBridge-client.jar
              +OracleBridge-client.jar
              +KronosBridge-client.jar
              +application.xml
              +jboss-app.xml
              <loader-repository>fast.rit.edu:loader=FormServer-Payroll.ear</loader-repository>


              • 4. Re: ClassLoading issue with multiple deployments
                frito

                Sorry, what I told you is working for e.g. the same application deployed in different versions.

                I aggree, this behaviour is strange since I really would like to access an ejb deployed in ear1 from another ejb deployed in ear2 (where both have the remote interface and bean interface with them).

                I am looking for a satisfying solution, too...

                Greetings,
                Frito

                • 5. Re: ClassLoading issue with multiple deployments
                  ben2

                  Can somebody please tell me for certain if this is possible.

                  Ben

                  • 6. Re: ClassLoading issue with multiple deployments
                    kishoreb

                    We have a similar problem on JBOSS3.2.0.
                    loader-repository works fine for loading the multiple versions of libraries. But it fails on PortableRemoteObject.narrow(.,.) call on looking up the ejb's deployed on different ear file. Did you find the solution for this problem.

                    • 7. Re: ClassLoading issue with multiple deployments
                      ben2

                      My solution is as follows, (I hope Jboss developers are listening because this is just crap).

                      In the deploy directory I have

                      FormServer-Payroll.ear - This contains a jboss-app.xml to scope it out and NO OracleBridge interfaces, even though it uses them, more on this below.

                      OracleBridge.ear - The only classes this contains is the bean implementation, no interfaces. It contains libraries and a jboss-app.xml to scope it out

                      OracleBridge-client.jar - This is just a standard jar file with all the support classes and interfaces the really should reside in the OracleBridge.ear

                      oraclebridge-commonclasspath-service.xml - This is a service.xml file with the sole purpose is to load the OracleBridge-client.jar into the common classloader. This way both the OracleBridge.ear and the Payroll-Formserver.ear can access it


                      This is the best solution that I have found so far. By doing this the only thing that goes into the common classloader is the OracleBridge interfaces and I don't have to worry about library conflicts.

                      Hope this helps.

                      Ben

                      • 8. Re: ClassLoading issue with multiple deployments
                        frito