<div><br></div>    Hi Paul,<div><br></div><div>    Your analysis is correct. The problem is that these configurations in MVEL are made using static properties and so they affect all uses of MVEL in a single classloading hierarchy. Unfortunately, I don&#39;t think there is anything you can do right now, other than open a JIRA in MVEL to help convince Mike to make all configurations non-static in MVEL:</div>
<div><br></div><div><a href="http://jira.codehaus.org/browse/MVEL">http://jira.codehaus.org/browse/MVEL</a></div><div><br></div><div>    Edson</div><div>    <br><div class="gmail_quote">2010/7/21 Paul Edwards <span dir="ltr">&lt;<a href="mailto:Paul.Edwards@hyro.com">Paul.Edwards@hyro.com</a>&gt;</span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Hi guys,<br>
<br>
I have an issue which involves smooks, drools and mvel.<br>
<br>
Quick explanation, the unit test is just a smooks run. Nothing complicated. The test passes happily. It contains an expression that involves an MVEL &quot;IF&quot; statement.<br>
<br>
Now if I add a drools startup (I&#39;m not using drools in the test, I&#39;m just initialising it), the unit test now fails on the &quot;IF&quot; statement. The exception received is:<br>
<br>
org.milyn.cdr.SmooksConfigurationException: Error invoking @Initialize method &#39;initialize&#39; on class &#39;org.milyn.javabean.BeanInstancePopulator&#39;.<br>
        at org.milyn.cdr.annotation.Configurator.invoke(Configurator.java:457)<br>
        at org.milyn.cdr.annotation.Configurator.initialise(Configurator.java:439)<br>
        at org.milyn.cdr.annotation.Configurator.configure(Configurator.java:91)<br>
        at org.milyn.cdr.annotation.Configurator.configure(Configurator.java:66)<br>
        at org.milyn.delivery.JavaContentHandlerFactory.create(JavaContentHandlerFactory.java:63)<br>
        at org.milyn.delivery.ContentDeliveryConfigBuilder$ContentHandlerExtractionStrategy.addCDU(ContentDeliveryConfigBuilder.java:623)<br>
        at org.milyn.delivery.ContentDeliveryConfigBuilder$ContentHandlerExtractionStrategy.applyCDUStrategy(ContentDeliveryConfigBuilder.java:548)<br>
        at org.milyn.delivery.ContentDeliveryConfigBuilder$ContentHandlerExtractionStrategy.applyStrategy(ContentDeliveryConfigBuilder.java:536)<br>
        at org.milyn.delivery.ContentDeliveryConfigBuilder$SmooksResourceConfigurationTableIterator.iterate(ContentDeliveryConfigBuilder.java:711)<br>
        at org.milyn.delivery.ContentDeliveryConfigBuilder$SmooksResourceConfigurationTableIterator.access$300(ContentDeliveryConfigBuilder.java:690)<br>
        at org.milyn.delivery.ContentDeliveryConfigBuilder.extractContentHandlers(ContentDeliveryConfigBuilder.java:484)<br>
        at org.milyn.delivery.ContentDeliveryConfigBuilder.load(ContentDeliveryConfigBuilder.java:349)<br>
        at org.milyn.delivery.ContentDeliveryConfigBuilder.getConfig(ContentDeliveryConfigBuilder.java:146)<br>
        at org.milyn.container.standalone.StandaloneExecutionContext.&lt;init&gt;(StandaloneExecutionContext.java:91)<br>
        at org.milyn.container.standalone.StandaloneExecutionContext.&lt;init&gt;(StandaloneExecutionContext.java:65)<br>
        at org.milyn.Smooks.createExecutionContext(Smooks.java:383)<br>
        at org.milyn.Smooks.createExecutionContext(Smooks.java:346)<br>
        at com.hyro.telstrapoc.smooks.SmooksTransformTest.runSmooksTransform(SmooksTransformTest.java:215)<br>
        at com.hyro.telstrapoc.smooks.SmooksTransformTest.testSmooks(SmooksTransformTest.java:139)<br>
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)<br>
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)<br>
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)<br>
        at java.lang.reflect.Method.invoke(Method.java:597)<br>
        at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)<br>
        at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)<br>
        at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)<br>
        at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)<br>
        at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)<br>
        at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)<br>
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:73)<br>
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:46)<br>
        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:180)<br>
        at org.junit.runners.ParentRunner.access$000(ParentRunner.java:41)<br>
        at org.junit.runners.ParentRunner$1.evaluate(ParentRunner.java:173)<br>
        at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)<br>
        at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)<br>
        at org.junit.runners.ParentRunner.run(ParentRunner.java:220)<br>
        at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)<br>
        at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)<br>
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)<br>
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)<br>
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)<br>
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)<br>
Caused by: [Error: was expecting type: java.lang.Object; but found type: null]<br>
[Near : {... }<br>
                els ....}]<br>
             ^<br>
