We can't start saying to people "Drools only works if you remember to turn on some JVM setting". It'll smell bad, too fragile.<br><br>For now Class.forName stays, you'll need to find other work arounds.<br>
<br>Mrk<br><div class="gmail_quote">On Fri, Nov 18, 2011 at 5:27 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;">
There are two workarounds mentioned there and one of them is:<br>
<br>
1. setting an environment variable when starting VM:<br>
-Dsun.lang.ClassLoader.allowArraySyntax=true.<br>
<br>
Instead of using the Class.forName() method. That looks like something<br>
that we can add in a profile right? it's just a JVM configuration<br>
issue.<br>
<br>
This looks to be a problem only in JDK 6.<br>
If we are using Class.forName() in an OSGI environment that provides<br>
hooks for Class.forName() we will end up having troubles with the<br>
CompositeClassLoader.<br>
<br>
What do you think about that? I'm trying to decide and find out what<br>
are the most appropriate next steps.<br>
<br>
Cheers<br>
<div class="HOEnZb"><div class="h5"><br>
<br>
On Fri, Nov 18, 2011 at 2:15 PM, Mark Proctor <<a href="mailto:mproctor@codehaus.org">mproctor@codehaus.org</a>> wrote:<br>
> This is the jira that links to the java issue that explains why we can't use<br>
> loadClass, the bug is still active, so we have to keep Class.forName<br>
> <a href="https://issues.jboss.org/browse/JBRULES-1553" target="_blank">https://issues.jboss.org/browse/JBRULES-1553</a><br>
> <a href="http://bugs.sun.com/bugdatabase/view_bug.do;jsessionid=2a9a78e4393c5e678a2c80f90c1?bug_id=6434149" target="_blank">http://bugs.sun.com/bugdatabase/view_bug.do;jsessionid=2a9a78e4393c5e678a2c80f90c1?bug_id=6434149</a><br>
><br>
> Mark<br>
> On Thu, Nov 17, 2011 at 5:53 PM, Mauricio Salatino <<a href="mailto:salaboy@gmail.com">salaboy@gmail.com</a>><br>
> wrote:<br>
>><br>
>> Just a small update:<br>
>> If I compile core and compiler with tests I'm just getting the<br>
>> following failing tests in compiler:<br>
>> Failed tests:<br>
>><br>
>> testMonitorResourceChangeEvents(org.drools.agent.KnowledgeAgentDisposeTest)<br>
>> testDispose(org.drools.agent.KnowledgeAgentDisposeTest)<br>
>><br>
>> Tests in error:<br>
>><br>
>> testAccumulateMultipleFunctionsJava(org.drools.integrationtests.AccumulateTest)<br>
>><br>
>> testAccumulateMultipleFunctionsMVEL(org.drools.integrationtests.AccumulateTest)<br>
>> testAccumulateMinMax(org.drools.integrationtests.AccumulateTest)<br>
>> testAccumulateCE(org.drools.integrationtests.AccumulateTest)<br>
>><br>
>> I think that the knowledge agents problem is not related with the<br>
>> Class.forName() change, but all the failing test inside the<br>
>> AccumulateTest fails because the following line inside<br>
>> ClassFieldAccessorCache:<br>
>> 124: return this.classLoader.loadClass( className );<br>
>><br>
>> Debugging, I didn't find the reason of the following stack trace:<br>
>> org.drools.RuntimeDroolsException: Unable to resolve class<br>
>> '[Ljava.lang.Object;'<br>
>> at<br>
>> org.drools.base.ClassFieldAccessorCache.getClass(ClassFieldAccessorCache.java:126)<br>
>> at<br>
>> org.drools.base.ClassFieldAccessorCache.getClassObjectType(ClassFieldAccessorCache.java:48)<br>
>> at<br>
>> org.drools.base.ClassFieldAccessorStore.getClassObjectType(ClassFieldAccessorStore.java:285)<br>
>> at<br>
>> org.drools.base.ClassFieldAccessorStore.getClassObjectType(ClassFieldAccessorStore.java:271)<br>
>> at<br>
>> org.drools.rule.builder.PatternBuilder.build(PatternBuilder.java:291)<br>
>> at<br>
>> org.drools.rule.builder.PatternBuilder.build(PatternBuilder.java:130)<br>
>> at<br>
>> org.drools.rule.builder.GroupElementBuilder.build(GroupElementBuilder.java:65)<br>
>> at org.drools.rule.builder.RuleBuilder.build(RuleBuilder.java:80)<br>
>> at<br>
>> org.drools.compiler.PackageBuilder.addRule(PackageBuilder.java:2302)<br>
>> at<br>
>> org.drools.compiler.PackageBuilder.addPackage(PackageBuilder.java:823)<br>
>> at<br>
>> org.drools.compiler.PackageBuilder.addPackageFromDrl(PackageBuilder.java:405)<br>
>> at<br>
>> org.drools.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder.java:587)<br>
>> at<br>
>> org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:37)<br>
>> at<br>
>> org.drools.integrationtests.AccumulateTest.loadKnowledgeBase(AccumulateTest.java:111)<br>
>> at<br>
>> org.drools.integrationtests.AccumulateTest.execTestAccumulateMultipleFunctions(AccumulateTest.java:1656)<br>
>> at<br>
>> org.drools.integrationtests.AccumulateTest.testAccumulateMultipleFunctionsJava(AccumulateTest.java:940)<br>
>><br>
>> Because the community hudson is down I can't check if it's a local<br>
>> problem or a master one.<br>
>><br>
>> Cheers<br>
>><br>
>><br>
>><br>
>> On Wed, Nov 16, 2011 at 5:48 PM, Mauricio Salatino <<a href="mailto:salaboy@gmail.com">salaboy@gmail.com</a>><br>
>> wrote:<br>
>> > We really need to analyze the difference and understand what is<br>
>> > happening under the hood.. because if not strange things can happen.<br>
>> > I will run the tests locally to see if I see something wrong.<br>
>> ><br>
>> > Cheers<br>
>> ><br>
>> > On Wed, Nov 16, 2011 at 5:46 PM, Mark Proctor <<a href="mailto:mproctor@codehaus.org">mproctor@codehaus.org</a>><br>
>> > wrote:<br>
>> >> We original used classLoader.loadClass but then there was wierd bug<br>
>> >> with<br>
>> >> dynamic rules that wouldn't work, related to arrays. Switching to<br>
>> >> Class.forName avoided that bug. But I don't remember the exact details,<br>
>> >> it<br>
>> >> was several years ago now.<br>
>> >><br>
>> >> Mark<br>
>> >><br>
>> >> On Wed, Nov 16, 2011 at 5:50 PM, Mauricio Salatino <<a href="mailto:salaboy@gmail.com">salaboy@gmail.com</a>><br>
>> >> wrote:<br>
>> >>><br>
>> >>> 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<br>
>> >>><br>
>> >>> 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<br>
>> >>> 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<br>
>> >>><br>
>> >>> -> <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>><br>
>> >>> wrote:<br>
>> >>> ><br>
>> >>> > Lovely exception...<br>
>> >>> > Well, both my life and salaboy's depend on solving this issue...<br>
>> >>> > Mark<br>
>> >>> > and I<br>
>> >>> > were also considering to review the Composite ClassLoader at some<br>
>> >>> > point<br>
>> >>> > in<br>
>> >>> > the future, since it causes issues with (re)declared types in DRLs<br>
>> >>> > 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<br>
>> >>> > details?<br>
>> >>> > (version, any custom setting, etc...)<br>
>> >>> ><br>
>> >>> > --<br>
>> >>> > View this message in context:<br>
>> >>> ><br>
>> >>> > <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>
>> >>> _______________________________________________<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>
>> >><br>
>> >><br>
>> >> _______________________________________________<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>
>> >><br>
>> >><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>
>> --<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>
>> 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>
><br>
><br>
> _______________________________________________<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>
><br>
><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>
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>