-
1. Re: ClassLoader behaviour on remote clustering tests
clebert.suconic Apr 9, 2008 9:45 AM (in response to flavia.rainone)The only thing we do on the server side is a ClassLoaderDelegate.
At Service Container:private void registerClassLoader() throws Exception { ClassLoader cl = getClass().getClassLoader(); mbeanServer.registerMBean(new ClassLoaderJMXWrapper(cl), CLASS_LOADER_OBJECT_NAME); }
And this is the ClassLoaderWrapper:
http://anonsvn.jboss.org/repos/messaging/branches/Branch_Stable/tests/src/org/jboss/test/messaging/tools/container/ClassLoaderJMXWrapper.java
You could as a test remove the usage of ClassLoaderJMXWrapper on ServiceContainer. But I believe you should still look for a fix as you might find this bug in other scenarios. (Better to be safe IMO). Maybe you should simulate the same classLoader scenario on a testcase at the AOP sourcetree. -
2. Re: ClassLoader behaviour on remote clustering tests
clebert.suconic Apr 9, 2008 9:46 AM (in response to flavia.rainone)This is the URL for the ServiceContainer:
http://anonsvn.jboss.org/repos/messaging/branches/Branch_Stable/tests/src/org/jboss/test/messaging/tools/container/ServiceContainer.java -
3. Re: ClassLoader behaviour on remote clustering tests
clebert.suconic Apr 9, 2008 9:52 AM (in response to flavia.rainone)ClassLoader.defineclass is a protected method. Do you make any sort of hacks to make the call on classLoader? (Reflection with accessible=true maybe?)
Usually the method that needs to be delegated is loadClass only. Maybe you're calling something that is not being delegated due to some "hacking" behavior added by AOP? -
4. Re: ClassLoader behaviour on remote clustering tests
clebert.suconic Apr 9, 2008 10:19 AM (in response to flavia.rainone)This is interesting:
If I changed ClassLoaderJMSWrapper to look on itself besides the delegate, everything works (even with the latest AOP):public Class<?> loadClass(String name) throws ClassNotFoundException { try { if (name.endsWith("[]")) { name = name.substring(0, name.length() - 2); //The classloader of an array type is the classloader of it's element (if non primitive) Class cl = delegate.loadClass(name); Object arr = Array.newInstance(cl, 0); return arr.getClass(); } else { return delegate.loadClass(name); } } catch (ClassNotFoundException e) { return super.loadClass(name); } }
Now I have a few question:
Is there any hacks from javassist involved on calling the classLoader (direct calls to internal methods)?
Can you check if you are aways using the correct classloader? This might turn a bug on ClassLoaderJMXWrapper only. We just need to double check. -
5. Re: ClassLoader behaviour on remote clustering tests
adrian.brock Apr 9, 2008 10:29 AM (in response to flavia.rainone)"clebert.suconic@jboss.com" wrote:
Can you check if you are aways using the correct classloader? This might turn a bug on ClassLoaderJMXWrapper only. We just need to double check.
If instead of re-inventing the wheel, you used the DelegatingClassLoader from
JBoss Common Core, you'd already have the correct fix.
http://viewvc.jboss.org/cgi-bin/viewvc.cgi/common/common-core/trunk/src/main/java/org/jboss/util/loading/DelegatingClassLoader.java?revision=2787&view=markup
The super.loadClass() works because it invokes findLoadedClass(). -
6. Re: ClassLoader behaviour on remote clustering tests
flavia.rainone Apr 9, 2008 10:30 AM (in response to flavia.rainone)Hi, Clebert!
Is there any hacks from javassist involved on calling the classLoader (direct calls to internal methods)?
Yes, Javassist calls defineClass method, which is internal to ClassLoader. look at the Javassist code that invokes defineClass method:method.setAccessible(true); Class clazz = (Class)method.invoke(loader, args); method.setAccessible(false); return clazz;
Can you check if you are aways using the correct classloader?
The class loader we are using is the class loader that loaded the aspect class:aspect.getClass().getClassLoader();
So that every class generated to interact with the aspect class is actually loaded by the same class loader that loaded the aspect class itself. -
7. Re: ClassLoader behaviour on remote clustering tests
clebert.suconic Apr 9, 2008 10:34 AM (in response to flavia.rainone)If instead of re-inventing the wheel, you used the DelegatingClassLoader from JBoss Common Core, you'd already have the correct fix. http://viewvc.jboss.org/cgi-bin/viewvc.cgi/common/common-core/trunk/src/main/java/org/jboss/util/loading/DelegatingClassLoader.java?revision=2787&view=markup The super.loadClass() works because it invokes findLoadedClass().
Too bad Ovidiu is not here to be Brooked :-)
We will fix it. -
8. Re: ClassLoader behaviour on remote clustering tests
flavia.rainone Apr 9, 2008 10:36 AM (in response to flavia.rainone)I'm curious to know why we hadn't seen this error before.
-
9. Re: ClassLoader behaviour on remote clustering tests
clebert.suconic Apr 9, 2008 10:37 AM (in response to flavia.rainone)And thanks a lot Flavia... I will make few more tests but this seems to fix the problem.
-
10. Re: ClassLoader behaviour on remote clustering tests
clebert.suconic Apr 9, 2008 10:44 AM (in response to flavia.rainone)Flavia wrote:
I'm curious to know why we hadn't seen this error before.
Maybe an older version of Javassist wasn't using the loader.defineClass hack? -
11. Re: ClassLoader behaviour on remote clustering tests
clebert.suconic Apr 9, 2008 10:47 AM (in response to flavia.rainone)Anyway... something changed on the interaction with the classLoader, and that hit the bug.
I'm changing it to use the DelegateClassLoader as Adrian suggested and it worked. So we are fine now! -
12. Re: ClassLoader behaviour on remote clustering tests
flavia.rainone Apr 9, 2008 10:53 AM (in response to flavia.rainone)I'm changing it to use the DelegateClassLoader as Adrian suggested and it worked. So we are fine now!
Great news!Maybe an older version of Javassist wasn't using the loader.defineClass hack?
I dunno. I have no idea of what changed but, as you said, what matters is that the issue is fixed. -
13. Re: ClassLoader behaviour on remote clustering tests
clebert.suconic Apr 9, 2008 11:25 PM (in response to flavia.rainone)We will need an AOP release anyway.
When I changed build-messaging.xml to use the default aopc I got another ClassNotFoundException, but everything passed when I built aop from SVN and replaced thirdpary, as Flavia fixed another problem. -
14. Re: ClassLoader behaviour on remote clustering tests
flavia.rainone Apr 10, 2008 9:43 AM (in response to flavia.rainone)Ok,
I'll start the CR9 release proccess now.