[jboss-jira] [JBoss JIRA] Commented: (JBRULES-2253) ClassNotFound when ASM optimizer kicks in in MVEL consequence
Vladimir Schafer (JIRA)
jira-events at lists.jboss.org
Sat Apr 17 06:02:26 EDT 2010
[ https://jira.jboss.org/jira/browse/JBRULES-2253?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12526293#action_12526293 ]
Vladimir Schafer commented on JBRULES-2253:
-------------------------------------------
In my case I use a serialized KnowledgeBase loaded using ClassLoader A together with all domain specific classes reachable by the same ClassLoader. The Drools, MVEL and ASM libraries are loaded by a parent of A - let's call it ClassLoader B. During execution of my rules using MVEL dialect the org.mvel2.optimizers.dynamic.DynamicGetAccessor decides to optimize value loading after 50 executions. This results in generation of a new ASMAccessorImpl class.
The problem is that the ClassLoader of the generated ASMAccessorImpl class is not the child A as expected, but the parent B instead. As a consequence during execution of the accessor it attempts to load a domain class using ClassLoader B where it can't be reached and the call thus results in a NoClassDefFoundError exception:
Caused by: java.lang.NoClassDefFoundError: fi/panoramapartners/igm/internal/reporting/entity/log/LogAccessRole
at ASMAccessorImpl_272841721271487376740.getValue(Unknown Source)
at org.mvel2.optimizers.dynamic.DynamicGetAccessor.getValue(DynamicGetAccessor.java:66)
at org.mvel2.ast.ASTNode.getReducedValueAccelerated(ASTNode.java:99)
at org.mvel2.ast.BinaryOperation.getReducedValueAccelerated(BinaryOperation.java:102)
at org.mvel2.MVELRuntime.execute(MVELRuntime.java:85)
at org.mvel2.compiler.CompiledExpression.getValue(CompiledExpression.java:104)
at org.mvel2.MVEL.executeExpression(MVEL.java:978)
Reason for this problem are some undocumented changes in class org.mvel2.optimizers.dynamic.DynamicClassLoader added in revision 2360 (titled "parser fixes"), which change the way of generating classes for Sun JVMs. Specifically:
if (sunJVM) {
return ((Unsafe) sunUnsafe).defineClass(className, b, start, end);
}
else {
return super.defineClass(className, b, start, end);
}
After removing the SunJVM condition the defining ClassLoader for the generated class works as expected. I'm using Sun JDK 1.6b18 with GlassFish. The original MVEL code without the fix works well on Weblogic with JDK 1.6b5 though.
> ClassNotFound when ASM optimizer kicks in in MVEL consequence
> -------------------------------------------------------------
>
> Key: JBRULES-2253
> URL: https://jira.jboss.org/jira/browse/JBRULES-2253
> Project: Drools
> Issue Type: Bug
> Security Level: Public(Everyone can see)
> Components: drools-core
> Affects Versions: 5.0.1.FINAL
> Reporter: Michael Neale
> Assignee: Edson Tirelli
> Priority: Critical
> Fix For: 5.1.0.M2
>
> Attachments: repository_export_mic.zip
>
>
> (ok if the subject is really confusing, perhaps this bug isn't for you).
> In chasing down JBRULES-2234 I found this. Instructions (apologies for relying on Guvnor to reproduce):
> To reproduce is not
> easy, but here are some instructions:
> * Run latest Guvnor (if you are able to, if not, then the rest is moot !).
> * Import the attached repo (unzip it first).
> * browse to KnowledgeBases/org/acme/insurance/pricing/
> - press "build package"
> * shut it down, restart (flushes caches etc...)
> Then:
> * browse to KnowledgeBases/org/acme/insurance/pricing/Test Scenarios
> * open PolicyQuotePackageTest
> * run it:
> Now you should see an exception like this:
> Caused by: java.lang.NoClassDefFoundError: org/acme/insurance/Policy
> at ASMAccessorImpl_62408281250565694450.setValue(Unknown Source)
> at org.mvel2.optimizers.dynamic.DynamicSetAccessor.setValue(DynamicSetAccessor.java:74)
> at org.mvel2.compiler.CompiledAccExpression.setValue(CompiledAccExpression.java:47)
> at org.mvel2.MVEL.executeSetExpression(MVEL.java:962)
> at org.mvel2.ast.WithNode$ParmValuePair.eval(WithNode.java:242)
> at org.mvel2.ast.WithNode.getReducedValueAccelerated(WithNode.java:67)
> at org.mvel2.ast.InterceptorWrapper.getReducedValueAccelerated(InterceptorWrapper.java:38)
> at org.mvel2.MVELRuntime.execute(MVELRuntime.java:85)
> at org.mvel2.compiler.CompiledExpression.getValue(CompiledExpression.java:104)
> at org.mvel2.MVEL.executeExpression(MVEL.java:995)
> at org.drools.base.mvel.MVELConsequence.evaluate(MVELConsequence.java:91)
> at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:966)
> This is due to it loading a previously serialized version of the KB.
> If it was to run off a freshly compiled one, its all fine. Also, if I
> tell MVEL to NOT use ASM optimizer, it works fine (using reflection).
> So clearly the stuff is available to the classpath in the right
> places... its only to do with ASM in mvel post deserialization. (and
> for that to happen, MVEL has to execute the compiled expression enough
> to kick in the JIT).
> MVELCompilationUnit in drools is worth examining too... still not sure where the problem lies.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the jboss-jira
mailing list