Javascript ScriptingEngine not found with Java 1.8

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Javascript ScriptingEngine not found with Java 1.8

Volker Börchers
Administrator
Hi,

you may have recognized the message in the forum
(https://sourceforge.net/p/freeplane/discussion/758437/thread/f54a2253/#f77e 
) that states that Javascript scripts are not found.

I found out that this is an issue of Java 1.8: It works with Java 1.7
that came with com/sun/script/javascript/RhinoScriptEngine in lib/rt.jar
while Java 1.8 has jdk/nashorn/api/scripting/NashornScriptEngine in
lib/ext/nashorn.jar

Even with Java 1.8 the NashornScriptEngine can be found, but only with
the Standard Thread.currentThread().getContextClassLoader() of type
sun.misc.Launcher$AppClassLoader. Freeplane uses another ClassLoader for
scripts, GenericScript.class.getClassLoader() of type BundleClassLoader.
See getScriptEngineManager in Class GenericScript.

So it's an OSGI problem I suppose. Does anyone have an idea how to fix
it? Btw. the problem is the same in 1.3 and 1.4.

Regards,
Volker

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Javascript ScriptingEngine not found with Java 1.8

Dimitry Polivaev
Administrator
> I found out that this is an issue of Java 1.8: It works with Java 1.7
> that came with com/sun/script/javascript/RhinoScriptEngine in lib/rt.jar
> while Java 1.8 has jdk/nashorn/api/scripting/NashornScriptEngine in
> lib/ext/nashorn.jar
>

System.getProperty("java.ext.dirs")

returns all directories with extension jars e.g.

         (java.lang.String) C:\Program Files\Java\jdk1.8.0_60\jre\lib\ext;C:\WINDOWS\Sun\Java\lib\ext

Either all jar files inside extension directories or only nashorn.jar should be added to class
loader URLs in org.freeplane.plugin.script.GenericScript.createClassLoader() .

I think it is better to add them all.

Regards,
Dimitry

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Javascript ScriptingEngine not found with Java 1.8

Volker Börchers
Administrator
Hi Dimitry,

thank you. I have committed the fix to 1.5.x and cherry-picked that to
the 1.4.x branch. As the JavaFX library is also in java.ext.dirs scripts
will be able to use that too in the future.

https://github.com/freeplane/freeplane/commit/474a754461f027

Regards,
Volker

Am 21.11.2015 um 18:44 schrieb Dimitry Polivaev [via Freeplane Developer]:

>  > I found out that this is an issue of Java 1.8: It works with Java 1.7
>  > that came with com/sun/script/javascript/RhinoScriptEngine in lib/rt.jar
>  > while Java 1.8 has jdk/nashorn/api/scripting/NashornScriptEngine in
>  > lib/ext/nashorn.jar
>  >
>
> System.getProperty("java.ext.dirs")
>
> returns all directories with extension jars e.g.
>
>           (java.lang.String) C:\Program
> Files\Java\jdk1.8.0_60\jre\lib\ext;C:\WINDOWS\Sun\Java\lib\ext
>
> Either all jar files inside extension directories or only nashorn.jar
> should be added to class
> loader URLs in
> org.freeplane.plugin.script.GenericScript.createClassLoader() .
>
> I think it is better to add them all.
>
> Regards,
> Dimitry
>
>
>
> ------------------------------------------------------------------------
> If you reply to this email, your message will be added to the discussion
> below:
> http://freeplane-developer.996965.n3.nabble.com/Javascript-ScriptingEngine-not-found-with-Java-1-8-tp807p808.html
>
> To start a new topic under Freeplane Developer, email
> [hidden email]
> To unsubscribe from Freeplane Developer, click here
> <
> NAML
> <
http://freeplane-developer.996965.n3.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>
Loading...