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]
<[email protected]> 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.

Reply via email to