Thanks Claus.
Indeed, I needed to have camel-script-javascript installed. In my insane
fervor of trial and error, I didn’t notice that I missed
camel-script-javascript in my Karaf install.
In case any one is interested, I did manage to get tests working with
javascript and osgi. You have to add the javascript engine described in the
camel-script-javascript feature as a dependency in your pom. You’ll have to
add an extra repository in your pom as well. Relevant snippets:
<dependency>
<groupId>com.google.code.scriptengines</groupId>
<artifactId>scriptengines-javascript</artifactId>
<version>1.1</version>
</dependency>
<repositories>
<repository>
<id>googlecode-scriptengines</id>
<name>Google Code Script Engines</name>
<url>http://scriptengines.googlecode.com/svn/m2-repo/</url>
</repository>
</repositories>
~Danny
On Jan 27, 2015, at 2:24 AM, Claus Ibsen <[email protected]> wrote:
> Hi
>
> I think you need to install camel-script-javascript also.
>
>
> On Mon, Jan 26, 2015 at 10:20 PM, Daniel Lamb <[email protected]>
> wrote:
>> I’m using openjdk 1.7.0_65 camel version 2.14.1 and I’ve run into difficulty
>> trying to use camel-script for javascript in a camel route using blueprint.
>> I’ve verified that camel-script works fine when building a war with spring
>> and deploying to a servlet container, but when building a bundle with
>> blueprint I get a timeout with a message like this when tests are attempted:
>>
>> Bundle RouteTest is waiting for dependencies
>> [(&(language=js)(objectClass=org.apache.camel.spi.LanguageResolver))].
>>
>> I also get this error if i build with skipping tests (builds fine) and then
>> deploy to an osgi runtime. I’ve tried both a brand new service mix (5.4.0)
>> and karaf (2.3.7 after following instructions on camel website). Both the
>> camel-script and camel-script-javascript features are installed in both
>> instances. In both situations, the bundle gets put into the grace period
>> for a few moments and then eventually fails.
>>
>> Both projects are simple edits of maven archetypes. Relevant chunks of poms
>> and route xmls:
>>
>> For blueprint:
>>
>> In the pom
>> <dependency>
>> <groupId>org.apache.camel</groupId>
>> <artifactId>camel-core</artifactId>
>> <version>2.14.1</version>
>> </dependency>
>> <dependency>
>> <groupId>org.apache.camel</groupId>
>> <artifactId>camel-blueprint</artifactId>
>> <version>2.14.1</version>
>> </dependency>
>> <dependency>
>> <groupId>org.apache.camel</groupId>
>> <artifactId>camel-script</artifactId>
>> <version>2.14.1</version>
>> </dependency>
>>
>> and in blueprint xml
>> <camelContext xmlns="http://camel.apache.org/schema/blueprint">
>> <route id="timer-to-log">
>> <from uri="timer://foo?fixedRate=true&period=10s"/>
>> <transform>
>> <javaScript>
>> request.body = 'Hello OSGI Application, how are you?';
>> </javaScript>
>> </transform>
>> <log message="From Javascript: ${body}" />
>> </route>
>> </camelContext>
>>
>> For war:
>>
>> In the pom
>> <dependency>
>> <groupId>org.apache.camel</groupId>
>> <artifactId>camel-core</artifactId>
>> <version>2.14.1</version>
>> </dependency>
>> <dependency>
>> <groupId>org.apache.camel</groupId>
>> <artifactId>camel-spring</artifactId>
>> <version>2.14.1</version>
>> </dependency>
>> <dependency>
>> <groupId>org.apache.camel</groupId>
>> <artifactId>camel-script</artifactId>
>> <version>2.14.1</version>
>> </dependency>
>>
>> and in the spring xml
>> <camelContext xmlns="http://camel.apache.org/schema/spring">
>> <route id="timer-to-log">
>> <from uri="timer://foo?fixedRate=true&period=10s"/>
>> <transform>
>> <javaScript>
>> request.body = 'Hello Web Application, how are you?';
>> </javaScript>
>> </transform>
>> <log message="From Javascript: ${body}" />
>> </route>
>> </camelContext>
>>
>> I’ve seen https://issues.apache.org/jira/browse/CAMEL-7122, which is
>> apparently resolved in version 2.13. I’ve also attempted the workaround
>> explained by the original stack overflow post
>> http://stackoverflow.com/questions/20997276/jboss-fuse-apache-camel-wont-resolve-language-js-javascript-for-bundle,
>> but with no luck.
>>
>> Are there any setup steps or other dependencies that I’m missing for this to
>> work in osgi?
>
>
>
> --
> Claus Ibsen
> -----------------
> Red Hat, Inc.
> Email: [email protected]
> Twitter: davsclaus
> Blog: http://davsclaus.com
> Author of Camel in Action: http://www.manning.com/ibsen
> hawtio: http://hawt.io/
> fabric8: http://fabric8.io/