5 Replies Latest reply on Apr 3, 2008 10:17 AM by Tim Fox

    ClassLoader issue with user classes and JBM 1.0.1SP4

    justin Newbie


      I'm having some trouble migrating to JBoss Messaging 1.0.1SP4 from JBossMQ. I'm running JBossAS 4.0.5GA.

      The problem is when onMessage() is called in a JMS client in an ear. I get a "java.lang.ClassNotFoundException: No ClassLoaders found for: <my class>". That class is located in a jar within the ear.

      I can instantiate the class elsewhere without a problem, so it's not a missing jar issue. When the class is deserialized from the JMS ObjectMessage.getObject() method, the above-mentioned exception occurs:

      public void onMessage(Message message) {
       try {
       ObjectMessage objectMessage = (ObjectMessage) message;
       DNSAMessage dnsaMessage = (DNSAMessage) objectMessage.getObject();

      I've read through the scoped classloader wiki docs, and even tried setting the ear to use the same loader-repository as jboss-messaging as suggested in other threads. Predictably, if I copy the jar containing my userland class into jboss-messaging.sar, the class is found but a ClassCastException is thrown, because two separate classloaders are now trying to use the same classes.

      I'm guessing since onMessage is called by a JBM thread, it uses JBM's classloader, hence the problem. How should I configure JBM so that it doesn't try to load my userland classes?

      Thank you for any ideas and help.