Package javax.script

Examples of javax.script.ScriptException


    public Object eval(String script, ScriptContext ctx)
            throws ScriptException {
        try {
            Class clazz = getScriptClass(script);
            if (clazz == null) throw new ScriptException("Script class is null");
            return eval(clazz, ctx);
        } catch (SyntaxException e) {
            throw new ScriptException(e.getMessage(),
                    e.getSourceLocator(), e.getLine());
        } catch (Exception e) {
            if (debug) e.printStackTrace();
            throw new ScriptException(e);
        }
    }
View Full Code Here


    public CompiledScript compile(String scriptSource) throws ScriptException {
        try {
            return new GroovyCompiledScript(this,
                    getScriptClass(scriptSource));
        } catch (SyntaxException e) {
            throw new ScriptException(e.getMessage(),
                    e.getSourceLocator(), e.getLine());
        } catch (IOException e) {
            throw new ScriptException(e);
        } catch (CompilationFailedException ee) {
            throw new ScriptException(ee);
        }
    }
View Full Code Here

                });

                return scriptObject.run();
            }
        } catch (Exception e) {
            throw new ScriptException(e);
        } finally {
            // Fix for GROOVY-3669: Can't use several times the same JSR-223 ScriptContext for different groovy script
            // Groovy's scripting engine implementation adds those two variables in the binding
            // but should clean up afterwards
            ctx.removeAttribute("context", ScriptContext.ENGINE_SCOPE);
View Full Code Here

                return callGlobal(name, args);
            }
        } catch (MissingMethodException mme) {
            throw new NoSuchMethodException(mme.getMessage());
        } catch (Exception e) {
            throw new ScriptException(e);
        }
    }
View Full Code Here

        try {
            while ((numChars = reader.read(arr, 0, arr.length)) > 0) {
                buf.append(arr, 0, numChars);
            }
        } catch (IOException exp) {
            throw new ScriptException(exp);
        }
        return buf.toString();
    }
View Full Code Here

                System.err.println("no factory");
            }
            prepareMaps();
        } catch (Exception e) {
            e.printStackTrace();
            throw new ScriptException(e);
        }
    }
View Full Code Here

                e.printStackTrace((PrintWriter) w);
            } else {
                try {
                    w.write(e.getMessage());
                } catch (IOException ex) {
                    return new ScriptException(ex);
                }
            }
            return new ScriptException((Exception) e.getCause());
        } else {
            return new ScriptException(e);
        }
    }
View Full Code Here

            e.printStackTrace((PrintWriter) w);
        } else {
            try {
                w.write(e.getMessage());
            } catch (IOException ex) {
                return new ScriptException(ex);
            }
        }
        if (e.getCause() instanceof Exception) {
            return new ScriptException((Exception) e.getCause());
        } else {
            return new ScriptException(e);
        }
    }
View Full Code Here

        try {
            response = ((Invocable)scriptEngine).invokeFunction(oper.getName(), objects);
        } catch (ScriptException e) {
            throw e;
        } catch (Exception e) {
            throw new ScriptException(e);
        }

        if (xmlHelper != null) {
            response = xmlHelper.toOMElement(response);
        }
View Full Code Here

            if (filename == null) {
                filename = "<unknown>";
            }
            return runtime.parse(script, filename, null, 0);
        } catch (Exception exp) {
            throw new ScriptException(exp);
        } finally {
            if (oldGlobals != null) {
                //setGlobalVariables(oldGlobals);
            }
        }
View Full Code Here

TOP

Related Classes of javax.script.ScriptException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.