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.