-
1. Re: Module classloader issue
sfcoy Apr 13, 2013 10:19 PM (in response to marcelomrwin)1 of 1 people found this helpfulUnless the groovy api provides a mechanism for passing it a classloader I don't believe that you can do that.
You will need to move the groovy jar into the WEB-INF/lib directory, which shares the same classloader as WEB-INF/classes.
-
2. Re: Module classloader issue
marcelomrwin Apr 14, 2013 9:08 AM (in response to marcelomrwin)That's exactly what I think. Clearly the new classloader model of jboss bring to us some of benefit, on the other hand some problems too. Every third party jar what we want integrate with our application we need to think if they support control over classloader or we have to put then inside our web-inf/lib. In my case, I have modified the groovy-all-2.0.4.jar, more especifically the class org.codehaus.groovy.runtime.callsite.CallSiteClassLoader, where I changed the method "protected synchronized Class loadClass(String name, boolean resolve)" and solve my problem. follows the complete method:
protected synchronized Class loadClass(String name, boolean resolve) throws ClassNotFoundException { if (KNOWN_CLASSES.contains(name)) return getClass().getClassLoader().loadClass(name); else { try { return super.loadClass(name, resolve); } catch (ClassNotFoundException e) { try { return getClass().getClassLoader().loadClass(name); } catch (ClassNotFoundException cnfe) { return Thread.currentThread().getContextClassLoader() .loadClass(name); } } } }
-
3. Re: Module classloader issue
sfcoy Apr 14, 2013 9:03 PM (in response to marcelomrwin)That's great!
Please consider submitting a patch to the groovy project.
You would have had the same problem if groovy.jar was added as a utility library to an EAR module (on any appserver platform), so your solution is not necessarily JBoss specific.