[jboss-jira] [JBoss JIRA] (WFCORE-719) JDK 1.8 javax.script.ScriptEngineFactory: Provider com.sun.script.javascript.RhinoScriptEngineFactory not found
Tomaz Cerar (JIRA)
issues at jboss.org
Thu May 28 06:46:02 EDT 2015
[ https://issues.jboss.org/browse/WFCORE-719?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Tomaz Cerar updated WFCORE-719:
-------------------------------
Fix Version/s: 2.0.0.Alpha3
> JDK 1.8 javax.script.ScriptEngineFactory: Provider com.sun.script.javascript.RhinoScriptEngineFactory not found
> ---------------------------------------------------------------------------------------------------------------
>
> Key: WFCORE-719
> URL: https://issues.jboss.org/browse/WFCORE-719
> Project: WildFly Core
> Issue Type: Enhancement
> Affects Versions: 2.0.0.Alpha2
> Reporter: Manuel Blechschmidt
> Assignee: Tomaz Cerar
> Labels: JS223, JavaScript, Scripting
> Fix For: 2.0.0.Alpha3
>
>
> When using the ScriptManager in a JSF bean the following happens:
> ERROR [stderr] (default task-21) ScriptEngineManager providers.next(): javax.script.ScriptEngineFactory: Provider com.sun.script.javascript.RhinoScriptEngineFactory not found
> {code}
> package de.example.log.jsf;
> import java.io.ByteArrayOutputStream;
> import java.io.IOException;
> import java.io.PrintStream;
> import javax.enterprise.inject.Model;
> import javax.faces.application.FacesMessage;
> import javax.faces.context.FacesContext;
> import javax.inject.Inject;
> import javax.script.Bindings;
> import javax.script.ScriptEngine;
> import javax.script.ScriptEngineManager;
> import javax.script.ScriptException;
> @Model
> public class Scripting {
> private String script;
> private String output;
> private ScriptEngineManager mgr = new ScriptEngineManager();
> public static String utilJavaScript = "var print = function (s) { __newOut.print(s); }; var println = function (s) { __newOut.println(s); };";
> public String execute() {
> ScriptEngine jsEngine = mgr.getEngineByName("JavaScript");
> ByteArrayOutputStream outputBuffer = new ByteArrayOutputStream(8192);
> PrintStream newOut = new PrintStream(outputBuffer, true);
> Bindings bindings = jsEngine.createBindings();
> bindings.put("__newOut", newOut);
> try {
> jsEngine.eval(utilJavaScript + getScript(), bindings);
> } catch (ScriptException from) {
> FacesContext.getCurrentInstance().addMessage(
> null,
> new FacesMessage(from.getColumnNumber() + " "
> + from.getFileName() + " " + from.getLineNumber()
> + " " + from.getMessage()));
> return null;
> }
> newOut.close();
> String returnString = outputBuffer.toString();
> setOutput(returnString);
> try {
> outputBuffer.close();
> } catch (IOException e) {
> FacesContext.getCurrentInstance().addMessage(
> null,
> new FacesMessage(e.getLocalizedMessage()));
> }
> return null;
> }
> public String getScript() {
> return script;
> }
> public void setScript(String script) {
> this.script = script;
> }
> public String getOutput() {
> return output;
> }
> public void setOutput(String output) {
> this.output = output;
> }
> }
> {code}
> The script engines are configured in the following file:
> WILDFLY_HOME/modules/system/layers/base/sun/jdk/main/service-loader-resources/META-INF/services/javax.script.ScriptEngineFactory
> {code}
> com.sun.script.javascript.RhinoScriptEngineFactory
> jdk.nashorn.api.scripting.NashornScriptEngineFactory
> {code}
> It should be made sure that with every JDK JSR 223 compliant requests for a JavaScript engine will work out of the box.
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)
More information about the jboss-jira
mailing list