- 
        1. Re: Scriptingdavsclaus May 4, 2011 1:54 PM (in response to manta7)Can you post the entire XML file. I wonder what namespace you use for the scripting tag? 
- 
        2. Re: Scriptingdavsclaus May 4, 2011 1:54 PM (in response to davsclaus)And what version of ServiceMix and JDK are you using? 
- 
        3. Re: Scriptingmanta7 May 4, 2011 2:09 PM (in response to manta7)Thanks for helping me, I use Servicemix 4.3 (and the OSGI way), with Camel 2.6 components and the JDK 1.5 (is there a difference with Java 6?). Sorry I didn't have my XML on this computer, but I followed this documentation with: <beans xmlns:scripting="http://servicemix.apache.org/scripting/1.0" xmlns:test="http://servicemix.apache.org/test" xmlns:util="http://www.springframework.org/schema/util"> But I added also the schemaLocation: http://servicemix.apache.org/scripting/1.0 http://servicemix.apache.org/scripting/1.0/servicemix-scripting.xsd Indeed, without this line my component was not deployed 
- 
        4. Re: Scriptingffang May 4, 2011 9:02 PM (in response to manta7)Hi, You misuse camel language component and scripting JBI component here. The endpoint you defined here <scripting:endpoint service="test:script" endpoint="scriptEndpoint" script="classpath:script/script.js" /> is a JBI endpoint, it can't be used directly in camel language component. Per the The correct URI for camel language endpoint is language://languageName[:script][?options] where the script part is the script to execute, but it shouldn't be a endpoint name of JBI scripting endpoint. http://camel.apache.org/language.html Freeman 
- 
        5. Re: Scriptingmanta7 May 5, 2011 3:01 AM (in response to ffang)Ok but I don't know how to complete the script argument in the language:// command... "but it shouldn't be a endpoint name of JBI scripting endpoint" What should it be so to access to my script.js ? Edited by: manta7 on May 5, 2011 7:00 AM 
- 
        6. Re: Scriptingdavsclaus May 5, 2011 3:04 AM (in response to manta7)The is as Freeman said a JBI component. So you need to use the Camel JBI to interact with it You cannot use the Camel language component directly with the JBI scripting component. We should maybe improve the Camel language component so it can load a script from a resource (eg from a file on the classpath etc.). I will log an enhancement for that. 
- 
        7. Re: Scriptingdavsclaus May 5, 2011 3:10 AM (in response to davsclaus)The enhancement ticket is here 
- 
        8. Re: Scriptingmanta7 May 5, 2011 3:39 AM (in response to davsclaus)Ok thanks for the ticket and the answer I understand... So according to my jbi endpoint which is: <scripting:endpoint service="test:script" endpoint="scriptEndpoint" script="classpath:script/script.js" /> And to my test namespace which is: xmlns:test="http://company.perso.org" My camel route should be: to("jbi:endpoint:http://company.perso.org/script/scriptEndpoint") Isn't it ? Because I get this exception : 09:34:27,564 | ERROR | 1 - seda://mslJS | SedaConsumer | ? ? | 944 - org.apache.camel.camel-core - 2.6.0 | Error processing exchange. Exchange[Message: ]. Caused by: [org.apache.camel.RuntimeCamelException - java.lang.IllegalStateEx ception: Invalid BundleContext.] 
- 
        9. Re: Scriptingmanta7 May 5, 2011 5:31 AM (in response to manta7)Weird.. I restart Servicemix and I don't have the Invalid BundleContext anymore, but I can't still access to my JBI endpoint <scripting:endpoint service="test:script" endpoint="scriptEndpoint" script="classpath:script/script.js" /> <bean class="org.apache.servicemix.common.osgi.EndpointExporter" /> <osgi:camelContext id="camelCTX" xmlns="http://camel.apache.org/schema/spring"> <package>org.my.mosaic.route</package> </osgi:camelContext> 
- 
        10. Re: Scriptingffang May 5, 2011 6:11 AM (in response to manta7)Hi, Scripting endpoint is a kind of consumer jbi endpoint, it's an initial side of a MEP, so it couldn't play the role as a target. Freeman 
- 
        11. Re: Scriptingdavsclaus May 5, 2011 6:59 AM (in response to ffang)A solution with pure Camel would be to load the script file and provide it as a header before you send the message the the camel language component. See that last example http://camel.apache.org/language You would then have to use for example java code to load the script file from the classpath. 
- 
        12. Re: Scriptingmanta7 May 5, 2011 9:11 AM (in response to davsclaus)Ok I succeed it ! Thanks for all your reply ! So for the next people's who will be lost as I was, the solution is indeed the last on this page : http://camel.apache.org/language You have to use a bean: from("..."). to("bean:MyBean?method=xx"); Into the xx method, I wrote that: CamelContext ctx = exchange.getContext(); ProducerTemplate producer = new DefaultProducerTemplate(ctx); try { producer.start(); producer.requestBodyAndHeader("language:javascript", exchange.getIn(), Exchange.LANGUAGE_SCRIPT, fileToString(myFile)); } catch (Exception e) { //Exception } The fileToString method take a File as argument and return the content as a string After on the js file you can access to the argument with context, exchange... (ScriptContext paragraph on http://camel.apache.org/javascript.html) Thx again ! 
- 
        13. Re: Scriptingmanta7 May 9, 2011 1:10 PM (in response to manta7)Arf.. Unfortunately this solution leads to a problem.. Ideed, the JSR 223 provides the ScriptEngine class ( http://download.oracle.com/javase/6/docs/api/javax/script/ScriptEngine.html) and the put method which allows to set a Java object into the script. With the source above, I can't pass Java objects... I'm lost :/ 
- 
        14. Re: Scriptingmanta7 May 10, 2011 2:27 PM (in response to manta7)Ok I solved the problem! (I know it's a monologue ) The only thing I found was to change the camel-script component. Indeed, in my component I put a Map<String, Object> into the header of the message. And in the evaluateScript(Exchange) method of the camel-script component, I iterate on the Map and I use the put() method of the ScriptEngine. I know this is not the most used component, but I think it could be a nice little evolution. Don't you think ? 
 
     
    