[Line: 3, Column: 16]<br>
        at org.mvel2.util.CompilerTools.expectType(CompilerTools.java:355)<br>
        at org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer._getAccessor(ReflectiveAccessorOptimizer.java:1052)<br>
        at org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.optimizeCollection(ReflectiveAccessorOptimizer.java:1079)<br>
        at org.mvel2.ast.InlineCollectionNode.&lt;init&gt;(InlineCollectionNode.java:50)<br>
        at org.mvel2.compiler.AbstractParser.nextToken(AbstractParser.java:1173)<br>
        at org.mvel2.compiler.ExpressionCompiler._compile(ExpressionCompiler.java:118)<br>
        at org.mvel2.compiler.ExpressionCompiler.compile(ExpressionCompiler.java:65)<br>
        at org.mvel2.MVEL.compileExpression(MVEL.java:886)<br>
        at org.mvel2.MVEL.compileExpression(MVEL.java:891)<br>
        at org.mvel2.MVEL.compileExpression(MVEL.java:797)<br>
        at org.milyn.expression.MVELExpressionEvaluator.setExpression(MVELExpressionEvaluator.java:55)<br>
        at org.milyn.javabean.BeanInstancePopulator.initialize(BeanInstancePopulator.java:235)<br>
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)<br>
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)<br>
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)<br>
        at java.lang.reflect.Method.invoke(Method.java:597)<br>
        at org.milyn.cdr.annotation.Configurator.invoke(Configurator.java:453)<br>
        ... 42 more<br>
