Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Equinox » Java8 javascript engine nashorn not found with BundleClassLoader
Java8 javascript engine nashorn not found with BundleClassLoader [message #1513544] Tue, 16 December 2014 16:33 Go to next message
Reto Urfer is currently offline Reto UrferFriend
Messages: 8
Registered: July 2009
Junior Member
Hi,

We use a JavaScript engine from within out application. With Java7 we could
just call
new ScriptEngineManager().getEngineByName("JavaScript")
to retrieve it.

Now with Java8 this does not work anymore. The ScriptEngineManager
constructor internally uses the context classloader to search all the
registered engines. In my case this was the bundle Classloader of the bundle
executing the code with the result that the engine is not found. I then
changed the code the following way
new ScriptEngineManager(null).getEngineByName("nashorn")
and everything was working fine anymore. In this case the system classloader
was used.

Can anybody explain me, why
new ScriptEngineManager().getEngineByName("nashorn")
is not working in case the context classloader is set to a bundle
classloader? Is the nashorn.jar located under jre/lib/ext not visible for
the OSGi bundle classloader and if yes, is there another way then calling
new ScriptEngineManager(null) to make it visible?

thanks
Reto
Re: Java8 javascript engine nashorn not found with BundleClassLoader [message #1517027 is a reply to message #1513544] Fri, 19 December 2014 07:47 Go to previous message
Reto Urfer is currently offline Reto UrferFriend
Messages: 8
Registered: July 2009
Junior Member
I have found a solution for the problem. The nashorn.jar is in only visible
for the extension classloader because its under lib/ext. Setting
osgi.parentClassloader=ext solves the problem.

"Reto Urfer" schrieb im Newsbeitrag news:m6pms8$auq$1@xxxxxxxxe.org...

Hi,

We use a JavaScript engine from within out application. With Java7 we could
just call
new ScriptEngineManager().getEngineByName("JavaScript")
to retrieve it.

Now with Java8 this does not work anymore. The ScriptEngineManager
constructor internally uses the context classloader to search all the
registered engines. In my case this was the bundle Classloader of the bundle
executing the code with the result that the engine is not found. I then
changed the code the following way
new ScriptEngineManager(null).getEngineByName("nashorn")
and everything was working fine anymore. In this case the system classloader
was used.

Can anybody explain me, why
new ScriptEngineManager().getEngineByName("nashorn")
is not working in case the context classloader is set to a bundle
classloader? Is the nashorn.jar located under jre/lib/ext not visible for
the OSGi bundle classloader and if yes, is there another way then calling
new ScriptEngineManager(null) to make it visible?

thanks
Reto
Previous Topic:Message about bundles not being resolved but they are running
Next Topic:Resolve dependency while install main bundle
Goto Forum:
  


Current Time: Fri Apr 19 01:14:58 GMT 2024

Powered by FUDForum. Page generated in 0.01813 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top