SYMPTOM

A process uses the API __ctx__.executeCommand("...").

The execution is OK from the Designer or from the Runtime's Scheduler.

But the execution fails from a startdelivery.bat (or startdelivery.sh) command.

Possible errors are :

javax.script.ScriptException: sun.org.mozilla.javascript.internal.WrappedException: Wrapped java.lang.NullPointerException (<Unknown source>#3) in <Unknown source> at line number 3
                at com.sun.script.javascript.RhinoScriptEngine.eval(RhinoScriptEngine.java:156)
                at com.sun.script.javascript.RhinoScriptEngine.eval(RhinoScriptEngine.java:170)
                at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:247)
                at com.indy.engine.actionCodes.ScriptingActionCodeI.executeCodewithRSet(SourceFile:151)
                at com.indy.engine.actionCodes.ScriptingActionCodeI.executeSimpleCode(SourceFile:323)
                at com.indy.engine.action.common.ActionCodeTypeI.executeCode(SourceFile:1646)
                at com.indy.engine.action.common.ActionCodeTypeI.run(SourceFile:1805)
                at java.lang.Thread.run(Thread.java:738)

or :

java.lang.NullPointerException
        at com.indy.engine.command.l.execute(SourceFile:1598)
        at com.indy.engine.command.parser.CommandLineParserI.executeCommandLine(CommandLineParserI.java:51)
        at com.indy.engine.command.a.b(SourceFile:2118)
        at com.indy.engine.main.scripting.ScriptContextI.a(SourceFile:413)
        at com.indy.engine.main.scripting.ScriptContextI.executeCommand(SourceFile:404)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at sun.org.mozilla.javascript.internal.MemberBox.invoke(MemberBox.java:167)
        at sun.org.mozilla.javascript.internal.NativeJavaMethod.call(NativeJavaMethod.java:245)
        at sun.org.mozilla.javascript.internal.Interpreter.interpretLoop(Interpreter.java:1706)
        at sun.org.mozilla.javascript.internal.Interpreter.interpret(Interpreter.java:849)
        at sun.org.mozilla.javascript.internal.InterpretedFunction.call(InterpretedFunction.java:162)
        at sun.org.mozilla.javascript.internal.ContextFactory.doTopCall(ContextFactory.java:430)
        at com.sun.script.javascript.RhinoScriptEngine$1.superDoTopCall(RhinoScriptEngine.java:116)
        at com.sun.script.javascript.RhinoScriptEngine$1.doTopCall(RhinoScriptEngine.java:109)
        at sun.org.mozilla.javascript.internal.ScriptRuntime.doTopCall(ScriptRuntime.java:3160)
        at sun.org.mozilla.javascript.internal.InterpretedFunction.exec(InterpretedFunction.java:173)
        at sun.org.mozilla.javascript.internal.Context.evaluateReader(Context.java:1169)
        at com.sun.script.javascript.RhinoScriptEngine.eval(RhinoScriptEngine.java:214)
        at com.sun.script.javascript.RhinoScriptEngine.eval(RhinoScriptEngine.java:240)
        at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:264)
        at com.indy.engine.actionCodes.ScriptingActionCodeI.executeCodewithRSet(SourceFile:151)
        at com.indy.engine.actionCodes.ScriptingActionCodeI.executeSimpleCode(SourceFile:323)
        at com.indy.engine.action.common.ActionCodeTypeI.executeCode(SourceFile:1608)
        at com.indy.engine.action.common.ActionCodeTypeI.run(SourceFile:1767)
        at java.lang.Thread.run(Thread.java:745)

 

SOLUTION

The __ctx__ API can be used from any process, as long as it is executed in a live Runtime.

It cannot be used in the context of a standalone delivery (startdelivery).

Possible alternatives are :

1. Use __ctx__.executeRemoteCommand(<runtimeHostName>, <runtimePort>, <runtimeCommand>); instead of executeCommand(...)

2. Instead of startdelivery, use startcommand.bat "connect to <runtimeHostname> port <runtimePort>;execute delivery <deliveryName>"