Freeman, Here is a sample project. It is really a basic OSGI-based project with only 2 files : pom.xml and camel-config.xml Can I make it work with ServiceMix 4.3 or do have I have to wait for the release of 4.4 ?
Thanks, Regards, metatech On 1 September 2011 14:54, Freeman-2 [via ServiceMix] <[email protected]> wrote: > Hi, > > This generally means > com.sun.script.javascript.RhinoScriptEngineFactory and > ScriptEngineFactory are loaded by different classloader. > You need elaborate how you package your customer bundle, such as how > is the OSGi metadata header looks like? you're using JBI package or > OSGi package? Did you embed jar into your bundle? A test project(with > pom.xml which we can build and deploy) would be more helpful here. > > Freeman > On 2011-9-1, at 下午8:39, metatech wrote: > >> Hello, >> >> With ServiceMix 4.3, I am trying to use a JavaScript expression in a >> Camel >> route as described here : >> http://camel.apache.org/javascript.html >> <choice> >> <when> >> <javaScript>request.headers.get('myheader') == 'myvalue'</javaScript> >> <to uri="log:output"/> >> </when> >> </choice> >> >> The routed worked fine with a "Simple" expression, but raises an >> exception >> when using the JavaScript expression, at the moment that a message >> is sent >> through the route : >> java.lang.IllegalArgumentException: No script engine could be >> created for: >> js >> at >> org >> .apache >> .camel >> .builder.script.ScriptBuilder.createScriptEngine(ScriptBuilder.java: >> 474) >> at >> org >> .apache >> .camel >> .builder.script.ScriptBuilder.checkInitialised(ScriptBuilder.java:451) >> at >> org >> .apache >> .camel.builder.script.ScriptBuilder.getEngine(ScriptBuilder.java:383) >> at >> org >> .apache >> .camel >> .builder.script.ScriptBuilder.getScriptContext(ScriptBuilder.java:426) >> at >> org >> .apache >> .camel >> .builder.script.ScriptBuilder.evaluateScript(ScriptBuilder.java:502) >> at >> org >> .apache >> .camel.builder.script.ScriptBuilder.matches(ScriptBuilder.java:86) >> at >> org >> .apache.camel.processor.ChoiceProcessor.process(ChoiceProcessor.java: >> 65) >> at >> org >> .apache >> .camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:70) >> at >> org >> .apache >> .camel >> .processor >> .DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:98) >> at >> org >> .apache >> .camel >> .processor >> .DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:89) >> at >> org >> .apache >> .camel >> .management >> .InstrumentationProcessor.process(InstrumentationProcessor.java:68) >> at >> org >> .apache >> .camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:70) >> at >> org >> .apache >> .camel >> .processor >> .DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:98) >> at >> org >> .apache >> .camel >> .processor >> .DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:89) >> at >> org >> .apache >> .camel >> .processor >> .interceptor.TraceInterceptor.process(TraceInterceptor.java:174) >> at >> org >> .apache >> .camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:70) >> at >> org >> .apache >> .camel >> .processor >> .RedeliveryErrorHandler >> .processErrorHandler(RedeliveryErrorHandler.java:299) >> at >> org >> .apache >> .camel >> .processor >> .RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:208) >> at >> org >> .apache.camel.processor.DefaultChannel.process(DefaultChannel.java: >> 269) >> at >> org >> .apache >> .camel >> .processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:102) >> at >> org >> .apache >> .camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:70) >> at >> org >> .apache >> .camel >> .processor >> .DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:98) >> at >> org >> .apache >> .camel >> .processor >> .DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:89) >> at >> org >> .apache >> .camel >> .management >> .InstrumentationProcessor.process(InstrumentationProcessor.java:68) >> at >> org >> .apache >> .camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:91) >> at >> org >> .apache >> .camel >> .processor >> .DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:85) >> at >> org.apache.camel.component.restlet.RestletConsumer >> $1.handle(RestletConsumer.java:54) >> at >> org >> .apache >> .camel >> .component.restlet.MethodBasedRouter.handle(MethodBasedRouter.java:56) >> at org.restlet.Filter.doHandle(Filter.java:150) >> at org.restlet.Filter.handle(Filter.java:195) >> at org.restlet.Router.handle(Router.java:504) >> at org.restlet.Filter.doHandle(Filter.java:150) >> at org.restlet.Filter.handle(Filter.java:195) >> at org.restlet.Router.handle(Router.java:504) >> at org.restlet.Filter.doHandle(Filter.java:150) >> at com.noelios.restlet.StatusFilter.doHandle(StatusFilter.java:130) >> at org.restlet.Filter.handle(Filter.java:195) >> at org.restlet.Filter.doHandle(Filter.java:150) >> at org.restlet.Filter.handle(Filter.java:195) >> at com.noelios.restlet.ChainHelper.handle(ChainHelper.java:124) >> at org.restlet.Component.handle(Component.java:673) >> at org.restlet.Server.handle(Server.java:331) >> at com.noelios.restlet.ServerHelper.handle(ServerHelper.java:68) >> at >> com >> .noelios.restlet.http.HttpServerHelper.handle(HttpServerHelper.java: >> 147) >> at >> com.noelios.restlet.http.StreamServerHelper >> $ConnectionHandler.run(StreamServerHelper.java:86) >> at java.util.concurrent.Executors >> $RunnableAdapter.call(Executors.java:441) >> at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) >> at java.util.concurrent.FutureTask.run(FutureTask.java:138) >> at >> java.util.concurrent.ThreadPoolExecutor >> $Worker.runTask(ThreadPoolExecutor.java:886) >> at >> java.util.concurrent.ThreadPoolExecutor >> $Worker.run(ThreadPoolExecutor.java:908) >> at java.lang.Thread.run(Thread.java:662) >> >> With step-by-step debugging in the class >> "javax.script.ScriptEngineManager" >> from "org.apache.servicemix.specs.scripting-api-1.0-1.7.0.jar", I >> see that >> the "instanceof" at line 49 returns false : >> if (object instanceof ScriptEngineFactory) >> which means that com.sun.script.javascript.RhinoScriptEngineFactory >> is not >> an instance of ScriptEngineFactory. >> >> Maybe it is due to class visibility due to OSGi bundle classloading ? >> Any idea how to fix it ? >> >> Thanks, >> >> metatech >> >> >> >> >> -- >> View this message in context: >> http://servicemix.396122.n5.nabble.com/Exception-when-using-JavaScript-expression-in-Camel-routes-tp4758137p4758137.html >> Sent from the ServiceMix - User mailing list archive at Nabble.com. > --------------------------------------------- > Freeman Fang > > FuseSource > Email:[hidden email] > Web: fusesource.com > Twitter: freemanfang > Blog: http://freemanfang.blogspot.com > > > > > > > > > > > > ________________________________ > If you reply to this email, your message will be added to the discussion > below: > http://servicemix.396122.n5.nabble.com/Exception-when-using-JavaScript-expression-in-Camel-routes-tp4758137p4758201.html > To unsubscribe from Exception when using JavaScript expression in Camel > routes, click here. -- View this message in context: http://servicemix.396122.n5.nabble.com/Exception-when-using-JavaScript-expression-in-Camel-routes-tp4758137p4758698.html Sent from the ServiceMix - User mailing list archive at Nabble.com.
