Author |
Message
|
kevin.shen |
Posted: Tue Sep 25, 2007 12:44 pm Post subject: How to resolve NoClassDefFoundError in message broker? |
|
|
Novice
Joined: 05 Sep 2007 Posts: 18
|
I got NoClassDefFoundError in testing message flow project with
JavaCompute node
Here is the scenario:
1. The Message Flow Java project references framework classes in
another Java project
2. Project dependency has been set in Message Broker Toolkit Java Build
Path for Message Flow Java project
3. Jar file for framework Java project created and copied to workpath
4. The code that causes this error In evaluate() method of JavaCompute
node:
WMBServiceObject so = WMBServiceLocator.getServiceObject(nodeName);
Here, WMBServiceObject is a Java Interface, WMBServiceLocator actually returns an instance of a concrete class which implements this interface
Can anyone tell me what causes this error, and how to fix it?
Thanks! |
|
Back to top |
|
 |
jefflowrey |
Posted: Tue Sep 25, 2007 12:50 pm Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
It's either a classloader problem or a simple problem of not having the right class on the classpath.
*where* on the "workpath" did you put the jar file?
Did you restart broker after doing so?
Is the jar file containing the concrete class on the classpath somehow - or in the BAR file?
The simplest thing to start with is: put every jar file you might possibly need into the BAR file. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
kevin.shen |
Posted: Tue Sep 25, 2007 12:57 pm Post subject: |
|
|
Novice
Joined: 05 Sep 2007 Posts: 18
|
jefflowrey wrote: |
It's either a classloader problem or a simple problem of not having the right class on the classpath.
*where* on the "workpath" did you put the jar file?
Did you restart broker after doing so?
Is the jar file containing the concrete class on the classpath somehow - or in the BAR file?
The simplest thing to start with is: put every jar file you might possibly need into the BAR file. |
The workpath is "C:\Documents and Settings\All Users\Application Data\IBM\MQSI\shared-classes"
I restart the broker every time I copy this Jar file to work path
The Jar file is only copied to workpath, wich is path of the classpath, it is not part of the Bar file, and the Jar file contains all concrete classes referenced by the JavaCompute node
I will try to include the Jar file into Bar file to see what happens
Thanks a lot! |
|
Back to top |
|
 |
jefflowrey |
Posted: Tue Sep 25, 2007 1:06 pm Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
|
Back to top |
|
 |
kevin.shen |
Posted: Tue Sep 25, 2007 1:34 pm Post subject: |
|
|
Novice
Joined: 05 Sep 2007 Posts: 18
|
The framework creates the instance of concrete class, and JCN asks framework for the right instance
Do you mean I should make change to create the instance in JCN?
Thanks! |
|
Back to top |
|
 |
jefflowrey |
Posted: Tue Sep 25, 2007 1:38 pm Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
No, I'm not suggesting it one way or another.
I'm suggesting that you keep track of which classloader is going to be asked to load which classes - and make sure that the necessary classes are visible to that classloader.
Or put everything in one classloader - at least initially. that way you can eliminate classloader issues until you know you have all the actual dependencies resolved.
And then determine which jar files need to go to which classloader after that.
You likely have the right structure already - but you may be missing dependencies... the framework might need a class that's not on the classpath or etc. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
kevin.shen |
Posted: Tue Sep 25, 2007 5:44 pm Post subject: |
|
|
Novice
Joined: 05 Sep 2007 Posts: 18
|
jefflowrey wrote: |
No, I'm not suggesting it one way or another.
I'm suggesting that you keep track of which classloader is going to be asked to load which classes - and make sure that the necessary classes are visible to that classloader.
Or put everything in one classloader - at least initially. that way you can eliminate classloader issues until you know you have all the actual dependencies resolved.
And then determine which jar files need to go to which classloader after that.
You likely have the right structure already - but you may be missing dependencies... the framework might need a class that's not on the classpath or etc. |
I included framework Jar file into Bar file, however, I still got this error
How you put everything in one classloader?
How you keep track of the classloaders to be used?
Thanks! |
|
Back to top |
|
 |
