Hello,
I've been running into issues getting a JavaScript endpoint to work in
ServiceMix 4.3. At one point I managed to get a simple working using the
servicemix-scripting component in a stand-along xbean.xml file, but when the
same script was deployed in an SU it generates the following error:
> Caused by: org.mozilla.javascript.EcmaError: ReferenceError:
> "SourceTransformer" is not defined.
To recreate the scenario one need only create a simple, sample project
containing two service units. One is an http SU created using the following
command:
mvn archetype:create -DarchetypeArtifactId=servicemix-http-service-unit
-DarchetypeGroupId=org.apache.servicemix.tooling
-DartifactId=my-test-http-su
The second is the scripting service unit created with the following command:
mvn archetype:create -DarchetypeArtifactId=servicemix-scripting-service-unit
-DarchetypeGroupId=org.apache.servicemix.tooling
-DartifactId=my-test-scripting-su
In the http SU the xbean.xml file needs to be modified to remove all the
end-points except the http:consumer where the targetEndpoint is set to
"javascript-jsr223" which is the default name for the JS endpoint created in
the scripting SU.
In the scripting SU xbean.xml file one needs to add the following or it
won't deploy:
<classpath>
<library>osgi:org.springframework.beans</library>
</classpath>
After creating the SA the project can be built and deployed. To generate the
error just enter the following URL in a browser:
http://localhost:8192/example/
Which should return an error page similar to the following:
<error>
com.google.code.scriptengines.js.util.ExtendedScriptException:
org.mozilla.javascript.EcmaError: ReferenceError: "SourceTransformer" is not
defined. (<Unknown Source>#11) at [11] in file <Unknown Source> at ...
</error>
The same exception will be found in the ServiceMix log.
I'm sure this is a classpath issue, but being a relative novice I not sure
what needs to be done to resolve this issue. I'd tried changing the
dependencies for the scripting SU and adding explicit classpath entries in
the xbean.xml file for the scripting SU, but nothing seemed to help. If you
look at the generated sample JavaScript file (JSExchangeProcessorJSR223.js)
you will observe that it does import the "org.apache.servicemix.jbi.jaxp"
package.
I've also searched these forums and the net at large and have come up with
nothing relevant. Can someone point me in the right direction or let me know
if this is a known issue?
Thanks!
--
View this message in context:
http://servicemix.396122.n5.nabble.com/JavaScript-SourceTransformer-is-not-defined-tp4725805p4725805.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.