Package javax.script

Examples of javax.script.ScriptException


            StAXOMBuilder builder = new StAXOMBuilder(
                new ByteArrayInputStream(scriptXML.toString().getBytes()));
            return builder.getDocumentElement();

        } catch (XMLStreamException e) {
            throw new ScriptException(e);
        }
    }
View Full Code Here


            byte[] xmlBytes = scriptXML.toString().getBytes();
            StAXOMBuilder builder = new StAXOMBuilder(new ByteArrayInputStream(xmlBytes));
            return builder.getDocumentElement();

        } catch (Exception e) {
            throw new ScriptException(e);
        }
    }
View Full Code Here

    protected ScriptEngine getScriptEngine() throws ScriptException {
        final String lang = getScriptLanguage();

        ScriptEngine scriptEngine = getInstance().getEngineByName(lang);
        if (scriptEngine == null) {
            throw new ScriptException("Cannot find engine named: '"+lang+"', ensure you set language field in JSR223 Test Element:"+getName());
        }

        return scriptEngine;
    }
View Full Code Here

                    }
                } finally {
                    IOUtils.closeQuietly(fileReader);
                }
            }  else {
                throw new ScriptException("Script file '"+scriptFile.getAbsolutePath()+"' does not exist or is unreadable for element:"+getName());
            }
        } else if (!StringUtils.isEmpty(getScript())){
            if (supportsCompilable && !StringUtils.isEmpty(cacheKey)) {
                CompiledScript compiledScript =
                        compiledScriptsCache.get(cacheKey);
                if (compiledScript==null) {
                    synchronized (compiledScriptsCache) {
                        compiledScript =
                                compiledScriptsCache.get(cacheKey);
                        if (compiledScript==null) {
                            compiledScript =
                                    ((Compilable) scriptEngine).compile(getScript());
                            compiledScriptsCache.put(cacheKey, compiledScript);
                        }
                    }
                }
                return compiledScript.eval(bindings);
            } else {
                return scriptEngine.eval(getScript(), bindings);
            }
        } else {
            throw new ScriptException("Both script file and script text are empty for element:"+getName());           
        }
    }
View Full Code Here

   
    private static ScriptException transfer(PrivilegedActionException e) {
        if (e.getCause() instanceof ScriptException) {
            return (ScriptException) e.getCause();
        } else {
            return new ScriptException(e);
        }
    }
View Full Code Here

                ScriptEngineInitializer initializer = ScriptEngineFactory.getInitializer(language);
                String message = initializer.extractUserFriendlyErrorMessage(exceptionHolder.scriptException);
                int col = exceptionHolder.scriptException.getColumnNumber();
                int line = exceptionHolder.scriptException.getLineNumber();
                String scriptName = createSummary(config, "script $packageName ($packageVersion) in repo $repoName");
                throw new ScriptException(message, scriptName, line, col);
            } else if (exceptionHolder.throwable != null) {
                LOG.info("The script execution for CLI notification of alert [" + alert + "] failed.",
                    exceptionHolder.throwable);

                throw exceptionHolder.throwable;
View Full Code Here

        } catch (RhinoException re) {
            if (DEBUG) re.printStackTrace();
            int line = (line = re.lineNumber()) == 0 ? -1 : line;
            throw new ExtendedScriptException(re, re.toString(), re.sourceName(), line);
        } catch (IOException ee) {
            throw new ScriptException(ee);
        } finally {
            Context.exit();
        }
       
        return unwrapReturnValue(ret);
View Full Code Here

           
            Script scr = cx.compileReader(preProcessScriptSource(script), filename, 1, null);
            ret = new RhinoCompiledScript(this, scr);
        } catch (Exception e) {
            if (DEBUG) e.printStackTrace();
            throw new ScriptException(e);
        } finally {
            Context.exit();
        }
        return ret;
    }
View Full Code Here

    public ScriptAssertionException(Throwable cause) {
        super(cause);
    }

    public ScriptAssertionException(AssertionError error) {
        super(new ScriptException(error.getMessage()));
    }
View Full Code Here

                }, acc);
            } catch (PrivilegedActionException e) {
                if (e.getCause() instanceof ScriptException) {
                    throw (ScriptException) e.getCause();
                } else {
                    throw new ScriptException("Script execution failed.");
                }
            }
        }
    }
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.