We original used classLoader.loadClass but then there was wierd bug with dynamic rules that wouldn't work, related to arrays. Switching to Class.forName avoided that bug. But I don't remember the exact details, it was several years ago now.<br>
<br>Mark<br><br><div class="gmail_quote">On Wed, Nov 16, 2011 at 5:50 PM, Mauricio Salatino <span dir="ltr"><<a href="mailto:salaboy@gmail.com">salaboy@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="HOEnZb"><div class="h5">Based on more tests and reading some articles about OSGI we (Professor<br>
dotty and I) have found that<br>
the composite class loader from drools is using Class.forName that is<br>
being intercepted by the equinox OSGI container -><br>
at org.eclipse.core.runtime.internal.adaptor.ContextFinder.loadClass(ContextFinder.java:124)<br>
It looks like both are trying to load the same class definition and<br>
the JVM throws the ClassCircularityError.<br>
For my very basic example changing the CompositeClassLoader<br>
implementation to use:<br>
<br>
cls = classLoader.loadClass(name);<br>
<br>
instead of:<br>
cls = Class.forName( name,<br>
resolve,<br>
classLoader );<br>
Fix the problems. But I'm not sure if that will work for all the other cases.<br>
Looking the usages of Class.forName inside compiler, core and api I<br>
found that it is being used 39 times, which worries me.<br>
I'm not planning to change all of them without being sure that is the<br>
right way to go. I will continue reading and testing to see if<br>
changing the way of loading the classes is the only alternative.<br>
Some notes about the difference between loadClass and forName:<br>
<br>
Classloader.loadClass() caches the loaded class object and returns<br>
always the same class object<br>
<br>
This is done by the defining class loader<br>
This ensures that each classloader loads the same class only once<br>
<br>
Class.forName() calls the normal classloader hierarchy to load the<br>
class (same happens as above)<br>
<br>
But caches the class object within the initiating class loader<br>
In standard cases no problem but can be tricky in dynamic environments<br>
<br>
Source -> <a href="http://www.martinlippert.org/events/WJAX2008-ClassloadingTypeVisibilityOSGi.pdf" target="_blank">http://www.martinlippert.org/events/WJAX2008-ClassloadingTypeVisibilityOSGi.pdf</a><br>
On Tue, Nov 15, 2011 at 4:04 PM, Davide Sottara <<a href="mailto:dsotty@gmail.com">dsotty@gmail.com</a>> wrote:<br>
><br>
> Lovely exception...<br>
> Well, both my life and salaboy's depend on solving this issue... Mark and I<br>
> were also considering to review the Composite ClassLoader at some point in<br>
> the future, since it causes issues with (re)declared types in DRLs loaded at<br>
> runtime. Looks like we'll have to catch two birds with one stone :)<br>
> Salaboy, can you share the simple service and the WSO2 config details?<br>
> (version, any custom setting, etc...)<br>
><br>
> --<br>
> View this message in context: <a href="http://drools.46999.n3.nabble.com/rules-users-class-loading-problems-with-5-3-0-Final-and-5-4-0-SNAPSHOT-tp3509949p3510640.html" target="_blank">http://drools.46999.n3.nabble.com/rules-users-class-loading-problems-with-5-3-0-Final-and-5-4-0-SNAPSHOT-tp3509949p3510640.html</a><br>
> Sent from the Drools: User forum mailing list archive at Nabble.com.<br>
> _______________________________________________<br>
> rules-users mailing list<br>
> <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
> <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
<br>
<br>
<br>
--<br>
- CTO @ <a href="http://www.plugtree.com" target="_blank">http://www.plugtree.com</a><br>
- MyJourney @ <a href="http://salaboy.wordpress.com" target="_blank">http://salaboy.wordpress.com</a><br>
- Co-Founder @ <a href="http://www.jugargentina.org" target="_blank">http://www.jugargentina.org</a><br>
- Co-Founder @ <a href="http://www.jbug.com.ar" target="_blank">http://www.jbug.com.ar</a><br>
<br>
- Salatino "Salaboy" Mauricio -<br>
<br>
<br>
<br>
--<br>
- CTO @ <a href="http://www.plugtree.com" target="_blank">http://www.plugtree.com</a><br>
- MyJourney @ <a href="http://salaboy.wordpress.com" target="_blank">http://salaboy.wordpress.com</a><br>
- Co-Founder @ <a href="http://www.jugargentina.org" target="_blank">http://www.jugargentina.org</a><br>
- Co-Founder @ <a href="http://www.jbug.com.ar" target="_blank">http://www.jbug.com.ar</a><br>
<br>
- Salatino "Salaboy" Mauricio -<br>
<br>
</div></div><div class="HOEnZb"><div class="h5">_______________________________________________<br>
rules-dev mailing list<br>
<a href="mailto:rules-dev@lists.jboss.org">rules-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-dev</a><br>
</div></div></blockquote></div><br>