|
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 |
|
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 |
|
In reply to this post by metatech
Hi
SMX 4.4 which is to be shipped with Camel 2.8.x ought to work better with scripting engines in OSGi environments. As the Camel team have improved this in camel-script, and in the osgi pieces in camel-core-osgi. On Thu, Sep 1, 2011 at 2:39 PM, metatech <[hidden email]> 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. > -- Claus Ibsen ----------------- FuseSource Email: [hidden email] Web: http://fusesource.com Twitter: davsclaus, fusenews Blog: http://davsclaus.blogspot.com/ Author of Camel in Action: http://www.manning.com/ibsen/ |
|
In reply to this post by Freeman-2
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] <[hidden email]> 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. |
|
Hi,
Ensure you already install camel-restlet and camel-script feature, then you can deploy your bundle in SMX4.3. Freeman On 2011-9-1, at 下午11:03, metatech wrote: > 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] > <[hidden email]> 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. --------------------------------------------- Freeman Fang FuseSource Email:[hidden email] Web: fusesource.com Twitter: freemanfang Blog: http://freemanfang.blogspot.com |
|
Freeman,
I did install camel-restlet and camel-script. You can see classes from both bundles in my stack trace. Does the sample projet work for you on SMX 4.3 ? Thanks, metatech On 1 September 2011 17:19, Freeman-2 [via ServiceMix] <[hidden email]> wrote: > Hi, > > Ensure you already install camel-restlet and camel-script feature, > then you can deploy your bundle in SMX4.3. > > Freeman > On 2011-9-1, at 下午11:03, metatech wrote: > >> 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] >> <[hidden email]> 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 |
|
Hi,
After install install camel-restlet and camel-script, I can deploy this test bundle successfully with Apache Servicemix 4.3. But without the camel-script feature, I can see exactly same exception you encounter. You need ensure your machine have internet connection and ensure there's no exception when you install camel features. Freeman On 2011-9-1, at 下午11:25, metatech wrote: > Freeman, > > I did install camel-restlet and camel-script. > You can see classes from both bundles in my stack trace. > Does the sample projet work for you on SMX 4.3 ? > > Thanks, > > metatech > > On 1 September 2011 17:19, Freeman-2 [via ServiceMix] > <[hidden email]> wrote: >> Hi, >> >> Ensure you already install camel-restlet and camel-script feature, >> then you can deploy your bundle in SMX4.3. >> >> Freeman >> On 2011-9-1, at 下午11:03, metatech wrote: >> >>> 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] >>> <[hidden email]> 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 > > > -- > View this message in context: http://servicemix.396122.n5.nabble.com/Exception-when-using-JavaScript-expression-in-Camel-routes-tp4758137p4758768.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 |
|
Hi Freeman,
I DID install camel-restlet and camel-script. The bundle is deployed successfully, but I see the exception in my web browser when I try to access its URL : http://localhost:8888/javascriptClassCast I also tried to add the file /META-INF/services/javax.script.ScriptEngineFactory in my bundle, but Camel fails in a different code path : ClassCastException in ScriptEngineManager:131: ScriptEngineFactory f = factoryClass.newInstance(); Following to Claus' answer, I found the following bug : https://issues.apache.org/jira/browse/CAMEL-3481 When I uninstall camel-script, I see a different exception during deployment (see below). I have a "vanilla" ServiceMix 4.3, which contains Camel 2.6 components. Which version do you have ? Thanks, metatech ============= Caused by: org.apache.camel.FailedToCreateRouteException: Failed to create route route3 at: >>> Choice[[When[js{request.headers.get('CamelHttpQuery') == '_wadl2'} -> [To[log:output]]]] Otherwise[[To[log:output]]]] <<< in route: Route[[From[restlet:http://0.0.0.0:8888/javascriptClassCast?... because of No language could be found for: js at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:759)[72:org.apache.camel.camel-core:2.6.0] at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:160)[72:org.apache.camel.camel-core:2.6.0] at org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:701)[72:org.apache.camel.camel-core:2.6.0] at org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:1623)[72:org.apache.camel.camel-core:2.6.0] at org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:1412)[72:org.apache.camel.camel-core:2.6.0] at org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:1321)[72:org.apache.camel.camel-core:2.6.0] at org.apache.camel.spring.SpringCamelContext.doStart(SpringCamelContext.java:164)[79:org.apache.camel.camel-spring:2.6.0] at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:65)[72:org.apache.camel.camel-core:2.6.0] at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:52)[72:org.apache.camel.camel-core:2.6.0] at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:1299)[72:org.apache.camel.camel-core:2.6.0] at org.apache.camel.spring.SpringCamelContext.maybeStart(SpringCamelContext.java:203)[79:org.apache.camel.camel-spring:2.6.0] at org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:101)[79:org.apache.camel.camel-spring:2.6.0] ... 10 more Caused by: org.apache.camel.NoSuchLanguageException: No language could be found for: js at org.apache.camel.core.osgi.OsgiLanguageResolver.resolveLanguage(OsgiLanguageResolver.java:62)[79:org.apache.camel.camel-spring:2.6.0] at org.apache.camel.impl.DefaultCamelContext.resolveLanguage(DefaultCamelContext.java:922)[72:org.apache.camel.camel-core:2.6.0] at org.apache.camel.model.language.ExpressionDefinition.createPredicate(ExpressionDefinition.java:152)[72:org.apache.camel.camel-core:2.6.0] at org.apache.camel.model.language.ExpressionDefinition.createPredicate(ExpressionDefinition.java:141)[72:org.apache.camel.camel-core:2.6.0] at org.apache.camel.model.ExpressionNode.createFilterProcessor(ExpressionNode.java:97)[72:org.apache.camel.camel-core:2.6.0] at org.apache.camel.model.WhenDefinition.createProcessor(WhenDefinition.java:69)[72:org.apache.camel.camel-core:2.6.0] at org.apache.camel.model.ChoiceDefinition.createProcessor(ChoiceDefinition.java:69)[72:org.apache.camel.camel-core:2.6.0] at org.apache.camel.model.ProcessorDefinition.makeProcessor(ProcessorDefinition.java:403)[72:org.apache.camel.camel-core:2.6.0] at org.apache.camel.model.ProcessorDefinition.addRoutes(ProcessorDefinition.java:174)[72:org.apache.camel.camel-core:2.6.0] at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:756)[72:org.apache.camel.camel-core:2.6.0] ... 21 more On 2 September 2011 02:53, Freeman-2 [via ServiceMix] <[hidden email]> wrote: > Hi, > > After install install camel-restlet and camel-script, I can deploy > this test bundle successfully with Apache Servicemix 4.3. > But without the camel-script feature, I can see exactly same exception > you encounter. > You need ensure your machine have internet connection and ensure > there's no exception when you install camel features. > > Freeman > On 2011-9-1, at 下午11:25, metatech wrote: > >> Freeman, >> >> I did install camel-restlet and camel-script. >> You can see classes from both bundles in my stack trace. >> Does the sample projet work for you on SMX 4.3 ? >> >> Thanks, >> >> metatech >> >> On 1 September 2011 17:19, Freeman-2 [via ServiceMix] >> <[hidden email]> wrote: >>> Hi, >>> >>> Ensure you already install camel-restlet and camel-script feature, >>> then you can deploy your bundle in SMX4.3. >>> >>> Freeman >>> On 2011-9-1, at 下午11:03, metatech wrote: >>> >>>> 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] >>>> <[hidden email]> 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 >> >> >> -- |
|
Hi,
I'm testing it with Apache Servicemix 4.3, exactly same version as you use. When I try to access URL :http://localhost:8888/javascriptClassCast From the $SMX_HOME/etc/servicemix.log I see log like 18:25:24,880 | INFO | Thread-37 | Tracer | 68 - org.apache.camel.camel-core - 2.6.0 | ID-Freeman-Mac-55497-1314959007814-0-6 >>> (route1) from(http://0.0.0.0:8888/javascriptClassCast ) --> choice <<< Pattern:InOut, Headers: {org.restlet.startTime=1314959124878, org.restlet.http.version=HTTP/ 1.1, org.restlet.http.headers=[Host: localhost:8888, User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.2.21) Gecko/20110830 Firefox/3.6.21, Accept: text/html,application/xhtml +xml,application/xml;q=0.9,*/*;q=0.8, Accept-Language: en-us,en;q=0.5, Accept-Encoding: gzip,deflate, Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7, Keep-Alive: 115, Connection: keep- alive], CamelHttpMethod=GET, CamelHttpUri=http://localhost:8888/javascriptClassCast }, BodyType:null, Body:null 18:25:24,887 | INFO | Thread-37 | Tracer | 68 - org.apache.camel.camel-core - 2.6.0 | ID-Freeman-Mac-55497-1314959007814-0-6 >>> (route1) choice --> log://output <<< Pattern:InOut, Headers: {org.restlet.startTime=1314959124878, org.restlet.http.version=HTTP/ 1.1, org.restlet.http.headers=[Host: localhost:8888, User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.2.21) Gecko/20110830 Firefox/3.6.21, Accept: text/html,application/xhtml +xml,application/xml;q=0.9,*/*;q=0.8, Accept-Language: en-us,en;q=0.5, Accept-Encoding: gzip,deflate, Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7, Keep-Alive: 115, Connection: keep- alive], CamelHttpMethod=GET, CamelHttpUri=http://localhost:8888/javascriptClassCast }, BodyType:null, Body:null 18:25:24,888 | INFO | Thread-37 | output | 68 - org.apache.camel.camel-core - 2.6.0 | Exchange[ExchangePattern:InOut, BodyType:null, Body:null] 18:25:24,889 | INFO | Thread-37 | LogService | - - | 2011-09-02 18:25:24 0:0:0:0:0:0:0:1%0 8888 GET /javascriptClassCast - 200 - - 10 http://localhost:8888 Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.2.21) Gecko/20110830 Firefox/3.6.21 - So I assume for this simple camel router it should also work in SMX4.3. Of course you can expect SMX 4.4(which will be release soon) which will use Camel 2.8.x for better camel-script support in OSGi container. Btw, you may need check if you install camel-restlet and camel-script feature successfully. Freeman On 2011-9-2, at 下午3:24, metatech wrote: > Hi Freeman, > > I DID install camel-restlet and camel-script. > > The bundle is deployed successfully, but I see the exception in my web > browser when I try to access its URL : > http://localhost:8888/javascriptClassCast > > I also tried to add the file > /META-INF/services/javax.script.ScriptEngineFactory in my bundle, but > Camel fails in a different code path : ClassCastException in > ScriptEngineManager:131: > ScriptEngineFactory f = factoryClass.newInstance(); > > Following to Claus' answer, I found the following bug : > https://issues.apache.org/jira/browse/CAMEL-3481 > > When I uninstall camel-script, I see a different exception during > deployment (see below). > I have a "vanilla" ServiceMix 4.3, which contains Camel 2.6 > components. > Which version do you have ? > > Thanks, > > metatech > ============= > Caused by: org.apache.camel.FailedToCreateRouteException: Failed to > create route route3 at: >>> > Choice[[When[js{request.headers.get('CamelHttpQuery') == '_wadl2'} -> > [To[log:output]]]] Otherwise[[To[log:output]]]] <<< in route: > Route[[From[restlet:http://0.0.0.0:8888/javascriptClassCast?... > because of No language could be found for: js > at > org > .apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java: > 759)[72:org.apache.camel.camel-core:2.6.0] > at > org > .apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java: > 160)[72:org.apache.camel.camel-core:2.6.0] > at > org > .apache > .camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java: > 701)[72:org.apache.camel.camel-core:2.6.0] > at > org > .apache > .camel > .impl > .DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java: > 1623)[72:org.apache.camel.camel-core:2.6.0] > at > org > .apache > .camel > .impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:1412) > [72:org.apache.camel.camel-core:2.6.0] > at > org > .apache > .camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java: > 1321)[72:org.apache.camel.camel-core:2.6.0] > at > org > .apache > .camel.spring.SpringCamelContext.doStart(SpringCamelContext.java:164) > [79:org.apache.camel.camel-spring:2.6.0] > at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java: > 65)[72:org.apache.camel.camel-core:2.6.0] > at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java: > 52)[72:org.apache.camel.camel-core:2.6.0] > at > org > .apache > .camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:1299) > [72:org.apache.camel.camel-core:2.6.0] > at > org > .apache > .camel.spring.SpringCamelContext.maybeStart(SpringCamelContext.java: > 203)[79:org.apache.camel.camel-spring:2.6.0] > at > org > .apache > .camel > .spring > .SpringCamelContext.onApplicationEvent(SpringCamelContext.java:101) > [79:org.apache.camel.camel-spring:2.6.0] > ... 10 more > Caused by: org.apache.camel.NoSuchLanguageException: No language could > be found for: js > at > org > .apache > .camel > .core > .osgi.OsgiLanguageResolver.resolveLanguage(OsgiLanguageResolver.java: > 62)[79:org.apache.camel.camel-spring:2.6.0] > at > org > .apache > .camel > .impl.DefaultCamelContext.resolveLanguage(DefaultCamelContext.java: > 922)[72:org.apache.camel.camel-core:2.6.0] > at > org > .apache > .camel > .model > .language > .ExpressionDefinition.createPredicate(ExpressionDefinition.java:152) > [72:org.apache.camel.camel-core:2.6.0] > at > org > .apache > .camel > .model > .language > .ExpressionDefinition.createPredicate(ExpressionDefinition.java:141) > [72:org.apache.camel.camel-core:2.6.0] > at > org > .apache > .camel > .model.ExpressionNode.createFilterProcessor(ExpressionNode.java:97) > [72:org.apache.camel.camel-core:2.6.0] > at > org > .apache > .camel.model.WhenDefinition.createProcessor(WhenDefinition.java:69) > [72:org.apache.camel.camel-core:2.6.0] > at > org > .apache > .camel.model.ChoiceDefinition.createProcessor(ChoiceDefinition.java: > 69)[72:org.apache.camel.camel-core:2.6.0] > at > org > .apache > .camel > .model.ProcessorDefinition.makeProcessor(ProcessorDefinition.java: > 403)[72:org.apache.camel.camel-core:2.6.0] > at > org > .apache > .camel.model.ProcessorDefinition.addRoutes(ProcessorDefinition.java: > 174)[72:org.apache.camel.camel-core:2.6.0] > at > org > .apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java: > 756)[72:org.apache.camel.camel-core:2.6.0] > ... 21 more > > > On 2 September 2011 02:53, Freeman-2 [via ServiceMix] > <[hidden email]> wrote: >> Hi, >> >> After install install camel-restlet and camel-script, I can deploy >> this test bundle successfully with Apache Servicemix 4.3. >> But without the camel-script feature, I can see exactly same >> exception >> you encounter. >> You need ensure your machine have internet connection and ensure >> there's no exception when you install camel features. >> >> Freeman >> On 2011-9-1, at 下午11:25, metatech wrote: >> >>> Freeman, >>> >>> I did install camel-restlet and camel-script. >>> You can see classes from both bundles in my stack trace. >>> Does the sample projet work for you on SMX 4.3 ? >>> >>> Thanks, >>> >>> metatech >>> >>> On 1 September 2011 17:19, Freeman-2 [via ServiceMix] >>> <[hidden email]> wrote: >>>> Hi, >>>> >>>> Ensure you already install camel-restlet and camel-script feature, >>>> then you can deploy your bundle in SMX4.3. >>>> >>>> Freeman >>>> On 2011-9-1, at 下午11:03, metatech wrote: >>>> >>>>> 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] >>>>> <[hidden email]> 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 >>> >>> >>> -- > > > -- > View this message in context: http://servicemix.396122.n5.nabble.com/Exception-when-using-JavaScript-expression-in-Camel-routes-tp4758137p4761355.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 |
|
Hi Freeman,
I found the cause of my exception : My ServiceMix installation was not really "vanilla" : I anticipated the future "light" packaging (SMX4-883) and removed all "servicemix-*" features, including "servicemix-scripting", because I use only OSGI components and no JBI components (they are planned to be removed in ServiceMix 5.x anyway). After reinstalling the JavaScript engine with the following commands, it worked ! osgi:install mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.rhino/1.7R1_3 osgi:install mvn:com.google.code.scriptengines/scriptengines-javascript/1.1 osgi:start 147 osgi:start 148 By debugging step-by-step, I see that the implementation used is "com.google.code.scriptengines.js.javascript.RhinoScriptEngineFactory". I find it strange however that the "camel-script" relies on the presence of the "servicemix-scripting" to work properly. Is it really intended to work this way ? Maybe the enhancements in Camel 2.8 will make this prerequisite unnecessary anymore. It is nevertheless worth checking that it works with Service 4.4 (or 4.5) without JBI. Next time I will certainly try to reproduce on a "full vanilla installation" :-) Thanks again for your help ! metatech On 2 September 2011 12:38, Freeman-2 [via ServiceMix] <[hidden email]> wrote: > Hi, > > I'm testing it with Apache Servicemix 4.3, exactly same version as you > use. > When I try to access URL :http://localhost:8888/javascriptClassCast > > From the $SMX_HOME/etc/servicemix.log I see log like > > 18:25:24,880 | INFO | Thread-37 | > Tracer | 68 - org.apache.camel.camel-core - > 2.6.0 | ID-Freeman-Mac-55497-1314959007814-0-6 >>> (route1) > from(http://0.0.0.0:8888/javascriptClassCast > ) --> choice <<< Pattern:InOut, Headers: > {org.restlet.startTime=1314959124878, org.restlet.http.version=HTTP/ > 1.1, org.restlet.http.headers=[Host: localhost:8888, User-Agent: > Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.2.21) > Gecko/20110830 Firefox/3.6.21, Accept: text/html,application/xhtml > +xml,application/xml;q=0.9,*/*;q=0.8, Accept-Language: en-us,en;q=0.5, > Accept-Encoding: gzip,deflate, Accept-Charset: > ISO-8859-1,utf-8;q=0.7,*;q=0.7, Keep-Alive: 115, Connection: keep- > alive], CamelHttpMethod=GET, > CamelHttpUri=http://localhost:8888/javascriptClassCast > }, BodyType:null, Body:null > 18:25:24,887 | INFO | Thread-37 | > Tracer | 68 - org.apache.camel.camel-core - > 2.6.0 | ID-Freeman-Mac-55497-1314959007814-0-6 >>> (route1) choice --> > log://output <<< Pattern:InOut, Headers: > {org.restlet.startTime=1314959124878, org.restlet.http.version=HTTP/ > 1.1, org.restlet.http.headers=[Host: localhost:8888, User-Agent: > Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.2.21) > Gecko/20110830 Firefox/3.6.21, Accept: text/html,application/xhtml > +xml,application/xml;q=0.9,*/*;q=0.8, Accept-Language: en-us,en;q=0.5, > Accept-Encoding: gzip,deflate, Accept-Charset: > ISO-8859-1,utf-8;q=0.7,*;q=0.7, Keep-Alive: 115, Connection: keep- > alive], CamelHttpMethod=GET, > CamelHttpUri=http://localhost:8888/javascriptClassCast > }, BodyType:null, Body:null > 18:25:24,888 | INFO | Thread-37 | > output | 68 - org.apache.camel.camel-core - > 2.6.0 | Exchange[ExchangePattern:InOut, BodyType:null, Body:null] > 18:25:24,889 | INFO | Thread-37 | > LogService | - - | 2011-09-02 18:25:24 > 0:0:0:0:0:0:0:1%0 8888 GET /javascriptClassCast - 200 - - 10 > http://localhost:8888 > Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.2.21) > > Gecko/20110830 Firefox/3.6.21 - > > > So I assume for this simple camel router it should also work in SMX4.3. > > Of course you can expect SMX 4.4(which will be release soon) which > will use Camel 2.8.x for better camel-script support in OSGi container. > > Btw, you may need check if you install camel-restlet and camel-script > feature successfully. > > Freeman > On 2011-9-2, at 下午3:24, metatech wrote: > >> Hi Freeman, >> >> I DID install camel-restlet and camel-script. >> >> The bundle is deployed successfully, but I see the exception in my web >> browser when I try to access its URL : >> http://localhost:8888/javascriptClassCast >> >> I also tried to add the file >> /META-INF/services/javax.script.ScriptEngineFactory in my bundle, but >> Camel fails in a different code path : ClassCastException in >> ScriptEngineManager:131: >> ScriptEngineFactory f = factoryClass.newInstance(); >> >> Following to Claus' answer, I found the following bug : >> https://issues.apache.org/jira/browse/CAMEL-3481 >> >> When I uninstall camel-script, I see a different exception during >> deployment (see below). >> I have a "vanilla" ServiceMix 4.3, which contains Camel 2.6 >> components. >> Which version do you have ? >> >> Thanks, >> >> metatech >> ============= >> Caused by: org.apache.camel.FailedToCreateRouteException: Failed to >> create route route3 at: >>> >> Choice[[When[js{request.headers.get('CamelHttpQuery') == '_wadl2'} -> >> [To[log:output]]]] Otherwise[[To[log:output]]]] <<< in route: >> Route[[From[restlet:http://0.0.0.0:8888/javascriptClassCast?... >> because of No language could be found for: js >> at >> org >> .apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java: >> 759)[72:org.apache.camel.camel-core:2.6.0] >> at >> org >> .apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java: >> 160)[72:org.apache.camel.camel-core:2.6.0] >> at >> org >> .apache >> .camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java: >> 701)[72:org.apache.camel.camel-core:2.6.0] >> at >> org >> .apache >> .camel >> .impl >> .DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java: >> 1623)[72:org.apache.camel.camel-core:2.6.0] >> at >> org >> .apache >> .camel >> .impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:1412) >> [72:org.apache.camel.camel-core:2.6.0] >> at >> org >> .apache >> .camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java: >> 1321)[72:org.apache.camel.camel-core:2.6.0] >> at >> org >> .apache >> .camel.spring.SpringCamelContext.doStart(SpringCamelContext.java:164) >> [79:org.apache.camel.camel-spring:2.6.0] >> at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java: >> 65)[72:org.apache.camel.camel-core:2.6.0] >> at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java: >> 52)[72:org.apache.camel.camel-core:2.6.0] >> at >> org >> .apache >> .camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:1299) >> [72:org.apache.camel.camel-core:2.6.0] >> at >> org >> .apache >> .camel.spring.SpringCamelContext.maybeStart(SpringCamelContext.java: >> 203)[79:org.apache.camel.camel-spring:2.6.0] >> at >> org >> .apache >> .camel >> .spring >> .SpringCamelContext.onApplicationEvent(SpringCamelContext.java:101) >> [79:org.apache.camel.camel-spring:2.6.0] >> ... 10 more >> Caused by: org.apache.camel.NoSuchLanguageException: No language could >> be found for: js >> at >> org >> .apache >> .camel >> .core >> .osgi.OsgiLanguageResolver.resolveLanguage(OsgiLanguageResolver.java: >> 62)[79:org.apache.camel.camel-spring:2.6.0] >> at >> org >> .apache >> .camel >> .impl.DefaultCamelContext.resolveLanguage(DefaultCamelContext.java: >> 922)[72:org.apache.camel.camel-core:2.6.0] >> at >> org >> .apache >> .camel >> .model >> .language >> .ExpressionDefinition.createPredicate(ExpressionDefinition.java:152) >> [72:org.apache.camel.camel-core:2.6.0] >> at >> org >> .apache >> .camel >> .model >> .language >> .ExpressionDefinition.createPredicate(ExpressionDefinition.java:141) >> [72:org.apache.camel.camel-core:2.6.0] >> at >> org >> .apache >> .camel >> .model.ExpressionNode.createFilterProcessor(ExpressionNode.java:97) >> [72:org.apache.camel.camel-core:2.6.0] >> at >> org >> .apache >> .camel.model.WhenDefinition.createProcessor(WhenDefinition.java:69) >> [72:org.apache.camel.camel-core:2.6.0] >> at >> org >> .apache >> .camel.model.ChoiceDefinition.createProcessor(ChoiceDefinition.java: >> 69)[72:org.apache.camel.camel-core:2.6.0] >> at >> org >> .apache >> .camel >> .model.ProcessorDefinition.makeProcessor(ProcessorDefinition.java: >> 403)[72:org.apache.camel.camel-core:2.6.0] >> at >> org >> .apache >> .camel.model.ProcessorDefinition.addRoutes(ProcessorDefinition.java: >> 174)[72:org.apache.camel.camel-core:2.6.0] >> at >> org >> .apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java: >> 756)[72:org.apache.camel.camel-core:2.6.0] >> ... 21 more >> >> >> On 2 September 2011 02:53, Freeman-2 [via ServiceMix] >> <[hidden email]> wrote: >>> Hi, >>> >>> After install install camel-restlet and camel-script, I can deploy >>> this test bundle successfully with Apache Servicemix 4.3. >>> But without the camel-script feature, I can see exactly same >>> exception >>> you encounter. >>> You need ensure your machine have internet connection and ensure >>> there's no exception when you install camel features. >>> >>> Freeman >>> On 2011-9-1, at 下午11:25, metatech wrote: >>> >>>> Freeman, >>>> >>>> I did install camel-restlet and camel-script. >>>> You can see classes from both bundles in my stack trace. >>>> Does the sample projet work for you on SMX 4.3 ? >>>> >>>> Thanks, >>>> >>>> metatech >>>> >>>> On 1 September 2011 17:19, Freeman-2 [via ServiceMix] >>>> <[hidden email]> wrote: >>>>> Hi, >>>>> >>>>> Ensure you already install camel-restlet and camel-script feature, >>>>> then you can deploy your bundle in SMX4.3. >>>>> >>>>> Freeman >>>>> On 2011-9-1, at 下午11:03, metatech wrote: >>>>> >>>>>> 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] >>>>>> <[hidden email]> 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 >>>> >>>> >>>> -- >> >> >> -- >> View this message in context: >> http://servicemix.396122.n5.nabble.com/Exception-when-using-JavaScript-expression-in-Camel-routes-tp4758137p4761355.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-tp4758137p4761878.html > To unsubscribe from Exception when using JavaScript expression in Camel > routes, click here. |
|
Hi,
Absolutely camel-script should work without sevicemix-scripting feature get installed, create CAMEL-4407[1], will fix it there. Thanks for pointing out this issue. [1]https://issues.apache.org/jira/browse/CAMEL-4407 Freeman On 2011-9-2, at 下午7:59, metatech wrote: > Hi Freeman, > > I found the cause of my exception : > > My ServiceMix installation was not really "vanilla" : I anticipated > the future "light" packaging (SMX4-883) and removed all "servicemix-*" > features, including "servicemix-scripting", because I use only OSGI > components and no JBI components (they are planned to be removed in > ServiceMix 5.x anyway). > > After reinstalling the JavaScript engine with the following commands, > it worked ! > > osgi:install mvn:org.apache.servicemix.bundles/ > org.apache.servicemix.bundles.rhino/1.7R1_3 > osgi:install mvn:com.google.code.scriptengines/scriptengines- > javascript/1.1 > osgi:start 147 > osgi:start 148 > > By debugging step-by-step, I see that the implementation used is > "com > .google.code.scriptengines.js.javascript.RhinoScriptEngineFactory". > > I find it strange however that the "camel-script" relies on the > presence of the "servicemix-scripting" to work properly. Is it really > intended to work this way ? Maybe the enhancements in Camel 2.8 will > make this prerequisite unnecessary anymore. > It is nevertheless worth checking that it works with Service 4.4 (or > 4.5) without JBI. > > Next time I will certainly try to reproduce on a "full vanilla > installation" :-) > > Thanks again for your help ! > > metatech > > > On 2 September 2011 12:38, Freeman-2 [via ServiceMix] > <[hidden email]> wrote: >> Hi, >> >> I'm testing it with Apache Servicemix 4.3, exactly same version as >> you >> use. >> When I try to access URL :http://localhost:8888/javascriptClassCast >> >> From the $SMX_HOME/etc/servicemix.log I see log like >> >> 18:25:24,880 | INFO | Thread-37 | >> Tracer | 68 - org.apache.camel.camel-core - >> 2.6.0 | ID-Freeman-Mac-55497-1314959007814-0-6 >>> (route1) >> from(http://0.0.0.0:8888/javascriptClassCast >> ) --> choice <<< Pattern:InOut, Headers: >> {org.restlet.startTime=1314959124878, org.restlet.http.version=HTTP/ >> 1.1, org.restlet.http.headers=[Host: localhost:8888, User-Agent: >> Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.2.21) >> Gecko/20110830 Firefox/3.6.21, Accept: text/html,application/xhtml >> +xml,application/xml;q=0.9,*/*;q=0.8, Accept-Language: en- >> us,en;q=0.5, >> Accept-Encoding: gzip,deflate, Accept-Charset: >> ISO-8859-1,utf-8;q=0.7,*;q=0.7, Keep-Alive: 115, Connection: keep- >> alive], CamelHttpMethod=GET, >> CamelHttpUri=http://localhost:8888/javascriptClassCast >> }, BodyType:null, Body:null >> 18:25:24,887 | INFO | Thread-37 | >> Tracer | 68 - org.apache.camel.camel-core - >> 2.6.0 | ID-Freeman-Mac-55497-1314959007814-0-6 >>> (route1) choice >> --> >> log://output <<< Pattern:InOut, Headers: >> {org.restlet.startTime=1314959124878, org.restlet.http.version=HTTP/ >> 1.1, org.restlet.http.headers=[Host: localhost:8888, User-Agent: >> Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.2.21) >> Gecko/20110830 Firefox/3.6.21, Accept: text/html,application/xhtml >> +xml,application/xml;q=0.9,*/*;q=0.8, Accept-Language: en- >> us,en;q=0.5, >> Accept-Encoding: gzip,deflate, Accept-Charset: >> ISO-8859-1,utf-8;q=0.7,*;q=0.7, Keep-Alive: 115, Connection: keep- >> alive], CamelHttpMethod=GET, >> CamelHttpUri=http://localhost:8888/javascriptClassCast >> }, BodyType:null, Body:null >> 18:25:24,888 | INFO | Thread-37 | >> output | 68 - org.apache.camel.camel-core - >> 2.6.0 | Exchange[ExchangePattern:InOut, BodyType:null, Body:null] >> 18:25:24,889 | INFO | Thread-37 | >> LogService | - - | 2011-09-02 18:25:24 >> 0:0:0:0:0:0:0:1%0 8888 GET /javascriptClassCast - 200 - - 10 >> http://localhost:8888 >> Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv: >> 1.9.2.21) >> >> Gecko/20110830 Firefox/3.6.21 - >> >> >> So I assume for this simple camel router it should also work in >> SMX4.3. >> >> Of course you can expect SMX 4.4(which will be release soon) which >> will use Camel 2.8.x for better camel-script support in OSGi >> container. >> >> Btw, you may need check if you install camel-restlet and camel-script >> feature successfully. >> >> Freeman >> On 2011-9-2, at 下午3:24, metatech wrote: >> >>> Hi Freeman, >>> >>> I DID install camel-restlet and camel-script. >>> >>> The bundle is deployed successfully, but I see the exception in my >>> web >>> browser when I try to access its URL : >>> http://localhost:8888/javascriptClassCast >>> >>> I also tried to add the file >>> /META-INF/services/javax.script.ScriptEngineFactory in my bundle, >>> but >>> Camel fails in a different code path : ClassCastException in >>> ScriptEngineManager:131: >>> ScriptEngineFactory f = factoryClass.newInstance(); >>> >>> Following to Claus' answer, I found the following bug : >>> https://issues.apache.org/jira/browse/CAMEL-3481 >>> >>> When I uninstall camel-script, I see a different exception during >>> deployment (see below). >>> I have a "vanilla" ServiceMix 4.3, which contains Camel 2.6 >>> components. >>> Which version do you have ? >>> >>> Thanks, >>> >>> metatech >>> ============= >>> Caused by: org.apache.camel.FailedToCreateRouteException: Failed to >>> create route route3 at: >>> >>> Choice[[When[js{request.headers.get('CamelHttpQuery') == '_wadl2'} >>> -> >>> [To[log:output]]]] Otherwise[[To[log:output]]]] <<< in route: >>> Route[[From[restlet:http://0.0.0.0:8888/javascriptClassCast?... >>> because of No language could be found for: js >>> at >>> org >>> .apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java: >>> 759)[72:org.apache.camel.camel-core:2.6.0] >>> at >>> org >>> .apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java: >>> 160)[72:org.apache.camel.camel-core:2.6.0] >>> at >>> org >>> .apache >>> .camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java: >>> 701)[72:org.apache.camel.camel-core:2.6.0] >>> at >>> org >>> .apache >>> .camel >>> .impl >>> .DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java: >>> 1623)[72:org.apache.camel.camel-core:2.6.0] >>> at >>> org >>> .apache >>> .camel >>> .impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java: >>> 1412) >>> [72:org.apache.camel.camel-core:2.6.0] >>> at >>> org >>> .apache >>> .camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java: >>> 1321)[72:org.apache.camel.camel-core:2.6.0] >>> at >>> org >>> .apache >>> .camel.spring.SpringCamelContext.doStart(SpringCamelContext.java: >>> 164) >>> [79:org.apache.camel.camel-spring:2.6.0] >>> at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java: >>> 65)[72:org.apache.camel.camel-core:2.6.0] >>> at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java: >>> 52)[72:org.apache.camel.camel-core:2.6.0] >>> at >>> org >>> .apache >>> .camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:1299) >>> [72:org.apache.camel.camel-core:2.6.0] >>> at >>> org >>> .apache >>> .camel.spring.SpringCamelContext.maybeStart(SpringCamelContext.java: >>> 203)[79:org.apache.camel.camel-spring:2.6.0] >>> at >>> org >>> .apache >>> .camel >>> .spring >>> .SpringCamelContext.onApplicationEvent(SpringCamelContext.java:101) >>> [79:org.apache.camel.camel-spring:2.6.0] >>> ... 10 more >>> Caused by: org.apache.camel.NoSuchLanguageException: No language >>> could >>> be found for: js >>> at >>> org >>> .apache >>> .camel >>> .core >>> .osgi >>> .OsgiLanguageResolver.resolveLanguage(OsgiLanguageResolver.java: >>> 62)[79:org.apache.camel.camel-spring:2.6.0] >>> at >>> org >>> .apache >>> .camel >>> .impl.DefaultCamelContext.resolveLanguage(DefaultCamelContext.java: >>> 922)[72:org.apache.camel.camel-core:2.6.0] >>> at >>> org >>> .apache >>> .camel >>> .model >>> .language >>> .ExpressionDefinition.createPredicate(ExpressionDefinition.java:152) >>> [72:org.apache.camel.camel-core:2.6.0] >>> at >>> org >>> .apache >>> .camel >>> .model >>> .language >>> .ExpressionDefinition.createPredicate(ExpressionDefinition.java:141) >>> [72:org.apache.camel.camel-core:2.6.0] >>> at >>> org >>> .apache >>> .camel >>> .model.ExpressionNode.createFilterProcessor(ExpressionNode.java:97) >>> [72:org.apache.camel.camel-core:2.6.0] >>> at >>> org >>> .apache >>> .camel.model.WhenDefinition.createProcessor(WhenDefinition.java:69) >>> [72:org.apache.camel.camel-core:2.6.0] >>> at >>> org >>> .apache >>> .camel.model.ChoiceDefinition.createProcessor(ChoiceDefinition.java: >>> 69)[72:org.apache.camel.camel-core:2.6.0] >>> at >>> org >>> .apache >>> .camel >>> .model.ProcessorDefinition.makeProcessor(ProcessorDefinition.java: >>> 403)[72:org.apache.camel.camel-core:2.6.0] >>> at >>> org >>> .apache >>> .camel.model.ProcessorDefinition.addRoutes(ProcessorDefinition.java: >>> 174)[72:org.apache.camel.camel-core:2.6.0] >>> at >>> org >>> .apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java: >>> 756)[72:org.apache.camel.camel-core:2.6.0] >>> ... 21 more >>> >>> >>> On 2 September 2011 02:53, Freeman-2 [via ServiceMix] >>> <[hidden email]> wrote: >>>> Hi, >>>> >>>> After install install camel-restlet and camel-script, I can deploy >>>> this test bundle successfully with Apache Servicemix 4.3. >>>> But without the camel-script feature, I can see exactly same >>>> exception >>>> you encounter. >>>> You need ensure your machine have internet connection and ensure >>>> there's no exception when you install camel features. >>>> >>>> Freeman >>>> On 2011-9-1, at 下午11:25, metatech wrote: >>>> >>>>> Freeman, >>>>> >>>>> I did install camel-restlet and camel-script. >>>>> You can see classes from both bundles in my stack trace. >>>>> Does the sample projet work for you on SMX 4.3 ? >>>>> >>>>> Thanks, >>>>> >>>>> metatech >>>>> >>>>> On 1 September 2011 17:19, Freeman-2 [via ServiceMix] >>>>> <[hidden email]> wrote: >>>>>> Hi, >>>>>> >>>>>> Ensure you already install camel-restlet and camel-script >>>>>> feature, >>>>>> then you can deploy your bundle in SMX4.3. >>>>>> >>>>>> Freeman >>>>>> On 2011-9-1, at 下午11:03, metatech wrote: >>>>>> >>>>>>> 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] >>>>>>> <[hidden email]> 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 >>>>> >>>>> >>>>> -- >>> >>> >>> -- >>> View this message in context: >>> http://servicemix.396122.n5.nabble.com/Exception-when-using-JavaScript-expression-in-Camel-routes-tp4758137p4761355.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-tp4758137p4761878.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-tp4758137p4762080.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 |
|
Encountered the same issue above and resolved it. Adding our solution in case this helps with anyone else who finds this page through google like we did.
Make sure that the mvn bundle, org.apache.camel/camel-script is also included in your servicemix. We were using servicemix 4.3 and we had to add this before anything would work. This bundle was not included by default in the servicemix-script features, though we "thought" it was because we saw this bundle, org.apache.servicemix/servicemix-scripting, in the features and thought it was the same bundles with a different names. |
| Powered by Nabble | Edit this page |