<br>
<br>
If I remove the 3 lines initialising drools, it all passes again. I suspect that the MVEL engine is a singleton, and both drools and smooks are using the same instance. I believe drools is setting MVEL to disallow &quot;IF&quot; statements on the RHS of a rule. (see: <a href="http://drools-java-rules-engine.46999.n3.nabble.com/Trivial-rule-with-condition-in-RHS-won-t-compile-help-please-td67458.html" target="_blank">http://drools-java-rules-engine.46999.n3.nabble.com/Trivial-rule-with-condition-in-RHS-won-t-compile-help-please-td67458.html</a>) I don&#39;t understand why MVEL thinks that my smooks expression is a RHS of a rule....<br>

<br>
<br>
Heres the unit test:<br>
@Test<br>
    public void testSmooks2() throws Exception {<br>
<br>
        String input =<br>
        &quot;&lt;ns5:user partyAdminRoles=\&quot;\&quot; lastName=\&quot;Edwards\&quot; firstName=\&quot;Paul\&quot; primary=\&quot;false\&quot; userID=\&quot;pedwards\&quot; otpTokenRemainingUses=\&quot;0\&quot; registrationCodeRemainingUses=\&quot;0\&quot; enabled=\&quot;true\&quot; customIntAttr1=\&quot;0\&quot; xmlns:ns2=\&quot;urn:oasis:names:tc:SPML:2:0:reference\&quot; xmlns=\&quot;urn:oasis:names:tc:SPML:2:0\&quot; xmlns:ns4=\&quot;urn:oasis:names:tc:SPML:2:0:password\&quot; xmlns:ns3=\&quot;urn:oasis:names:tc:SPML:2:0:search\&quot; xmlns:ns5=\&quot;<a href="http://hyro.com/da/objectmodel\" target="_blank">http://hyro.com/da/objectmodel\</a>&quot; xmlns:ns6=\&quot;<a href="http://www.sifinfo.org/au/infrastructure/2.x\" target="_blank">http://www.sifinfo.org/au/infrastructure/2.x\</a>&quot; xmlns:ns7=\&quot;urn:oasis:names:tc:SPML:2:0:batch\&quot;&gt;\n&quot; +<br>

        &quot;    &lt;ns5:emailAddresses emailAddress=\&quot;<a href="mailto:pedwards@frazzle.co.nz">pedwards@frazzle.co.nz</a>\&quot; primary=\&quot;true\&quot; type=\&quot;Personal\&quot; modificationMode=\&quot;0\&quot;/&gt;\n&quot; +<br>

        &quot;    &lt;ns5:emailAddresses emailAddress=\&quot;<a href="mailto:grumpy@frazzle.co.nz">grumpy@frazzle.co.nz</a>\&quot; primary=\&quot;false\&quot; type=\&quot;Personal\&quot; modificationMode=\&quot;0\&quot;/&gt;\n&quot; +<br>

        &quot;    &lt;ns5:authzRoleSubscriptions status=\&quot;Active\&quot; primary=\&quot;false\&quot; singlePasswordOptOut=\&quot;false\&quot; reprovision=\&quot;false\&quot; customBoolAttr5=\&quot;false\&quot; customBoolAttr4=\&quot;false\&quot; customBoolAttr3=\&quot;false\&quot; customBoolAttr2=\&quot;false\&quot; customBoolAttr1=\&quot;false\&quot; customIntAttr5=\&quot;0\&quot; customIntAttr4=\&quot;0\&quot; customIntAttr3=\&quot;0\&quot; customIntAttr2=\&quot;0\&quot; customIntAttr1=\&quot;0\&quot;&gt;\n&quot; +<br>

        &quot;        &lt;ns5:role roleName=\&quot;Account\&quot;&gt;\n&quot; +<br>
        &quot;            &lt;ns5:entitlement entitlementID=\&quot;Open LDAP Account\&quot; type=\&quot;Account\&quot;/&gt;\n&quot; +<br>
        &quot;        &lt;/ns5:role&gt;\n&quot; +<br>
        &quot;    &lt;/ns5:authzRoleSubscriptions&gt;\n&quot; +<br>
        &quot;    &lt;ns5:auxEntities/&gt;\n&quot; +<br>
        &quot;&lt;/ns5:user&gt;\n&quot;;<br>
<br>
        UserType inUser = null;<br>
        Unmarshaller unmarshaller = null;<br>
<br>
        try {<br>
            log.debug(&quot;Unmarshalling: &quot; + input);<br>
            unmarshaller = (Unmarshaller) SpmlConstants.unmarshallerPool.borrowObject();<br>
            inUser = ((JAXBElement&lt;UserType&gt;) unmarshaller.unmarshal(new StringReader(input))).getValue();<br>
        } catch (JAXBException e) {<br>
            log.error(&quot;Exception while trying to unmarshall input daSpmlString: &quot; + e.getMessage());<br>
            e.printStackTrace();<br>
            throw e;<br>
        } catch (Exception e) {<br>
            log.error(&quot;Exception while trying to unmarshall input daSpmlString: &quot; + e.getMessage());<br>
            e.printStackTrace();<br>
            throw e;<br>
        } finally {<br>
            SpmlConstants.unmarshallerPool.returnObject(unmarshaller);<br>
        }<br>
<br>
        log.debug(&quot;Unmarshalled: &quot; + inUser.getUserID());<br>
<br>
        Properties parsed = runSmooksTransform(inUser);<br>
        assertNotNull(parsed);<br>
<br>
<br>
        for(Iterator&lt;Object&gt; i = parsed.keySet().iterator(); i.hasNext();) {<br>
            Object key = i.next();<br>
            Object value = parsed.get(key);<br>
            System.out.println(&quot;Key: &quot; + key + &quot; value: &quot; + value);<br>
        }<br>
<br>
    }<br>
<br>
Heres the smooks file:<br>
<br>
&lt;?xml version=&quot;1.0&quot;?&gt;<br>
&lt;smooks-resource-list xmlns=&quot;<a href="http://www.milyn.org/xsd/smooks-1.1.xsd" target="_blank">http://www.milyn.org/xsd/smooks-1.1.xsd</a>&quot;<br>
                      xmlns:core=&quot;<a href="http://www.milyn.org/xsd/smooks/smooks-core-1.3.xsd" target="_blank">http://www.milyn.org/xsd/smooks/smooks-core-1.3.xsd</a>&quot;<br>
                      xmlns:jb=&quot;<a href="http://www.milyn.org/xsd/smooks/javabean-1.3.xsd" target="_blank">http://www.milyn.org/xsd/smooks/javabean-1.3.xsd</a>&quot;&gt;<br>
<br>
    &lt;!-- NOTE NOTE NOTE --&gt;<br>
    &lt;!-- This is purely to map user or person props to the LDAP name. Anything that is handled --&gt;<br>
    &lt;!-- explicitly (like firstname or lastname) does not get mapped --&gt;<br>
<br>
    &lt;jb:bean beanId=&quot;UserOrPerson&quot; class=&quot;java.util.Properties&quot; createOnElement=&quot;com.hyro.spmlservice.generated.objectmodel.PersonType&quot;&gt;<br>
<br>
        &lt;jb:value property=&quot;employeeNumber&quot; decoder=&quot;String&quot; data=&quot;personID&quot; /&gt;<br>
        &lt;jb:value property=&quot;mobile&quot; decoder=&quot;String&quot; data=&quot;mobileTel&quot; /&gt;<br>
        &lt;jb:value property=&quot;facsimileTelephoneNumber&quot; decoder=&quot;String&quot; data=&quot;workFax&quot; /&gt;<br>
        &lt;jb:value property=&quot;telephoneNumber&quot; decoder=&quot;String&quot; data=&quot;workTel&quot; /&gt;<br>
        &lt;jb:value property=&quot;description&quot; decoder=&quot;String&quot; data=&quot;title&quot; /&gt;<br>
        &lt;jb:value property=&quot;l&quot; decoder=&quot;String&quot; data=&quot;customAttr27&quot; /&gt;<br>
        &lt;jb:value property=&quot;physicalDeliveryOfficeName&quot; decoder=&quot;String&quot; data=&quot;customAttr8&quot; /&gt;<br>
        &lt;jb:value property=&quot;postalCode&quot; decoder=&quot;String&quot; data=&quot;customAttr7&quot; /&gt;<br>
<br>
    &lt;/jb:bean&gt;<br>
<br>
    &lt;jb:bean beanId=&quot;UserOrPerson&quot; class=&quot;java.util.Properties&quot; createOnElement=&quot;com.hyro.spmlservice.generated.objectmodel.UserType&quot;&gt;<br>
        &lt;jb:value property=&quot;firstName&quot; decoder=&quot;String&quot; data=&quot;firstName&quot; /&gt;<br>
        &lt;jb:value property=&quot;lastName&quot; decoder=&quot;String&quot; data=&quot;lastName&quot; /&gt;<br>
        &lt;jb:value property=&quot;user&quot; decoder=&quot;String&quot; data=&quot;userID&quot; /&gt;<br>
<br>
        &lt;jb:value property=&quot;displayName&quot; decoder=&quot;String&quot; data=&quot;customAttr4&quot; /&gt;<br>
        &lt;jb:value property=&quot;postalCode&quot; decoder=&quot;String&quot; data=&quot;customAttr2&quot; /&gt;<br>
<br>
        &lt;jb:expression property=&quot;mail&quot; execOnElement=&quot;emailAddresses&quot;&gt;<br>
<br>
              if(1 == 2) {<br>
                return emailAddresses[0].emailAddress;<br>
              }<br>
                else {<br>
                return &quot;NOT FOUND&quot;;<br>
              }<br>
        &lt;/jb:expression&gt;<br>
<br>
<br>
    &lt;/jb:bean&gt;<br>
<br>
    &lt;jb:bean beanId=&quot;emailAddresses&quot; class=&quot;java.util.ArrayList&quot; createOnElement=&quot;emailAddresses&quot;&gt;<br>
        &lt;jb:wiring beanIdRef=&quot;emailAddressType&quot; /&gt;<br>
    &lt;/jb:bean&gt;<br>
<br>
    &lt;jb:bean beanId=&quot;emailAddressType&quot; class=&quot;com.hyro.spmlservice.generated.objectmodel.EmailAddressType&quot; createOnElement=&quot;com.hyro.spmlservice.generated.objectmodel.EmailAddressType&quot;&gt;<br>

        &lt;jb:value property=&quot;modificationMode&quot; decoder=&quot;Short&quot; data=&quot;modificationMode&quot; /&gt;<br>
        &lt;jb:value property=&quot;emailAddress&quot; decoder=&quot;String&quot; data=&quot;emailAddress&quot; /&gt;<br>
        &lt;jb:value property=&quot;type&quot; decoder=&quot;String&quot; data=&quot;type&quot; /&gt;<br>
        &lt;jb:value property=&quot;primary&quot; decoder=&quot;Boolean&quot; data=&quot;primary&quot; /&gt;<br>
    &lt;/jb:bean&gt;<br>
<br>
<br>
&lt;/smooks-resource-list&gt;<br>
<br>
<br>
Any Ideas? I&#39;ve wasted 3 days getting to this point....<br>
<font color="#888888">--<br>
Paul Edwards<br>
<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></blockquote></div><br><br clear="all"><br>-- <br>  Edson Tirelli<br>  JBoss Drools Core Development<br>  JBoss by Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a><br>
</div>