Based on more tests and reading some articles about OSGI we (Professor dotty and I) have found that<div>the composite class loader from drools is using Class.forName that is being intercepted by the equinox OSGI container -></div>
<div><span class="Apple-style-span" style="border-collapse: collapse; color: rgb(80, 0, 80); font-family: arial, sans-serif; font-size: 13px; ">at org.eclipse.core.runtime.internal.adaptor.ContextFinder.loadClass(ContextFinder.java:124)</span></div>
<div><span class="Apple-style-span" style="border-collapse: collapse; color: rgb(80, 0, 80); font-family: arial, sans-serif; font-size: 13px; "><br></span></div><div><span class="Apple-style-span" style="border-collapse: collapse; color: rgb(80, 0, 80); font-family: arial, sans-serif; font-size: 13px; ">It looks like both are trying to load the same class definition and the JVM throws the </span><span class="Apple-style-span" style="border-collapse: collapse; color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 13px; ">ClassCircularityError.</span></div>
<div><span class="Apple-style-span" style="border-collapse: collapse; color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 13px; "><br></span></div><div><font class="Apple-style-span" color="#222222" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse;">For my very basic example changing the CompositeClassLoader implementation to use:</span></font></div>
<div><span class="Apple-style-span" style="border-collapse: collapse; color: rgb(34, 34, 34); font-family: arial, sans-serif; "><div> </div><div> cls = classLoader.loadClass(name);</div></span></div>
<div><span class="Apple-style-span" style="border-collapse: collapse; color: rgb(34, 34, 34); font-family: arial, sans-serif; "> </span></div><div><span class="Apple-style-span" style="border-collapse: collapse; color: rgb(34, 34, 34); font-family: arial, sans-serif; ">instead of:</span></div>
<div><span class="Apple-style-span" style="border-collapse: collapse; color: rgb(34, 34, 34); font-family: arial, sans-serif; "><div> cls = Class.forName( name,</div><div> resolve,</div>
<div> classLoader );</div></span></div><div><br></div><div>Fix the problems. But I'm not sure if that will work for all the other cases.</div><div>Looking the usages of Class.forName inside compiler, core and api I found that it is being used 39 times, which worries me.</div>
<div>I'm not planning to change all of them without being sure that is the right way to go. I will continue reading and testing to see if changing the way of loading the classes is the only alternative.</div><div><br>
</div><div>Some notes about the difference between loadClass and forName:</div><div>
                
        
        
                <div class="section">
                        <div class="section">
                                <div class="layoutArea">
                                        <div class="column">
                                                <p></p><ul><li><span class="Apple-style-span" style="font-family: 'times new roman', serif; ">Classloader.loadClass() caches the loaded class
object and returns always the same class object</span></li><ul><li><span class="Apple-style-span" style="color: rgb(37, 85, 89); font-family: 'times new roman', serif; ">This is done by the defining class loader</span></li>
<li><span class="Apple-style-span" style="font-family: 'times new roman', serif; ">This ensures that each classloader loads the same class only </span><span class="Apple-style-span" style="font-family: 'times new roman', serif; ">once</span></li>
</ul><li><span class="Apple-style-span" style="font-family: 'times new roman', serif; ">Class.forName() calls the normal classloader
hierarchy to load the class (same happens as above)</span></li><ul><li><span class="Apple-style-span" style="color: rgb(37, 85, 89); font-family: 'times new roman', serif; ">But caches the class object within the initiating
class loader</span></li><li><span class="Apple-style-span" style="font-family: 'times new roman', serif; ">In standard cases no problem but can be tricky in dynamic
environments </span></li></ul></ul><p></p></div></div></div>
                </div></div><div><br></div><div>Source -> <a href="http://www.martinlippert.org/events/WJAX2008-ClassloadingTypeVisibilityOSGi.pdf">http://www.martinlippert.org/events/WJAX2008-ClassloadingTypeVisibilityOSGi.pdf</a></div>
<div><br><div class="gmail_quote">On Tue, Nov 15, 2011 at 4:04 PM, Davide Sottara <span dir="ltr"><<a href="mailto:dsotty@gmail.com">dsotty@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
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>
<span class="HOEnZb"><font color="#888888"><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>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <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><div>
- 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 -</div>
<br>
</div>