[ 
https://issues.apache.org/jira/browse/CAMEL-5493?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13437587#comment-13437587
 ] 

Sergey Zhemzhitsky commented on CAMEL-5493:
-------------------------------------------

Hi Willem,

Thanks a lot for the workaround!

Seems, that it's a bug in the felix, as the following snippet in the 
GroovyExpression#evaluate(Exchange, Class)

{code}
System.out.printf("Script type: %s@%s%n", scriptType.getName(), 
System.identityHashCode(scriptType));
Object o = scriptType.newInstance();
System.out.printf("Script instance: %s@%s%n", o.getClass().getName(), 
System.identityHashCode(o));
System.out.printf("Script instance superclass: %s@%s%n",
    o.getClass().getSuperclass().getName(), 
System.identityHashCode(o.getClass().getSuperclass()));
System.out.printf("Script.class: %s@%s%n", Script.class.getName(), 
System.identityHashCode(Script.class));

System.out.printf("Script.type classloader: %s@%s%n",
    scriptType.getClassLoader().getClass().getName(), 
System.identityHashCode(scriptType.getClassLoader()));
System.out.printf("Script.instance classloader: %s@%s%n",
    o.getClass().getClassLoader().getClass().getName(), 
System.identityHashCode(o.getClass().getClassLoader()));
System.out.printf("Script.class classloader: %s@%s%n",
    Script.class.getClassLoader().getClass().getName(), 
System.identityHashCode(Script.class.getClassLoader()));
{code}

outputs the following for the passed test

{code}
Script type: script13454122538541505912543@999191884
Script instance: script13454122538541505912543@681806680
Script instance superclass: groovy.lang.Script@765505133
Script.class: groovy.lang.Script@765505133
Script.type classloader: groovy.lang.GroovyClassLoader$InnerLoader@1915502523
Script.instance classloader: 
groovy.lang.GroovyClassLoader$InnerLoader@1915502523
{code}

and outputs the following for the failed test

{code}
Script type: script13454122770291505912543@1670892698
Script instance: script13454122770291505912543@1556003292
Script instance superclass: groovy.lang.Script@798159189
Script.class: groovy.lang.Script@1292687619
Script.type classloader: groovy.lang.GroovyClassLoader$InnerLoader@1694302424
Script.instance classloader: 
groovy.lang.GroovyClassLoader$InnerLoader@1694302424
{code}

Script.class and Script instance superclass must be the same classes, but in 
the case of lazy bundle activation and felix framework they are different.
                
> GroovyLanguage should use applicationContextClassLoader of the corresponding 
> CamelContext instead of current thread's contextClassLoader
> ----------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-5493
>                 URL: https://issues.apache.org/jira/browse/CAMEL-5493
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-groovy
>    Affects Versions: 2.10.0
>            Reporter: Sergey Zhemzhitsky
>            Assignee: Willem Jiang
>         Attachments: camel-groovy-failure.zip
>
>
> Stacktrace:
> {code}
> Caused by: java.lang.ClassCastException: script13444652627211505912543 cannot 
> be cast to groovy.lang.Script
>         at 
> org.apache.camel.language.groovy.GroovyExpression.evaluate(GroovyExpression.java:52)
>         at 
> org.apache.camel.component.language.LanguageProducer.process(LanguageProducer.java:80)
>         at 
> org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverte
> rHelper.java:61)
>         at 
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
>         at 
> org.apache.camel.processor.SendProcessor$2.doInAsyncProducer(SendProcessor.java:120)
>         at 
> org.apache.camel.impl.ProducerCache.doInAsyncProducer(ProducerCache.java:292)
>         at 
> org.apache.camel.processor.SendProcessor.process(SendProcessor.java:115)
>         at 
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to