admin管理员组文章数量:1387360
I am trying to use ScriptEngineManager
and ScriptEngine
to execute some JavaScript code with Java. I use Java 8 I am executing this code under Karaf OSGi.
The example I used works fine in a sample Java Class, but packing it in a bundle gives me this error ScriptEngineManager providers.next(): javax.script.ScriptEngineFactory: Provider jdk.nashorn.api.scripting.NashornScriptEngineFactory not found
When I look to the headers of the bundle, I see that the bundle imports javax.script,
the package of the called classes but it seems that (nashorn) the provider is not found.
Thanks
I am trying to use ScriptEngineManager
and ScriptEngine
to execute some JavaScript code with Java. I use Java 8 I am executing this code under Karaf OSGi.
The example I used works fine in a sample Java Class, but packing it in a bundle gives me this error ScriptEngineManager providers.next(): javax.script.ScriptEngineFactory: Provider jdk.nashorn.api.scripting.NashornScriptEngineFactory not found
When I look to the headers of the bundle, I see that the bundle imports javax.script,
the package of the called classes but it seems that (nashorn) the provider is not found.
Thanks
Share Improve this question asked May 31, 2016 at 20:58 Ali Ben MessaoudAli Ben Messaoud 11.9k8 gold badges57 silver badges88 bronze badges2 Answers
Reset to default 7Go to file etc/config.properties (located inside of Karaf installation), find configuration property org.osgi.framework.bootdelegation and add jdk.nashorn.* to it. Complete configuration will be like this:
org.osgi.framework.bootdelegation=org.apache.karaf.jaas.boot,org.apache.karaf.jaas.boot.principal,sun.*,.sun.*,javax.transaction,javax.transaction.*,javax.xml.crypto,javax.xml.crypto.*,org.apache.xerces.jaxp.datatype,org.apache.xerces.stax,org.apache.xerces.parsers,org.apache.xerces.jaxp,org.apache.xerces.jaxp.validation,org.apache.xerces.dom,sun.*,jdk.nashorn.*
Bug is reported to Karaf munity.
Edit: If you use Pax Exam Container 4.x for Karaf in your tests then don't forget to add org.ops4j.pax.exam.CoreOptions.bootDelegationPackage("jdk.nashorn.*")
to the configuration of your test container.
You'll need to make sure you have a bundle or the system to actually export those packages in question:
So either install the corresponding bundle, or you need to tweak on the exports of the system bundle, in that case edit the jre.properties and make sure the package in question is exported from the system bundle.
本文标签:
版权声明:本文标题:javascript - ScriptEngineManager and ScriptEngine can not be loaded in Karaf OSGi (Nashorn not found) - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744482329a2608243.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论