jefflowrey |
Posted: Tue Sep 25, 2007 6:16 pm Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
If you're still getting this error, then you don't have everything you need in the BAR file.
You put everything in one classloader by putting it all in the BAR. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
kevin.shen |
Posted: Tue Sep 25, 2007 6:32 pm Post subject: |
|
|
Novice
Joined: 05 Sep 2007 Posts: 18
|
jefflowrey wrote: |
If you're still getting this error, then you don't have everything you need in the BAR file.
You put everything in one classloader by putting it all in the BAR. |
I did put it into Bar file, I can see it from the view, the Jar file is now part of the Bar file
Do I still need to copy the Jar file to shared-classes directory?
Any other way to trouble-shoot this problem?
Thanks! |
|
Back to top |
|
 |
jefflowrey |
Posted: Tue Sep 25, 2007 7:11 pm Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
The stuff you've put in the BAR file may depend on things that aren't in any of the JARs. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
kevin.shen |
Posted: Wed Sep 26, 2007 8:57 am Post subject: |
|
|
Novice
Joined: 05 Sep 2007 Posts: 18
|
jefflowrey wrote: |
The stuff you've put in the BAR file may depend on things that aren't in any of the JARs. |
I saw three classLoaders in debug view, DummyClassLoader, EgSharedClassLoader, and SharedClassLoader
It seems JCN is loaded by EgSharedClassLoader, and framework classes are loaded by EgSharedClassLoader, however, every thing is in the same Bar file
Also, I used Sun's Jar utility to create Jar file, not IBM's, does this cause problem?
Thanks! |
|
Back to top |
|
 |
jefflowrey |
Posted: Wed Sep 26, 2007 9:04 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
There may be classes that are required for the framework that aren't in the jar file for the framework.
I posted a link to the InfoCenter documentation that shows you the different classloaders, including EgShared,Shared, and etc.
It's good that you're seeing the framework in the EgShared, that means it's getting loaded from the BAR file successfully.
Other than going through the code for the class that is being reported as NoClassDefFound to find out what it depends on, there isn't anything very methodical you can try.
The only other thing I can suggest is to just reboot the broker a couple of times. I've seen NoClassDef problems mysteriously go away from doing that. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
kevin.shen |
Posted: Wed Sep 26, 2007 10:39 am Post subject: |
|
|
Novice
Joined: 05 Sep 2007 Posts: 18
|
jefflowrey wrote: |
There may be classes that are required for the framework that aren't in the jar file for the framework.
I posted a link to the InfoCenter documentation that shows you the different classloaders, including EgShared,Shared, and etc.
It's good that you're seeing the framework in the EgShared, that means it's getting loaded from the BAR file successfully.
Other than going through the code for the class that is being reported as NoClassDefFound to find out what it depends on, there isn't anything very methodical you can try.
The only other thing I can suggest is to just reboot the broker a couple of times. I've seen NoClassDef problems mysteriously go away from doing that. |
Sorry, my mistake, Framework classes are loaded by "com.ibm.broker.classloading.SharedClassLoader"
Do I need to remove the Framework Jar file from shared-classes directory?
Also, the error message associated with NoClassDefFoundError is "Local Variables Unavailable"
Thanks! |
|
Back to top |
|
 |
jefflowrey |
Posted: Wed Sep 26, 2007 10:53 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
It's probably worth removing it from shared-classes and restarting.
It might not be loading them from the BAR in EGShared because it already finds them in shared-classes. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
kevin.shen |
Posted: Wed Sep 26, 2007 5:04 pm Post subject: |
|
|
Novice
Joined: 05 Sep 2007 Posts: 18
|
jefflowrey wrote: |
It's probably worth removing it from shared-classes and restarting.
It might not be loading them from the BAR in EGShared because it already finds them in shared-classes. |
It seems EgSharedClassLoader calls "com.ibm.broker.classloading.DummyClassLoader" to load framework class, instead of delegating this to "com.ibm.broker.classloading.SharedClassLoader", I can see from debugger view, both DummyClassLoader and SharedClassLoader are parent class loader of EgSharedClassLoader
I cannot find any information about DummyClassLoader, could you explain this for me?
Thanks a lot! |
|
Back to top |
|
 |
|