1 2 Previous Next 18 Replies Latest reply on Feb 3, 2011 1:31 PM by clebert.suconic

    ClassNotFoundException HornetQ


      Hello everyone, I have a problem working with the HornetQ queue system, I developed a class that implements the javax.jms.MessageListener intereface; in the "onMessage" method I am calling an  object function of my App, it looks like this:



      public static Router router;
           try {
                Context ctx = new InitialContext();
                router = (Router) ctx.lookup("gw-server/RouterBean/remote");
           } catch (NamingException e) {
      public void onMessage(Message msg) {
           try {
           } catch (Throwable t) {



      but the line "router.processMessage(msg)" the system throws the following exception:


      16:08:34,581 ERROR [STDERR] java.lang.RuntimeException: Specified calling class, gw.beans.Router could not be found for BaseClassLoader@247973e4{vfs:///home/greenwise/Applications/jboss/jboss-}

      16:08:34,581 ERROR [STDERR] at org.jboss.ejb3.common.lang.SerializableMethod.getClassFromName(SerializableMethod.java:311)

      16:08:34,581 ERROR [STDERR] at org.jboss.ejb3.common.lang.SerializableMethod.getClassType(SerializableMethod.java:282)

      16:08:34,581 ERROR [STDERR] at org.jboss.ejb3.common.lang.SerializableMethod.toMethod(SerializableMethod.java:233)

      16:08:34,582 ERROR [STDERR] at org.jboss.ejb3.common.lang.SerializableMethod.toMethod(SerializableMethod.java:220)

      16:08:34,582 ERROR [STDERR] at org.jboss.ejb3.proxy.impl.handler.session.SessionProxyInvocationHandlerBase.invoke(SessionProxyInvocationHandlerBase.java:186)

      16:08:34,582 ERROR [STDERR] at $Proxy169.processMessage(Unknown Source)

      16:08:34,582 ERROR [STDERR] at gw.queue.Consum.onMessage(Consum.java:152)

      16:08:34,582 ERROR [STDERR] at org.hornetq.jms.client.JMSMessageListenerWrapper.onMessage(JMSMessageListenerWrapper.java:91)

      16:08:34,582 ERROR [STDERR] at org.hornetq.core.client.impl.ClientConsumerImpl.callOnMessage(ClientConsumerImpl.java:823)

      16:08:34,583 ERROR [STDERR] at org.hornetq.core.client.impl.ClientConsumerImpl.access$100(ClientConsumerImpl.java:46)

      16:08:34,583 ERROR [STDERR] at org.hornetq.core.client.impl.ClientConsumerImpl$Runner.run(ClientConsumerImpl.java:941)

      16:08:34,583 ERROR [STDERR] at org.hornetq.utils.OrderedExecutorFactory$OrderedExecutor$1.run(OrderedExecutorFactory.java:96)

      16:08:34,583 ERROR [STDERR] at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)

      16:08:34,583 ERROR [STDERR] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)

      16:08:34,583 ERROR [STDERR] at java.lang.Thread.run(Thread.java:619)

      16:08:34,584 ERROR [STDERR] Caused by: java.lang.ClassNotFoundException: gw.beans.Router from BaseClassLoader@247973e4{vfs:///home/greenwise/Applications/jboss/jboss-}

      16:08:34,584 ERROR [STDERR] at org.jboss.classloader.spi.base.BaseClassLoader.loadClass(BaseClassLoader.java:480)

      16:08:34,584 ERROR [STDERR] at java.lang.ClassLoader.loadClass(ClassLoader.java:248)

      16:08:34,584 ERROR [STDERR] at java.lang.Class.forName0(Native Method)

      16:08:34,584 ERROR [STDERR] at java.lang.Class.forName(Class.java:247)

      16:08:34,585 ERROR [STDERR] at org.jboss.ejb3.common.classloader.util.PrimitiveClassLoadingUtil.loadClass(PrimitiveClassLoadingUtil.java:99)

      16:08:34,585 ERROR [STDERR] at org.jboss.ejb3.common.lang.SerializableMethod.getClassFromName(SerializableMethod.java:307)

      16:08:34,585 ERROR [STDERR] ... 14 more



      My system has added all interfaces that apparently are missing... any ideas??


        • 1. Re: ClassNotFoundException HornetQ

          The classLoader at your EAR/WAR/Jar application containing your MDB is missing reference to gw.beans.Router



          At the time of onMessage, it will be using the same classloader where your EJB is located.



          You can fix that by either adding your gw.beans.Router to the main classPath, or adding the library to your EAR.  (Whatever fits your requirements better)

          • 2. Re: ClassNotFoundException HornetQ

            Hello Clebert, thanks for the reply,

            My project has added the jar that contain the gw.beans.Router interface.

            The funny thing about the problem is that if I add at the  onMessage  function an instance of Router, as follow:


            public void onMessage(Message msg) {
                 try {
                      Router r = new RouterBean();
                 } catch (Throwable t) {



            the function ping() works fine, but then, the system throws the same exception at the same line (router.processMessage).

            I had a partial solution adding the jar that contain the interface Router in the directory <JBOSS_HOME>/server/default/lib, but that causes others problems, basically, duplicate classes.


            • 3. Re: ClassNotFoundException HornetQ

              Hello Carlos,


              that sounds interesting.


              Could you please describe how you are deploying the app. Do you use an Ear-File, are you starting the JBoss from Eclipse etc?


              With best regards



              • 4. Re: ClassNotFoundException HornetQ

                Looking at that stacktrace it appears that the delivery of the message in happening in the context of the server level classloader instead of the (isolated) ear deployment specific classloader. As a result, the server level classloader isn't able to "see" the (isolated) .ear level classes.

                • 5. Re: ClassNotFoundException HornetQ

                  As a quick test, you can try setting the following property in JBOSS_HOME/server/< servername>/deployer/ear-deployer-jboss-beans.xml to false:

                  <bean name="EARClassLoaderDeployer">
                        <!-- A flag indicating if ear deployments should have their own scoped
                           class loader to isolate their classes from other deployments.
                        <property name="isolated">false</property>



                  P.S: Remember, this is just for testing and it's not recommended to set it to false in real dev/prod environment.

                  • 6. Re: ClassNotFoundException HornetQ

                    You didn't state the HornetQ version you're using...  or if you're using it from AS6.. etc...


                    I have done myself a few changes on the Executors used by RA.. I think that would fix it... Can you confirm it please?

                    • 7. Re: ClassNotFoundException HornetQ

                      Hello andreas,


                      I am using Jboss 6 M4 and Java version "1.6.0_20",  I start jboss from a shell using its binaries.


                      My project consist of many EAR apps, one of them is the master app that contain a WAR file, an EJB JAR file and a SAR file. The others are EARs app too that depend of the master.


                      Best regards

                      • 8. Re: ClassNotFoundException HornetQ

                        Hello jaikiran pai, thanks for the reply


                        I configured the isolated property setting it as "true". I did it because my project has many zones that depends of a master app; I tried the system setting this property as "false", but jboss confuses and mix all the zones. Every zone has the same classes, but they have different configurations. For my project is mandatory set the isolation property as true.


                        Thanks for everything, my best regards

                        • 9. Re: ClassNotFoundException HornetQ

                          Can you provide a package (or a few packages) showing the issue?


                          As we say on the top of this forum... http://community.jboss.org/docs/DOC-14508

                          • 10. Re: ClassNotFoundException HornetQ

                            Hi Clebert,


                            My  HornetQ version is 2.1.1.Final, but I am using it from jboss 6 M4.


                            Best regards

                            • 11. Re: ClassNotFoundException HornetQ

                              Yes, I saw you answering that already...



                              It seems you're using some complex deployment there. We would need some testcase replicating the issue.


                              Can you provide us something.. you don't need to write any rocket science test.. You can just remove any business specific stuff from your code, and give us something replicating it.



                              As we said on that WIKI that posted you.. We always ask users to provide testcases when they inform bugs.. it's a way to I help you , you help me... or one hand wash the other as we say in Brazil.

                              • 12. Re: ClassNotFoundException HornetQ

                                Hello Clebert,


                                I attached a zip that contain an EAR file and its source code.


                                This is a very easy test case where you can see the exception; just follow the steps:



                                - Set the isolation property as "true" (JBOSS_HOME/server/default/deployers/ear-deployer-jboss-beans.xml)

                                - Set the callByValue property as "true"  (JBOSS_HOME/server/default/deployers/ear-deployer-jboss-beans.xml)

                                -  Set the callByValue property as "true" (JBOSS_HOME/server/default/deployers/ejb-deployer-jboss-beans.xml)


                                1- Start jboss and deploy the gw-app-server.ear.


                                2- Open your browser and type  http://localhost:8080/Gweb/

                                    When you open this url, an example queue  and its consumer will be created.


                                3- When the url is open, there is a link that you can click to publish a new message in the queue


                                4- After click, you will see the exception

                                    If you still clicking the link, you will see the same exception over and over again


                                Thanks for your interest in this case, my best regards

                                • 13. Re: ClassNotFoundException HornetQ

                                  Hello Clebert,


                                  I just contact you to know if you could find something that can help me with the problem. did you replicate the exception? Sorry for bother you.


                                  Best Regards,


                                  Carlos Rodriguez

                                  • 14. Re: ClassNotFoundException HornetQ

                                    I'm sorry Carlos.. I haven't forgot about you... I have been working with some other issues.


                                    Give me another day and i will get back to you on this. Sorry for the delay.

                                    1 2 Previous Next