Skip to content
This repository has been archived by the owner on Oct 18, 2020. It is now read-only.

No JavaScript Support #24

Closed
JesusMcCloud opened this issue Jul 5, 2015 · 7 comments
Closed

No JavaScript Support #24

JesusMcCloud opened this issue Jul 5, 2015 · 7 comments

Comments

@JesusMcCloud
Copy link

Tried running an Apache Pivot application, however this failed since no JavaScript engine can be found (this only happens using openjdk-unofficial-builds):

org.apache.pivot.serialization.SerializationException: An error occurred at line number 133 in file *****blanked****.xml:
at org.apache.pivot.beans.BXMLSerializer.logException(BXMLSerializer.java:1434)
at org.apache.pivot.beans.BXMLSerializer.readObject(BXMLSerializer.java:463)
at org.apache.pivot.beans.BXMLSerializer.readObject(BXMLSerializer.java:633)
at org.apache.pivot.beans.BXMLSerializer.readObject(BXMLSerializer.java:588)
at org.apache.pivot.beans.BXMLSerializer.readObject(BXMLSerializer.java:549)
at ***blanked***.App.startup(App.java:46)
at org.apache.pivot.wtk.DesktopApplicationContext$2.run(DesktopApplicationContext.java:641)
at org.apache.pivot.wtk.ApplicationContext$QueuedCallback.run(ApplicationContext.java:1656)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:312)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:745)
at java.awt.EventQueue.access$300(EventQueue.java:103)
at java.awt.EventQueue$3.run(EventQueue.java:706)
at java.awt.EventQueue$3.run(EventQueue.java:704)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:715)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
Caused by: org.apache.pivot.serialization.SerializationException: Script engine for "javascript" not found.
at org.apache.pivot.beans.BXMLSerializer.processEndElement(BXMLSerializer.java:1284)
at org.apache.pivot.beans.BXMLSerializer.readObject(BXMLSerializer.java:447)
... 20 more
@alexkasko
Copy link
Owner

Hi Bernd,

On 07/06/2015 12:20 AM, Bernd Prünster wrote:

Tried running an Apache Pivot application, however this failed since no JavaScript engine can be found (this only happens using openjdk-unofficial-builds):

Mozilla Rhino -
https://developer.mozilla.org/en-US/docs/Mozilla/Projects/Rhino , that
is used as a JavaScript engine in Oracle JDK, is not a part of OpenJDK
(is not included within its sources). I think that adding Rhino JAR to
classpath should solve this issue.

 org.apache.pivot.serialization.SerializationException: An error occurred at line number 133 in file *****blanked****.xml:

at org.apache.pivot.beans.BXMLSerializer.logException(BXMLSerializer.java:1434)
at org.apache.pivot.beans.BXMLSerializer.readObject(BXMLSerializer.java:463)
at org.apache.pivot.beans.BXMLSerializer.readObject(BXMLSerializer.java:633)
at org.apache.pivot.beans.BXMLSerializer.readObject(BXMLSerializer.java:588)
at org.apache.pivot.beans.BXMLSerializer.readObject(BXMLSerializer.java:549)
at _blanked_.App.startup(App.java:46)
at org.apache.pivot.wtk.DesktopApplicationContext$2.run(DesktopApplicationContext.java:641)
at org.apache.pivot.wtk.ApplicationContext$QueuedCallback.run(ApplicationContext.java:1656)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:312)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:745)
at java.awt.EventQueue.access$300(EventQueue.java:103)
at java.awt.EventQueue$3.run(EventQueue.java:706)
at java.awt.EventQueue$3.run(EventQueue.java:704)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:715)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
Caused by: org.apache.pivot.serialization.SerializationException: Script engine for "javascript" not found.
at org.apache.pivot.beans.BXMLSerializer.processEndElement(BXMLSerializer.java:1284)
at org.apache.pivot.beans.BXMLSerializer.readObject(BXMLSerializer.java:447)
... 20 more


Reply to this email directly or view it on GitHub:
#24

-Alex

@JesusMcCloud
Copy link
Author

Interesting. I thought these major differences were put aside with Java 7. I am on Arch Linux here and JS works fine on the OpenJDK available from the repositories (however, I do see a switch in the PKGBUILD for enabling rhino).
Anyway, simply adding my jar and the rhino to the classpath and then manually specifying the main class does not work. Therefore I suspect that some other magic is going on when building OpenJDK with rhino included.

@alexkasko
Copy link
Owner

On 07/06/2015 10:54 PM, Bernd Prünster wrote:

Interesting. I thought these major differences were put aside with Java 7. I am on Arch Linux here and JS works fine on the OpenJDK available from the repositories (however, I do see a switch in the PKGBUILD for enabling rhino).

Arch (and most other distros) uses IcedTea stuff to build OpenJDK and
IcedTea supports bundling Rhino.

Anyway, simply adding my jar and the rhino to the classpath and then manually specifying the main class does not work. Therefore I suspect that some other magic is going on when building OpenJDK with rhino included.

I never tried this myself, but it actually should, service-provider
logic (META-INF/services) should work out of the box with Rhino. Thanks
for the bugreport, I will look into it.


Reply to this email directly or view it on GitHub:
#24 (comment)

-Alex

@JesusMcCloud
Copy link
Author

js.jar (Rhino) does not include this file.

@alexkasko
Copy link
Owner

On 07/06/2015 11:46 PM, Bernd Prünster wrote:

js.jar (Rhino) does not include this file.

Yes, it seems that Rhino [1] never included JSR223 implementation
(ScriptEngine, service provider descriptor etc). Instead
com.sun.phobos.script.javascript.RhinoScriptEngineFactory was
implemented as part of java.net scripting project [2] and it can be
"baked into" Rhino jar during OpenJDK build time [3](I guess Arch
package does something similar). It is also included into Apache
commons-bsf library [4] so it can be used with vanilla Rhino and vanilla
OpenJDK (at least simple examples work for me) with the following Maven
deps:

 <dependency>
     <groupId>org.mozilla</groupId>
     <artifactId>rhino</artifactId>
     <version>1.7R4</version>
 </dependency>
 <dependency>
     <groupId>org.apache.bsf</groupId>
     <artifactId>bsf-all</artifactId>
     <version>3.0-beta3</version>
 </dependency>

Alternatively put these libs to /jre/lib/ext to have out of the box
JS support, direct links to libs: Rhino [5], bsf [6].

[1] https://developer.mozilla.org/en-US/docs/Mozilla/Projects/Rhino
[2] https://java.net/projects/scripting
[3]
https://wiki.openjdk.java.net/display/Nashorn/Using+Rhino+JSR-223+engine+with+JDK8
[4] https://commons.apache.org/proper/commons-bsf/
[5] http://central.maven.org/maven2/org/mozilla/rhino/1.7R4/rhino-1.7R4.jar
[6]
http://central.maven.org/maven2/org/apache/bsf/bsf-all/3.0-beta3/bsf-all-3.0-beta3.jar


Reply to this email directly or view it on GitHub:
#24 (comment)

-Alex

@JesusMcCloud
Copy link
Author

Everything works perfectly now!
Thank you so much for investing the time and for your detailed instructions!
You basically restored my faith in Java after slowly losing it over the last two years.

@alexkasko
Copy link
Owner

Glad to know that it is working, I'll add the note about JS support to readme.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants