6 Replies Latest reply on Mar 23, 2007 5:16 PM by clebert.suconic

    Scoped classloaders question

    georgesberscheid

      Hi,

      I installed JBMessaging 1.2.0 on JBAS 4.0.5 where I was previously using JBMQ. I have about a dozen EARs deployed in the /deploy directory, and each of them uses their own scoped classloader to avoid conflicts between classes loaded from each of the applications.

      What's the best scenario for using JBMessaging classes from each of those applications? Do I really need to package the JBM libs into every EAR? This would cause a significant overhead on memory usage. Can I create a classloader hierarchy and attach my application's classloaders to the JBM classloader?

      Any help is greatly appreciated.
      Georges

        • 1. Re: Scoped classloaders question

          Probably this link may answer your question:

          http://wiki.jboss.org/wiki/Wiki.jsp?page=JBossMessagingUser_Deploying_a_scoped_MDB_container

          Although it's for deploying scoped MDB, principal should be same, I suppose.

          Thanks
          Madhu

          • 2. Re: Scoped classloaders question
            georgesberscheid

            Hmm, that WIKI entry confuses me a little. How would my deployed application be able to access the client libraries if they are deployed in a scoped classloader that's different from the application's?

            Indeed, I get the following exception when I try to open a JMS Topic Connection:

            TopicConnectionFactory factory = (TopicConnectionFactory) initialContext.lookup("ConnectionFactory");
            topicConnection = factory.createTopicConnection();
            topicConnection.start();

            java.lang.RuntimeException: java.lang.ClassNotFoundException: No ClassLoaders found for: org.jboss.jms.client.container.ClosedInterceptor
             at org.jboss.aop.advice.GenericAspectFactory.getClazz(GenericAspectFactory.java:141)
             at org.jboss.aop.advice.GenericAspectFactory.createPerInstance(GenericAspectFactory.java:182)
             at org.jboss.aop.InstanceAdvisorDelegate.initializeAspects(InstanceAdvisorDelegate.java:100)
             at org.jboss.aop.InstanceAdvisorDelegate.initialize(InstanceAdvisorDelegate.java:72)
             at org.jboss.aop.ClassInstanceAdvisor.<init>(ClassInstanceAdvisor.java:75)
             at org.jboss.jms.client.delegate.ClientConnectionDelegate._getInstanceAdvisor(ClientConnectionDelegate.java)
             at org.jboss.jms.client.delegate.ClientConnectionDelegate.start(ClientConnectionDelegate.java)
             at org.jboss.jms.client.JBossConnection.start(JBossConnection.java:144)


            I'm using JBAS 4.0.5 and CallByValue is set to false in /server/default/deploy/naming.sar/META-INF/jboss-service.xml

            Thanks,
            Georges

            • 3. Re: Scoped classloaders question
              georgesberscheid

              Hmm, still stuck... Any ideas?

              • 4. Re: Scoped classloaders question
                clebert.suconic

                 

                "georgesberscheid" wrote:
                Hmm, that WIKI entry confuses me a little. How would my deployed application be able to access the client libraries if they are deployed in a scoped classloader that's different from the application's?

                Indeed, I get the following exception when I try to open a JMS Topic Connection:
                TopicConnectionFactory factory = (TopicConnectionFactory) initialContext.lookup("ConnectionFactory");
                topicConnection = factory.createTopicConnection();
                topicConnection.start();

                java.lang.RuntimeException: java.lang.ClassNotFoundException: No ClassLoaders found for: org.jboss.jms.client.container.ClosedInterceptor
                 at org.jboss.aop.advice.GenericAspectFactory.getClazz(GenericAspectFactory.java:141)
                 at org.jboss.aop.advice.GenericAspectFactory.createPerInstance(GenericAspectFactory.java:182)
                 at org.jboss.aop.InstanceAdvisorDelegate.initializeAspects(InstanceAdvisorDelegate.java:100)
                 at org.jboss.aop.InstanceAdvisorDelegate.initialize(InstanceAdvisorDelegate.java:72)
                 at org.jboss.aop.ClassInstanceAdvisor.<init>(ClassInstanceAdvisor.java:75)
                 at org.jboss.jms.client.delegate.ClientConnectionDelegate._getInstanceAdvisor(ClientConnectionDelegate.java)
                 at org.jboss.jms.client.delegate.ClientConnectionDelegate.start(ClientConnectionDelegate.java)
                 at org.jboss.jms.client.JBossConnection.start(JBossConnection.java:144)


                I'm using JBAS 4.0.5 and CallByValue is set to false in /server/default/deploy/naming.sar/META-INF/jboss-service.xml

                Thanks,
                Georges


                That's why we ask JNDI set callByReference... then your client will get a handle to another class loaded in a different classLoader what should be okay.


                This exception you're getting is a bug we are fixing early next week.. about classLoading isolations on aspects... if you download sources from the SP branch it should be already fixed... but we don't have a release yet...

                this should be out over the weekend/early next week.!

                • 5. Re: Scoped classloaders question
                  georgesberscheid

                  Alrighty, but even if I get a reference to a class from a different classloader, I still need the remote interface implemented by that instance to be in the client classloader right?
                  Which JAR would I have to include in my client application?

                  • 6. Re: Scoped classloaders question
                    clebert.suconic

                    If your both applications are on the same JAR... as JNDI is set to use byReference... you will get a reference to classes on messging.sar.

                    So.. you will need these classes in your client jar if you were using callByValue.


                    Now.. if you need callByValue on JNDI for any reason.. then you will need to scope your client with messaging libraries... but this is more complicate.

                    We are looking forward to synchronize versions of aop and remoting on jboss 4.2 what would eliminate the need of scoping messaging, what would make its usage easier.