Unable to evaluate script: TypeError: <html>

Hi,

I’m trying to call a decision table held in the cloud. I’ve been able to call the service correctly using hard coded values in the payload as seen here:-

And thanks to Stephen Russett who helped me out enormously with his blog post I was able to process the response back from the decision table. Using the following output parameter:

However when I tried to parameterze the request payload using the following:-

var estacion = execution.getVariable("season");
var num_de_invitados = execution.getVariable("guestCount");
var obj = {"variables": {"season": {"value":estacion,"type":"String"}, "guestCount":{"value":num_de_invitados,"type":"String"} }};
var payload = JSON.stringify(obj);

I get the following error message from the tsklist:-

The process could not be started. :
Cannot instantiate process definition DinnerCall:23:9164ca80-fa09-11e6-b584-a0a8cd4879e9: Unable to evaluate script: TypeError: Internal Server Error has no such function "elements" in at line number 1

Looking at the contents of the logs shows the following:-

23-Feb-2017 20:49:55.348 SEVERE [http-apr-8080-exec-37] org.camunda.commons.logging.BaseLogger.logError ENGINE-16006 BPMN Stack Trace:
	ServiceTask_1e3x7bo (activity-execute, ProcessInstance[a1290bc1-fa09-11e6-b584-a0a8cd4879e9], pa=Dinner Rest Call App2)
	ServiceTask_1e3x7bo
	  ^
	  |
	StartEvent_1

23-Feb-2017 20:49:55.349 SEVERE [http-apr-8080-exec-37] org.camunda.commons.logging.BaseLogger.logError ENGINE-16004 Exception while closing command context: Unable to evaluate script: TypeError: <html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Error</title>
</head>
<body>Internal Server Error</body>
</html>
 has no such function "elements" in <eval> at line number 1
 org.camunda.bpm.engine.ScriptEvaluationException: Unable to evaluate script: TypeError: <html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Error</title>
</head>
<body>Internal Server Error</body>
</html>
 has no such function "elements" in <eval> at line number 1
	at org.camunda.bpm.engine.impl.scripting.SourceExecutableScript.evaluateScript(SourceExecutableScript.java:119)
	at org.camunda.bpm.engine.impl.scripting.SourceExecutableScript.evaluate(SourceExecutableScript.java:60)
	at org.camunda.bpm.engine.impl.scripting.ExecutableScript.execute(ExecutableScript.java:56)
	at org.camunda.bpm.engine.impl.scripting.env.ScriptingEnvironment.execute(ScriptingEnvironment.java:97)

Which seems to be having an issue with elements used to process the Rest response which was working fine before the introduction of the inline javascript code in the input parameter.

Anybody got any pointers?

Many TIA,

Anthony

Hi Anthony,

I would insert a

print("Payload: " + payload);

before the end of the payload-script (and return the var afterwards) to inspect the call on the server console. If you run Java 7, you have to write

println("...");

I assume that the decison engine didn’t understand the request and returns an empty result.

Hope this helps, Ingo

Hi Ingo,

Thanks for the tip, I tried that by adding an intermediate step to the script like so

And then the code from local host server came out as:-

25-Feb-2017 19:42:51.869 INFO [localhost-startStop-10] org.apache.catalina.startup.HostConfig.deployWAR Deployment of web application archive C:\Users\Anthony\Documents\Software\Camunda-tomcat-MySQL-7.6.0\server\apache-tomcat-8.0.24\webapps\Dinner-call-rest-api2-0.1.0-SNAPSHOT.war has finished in 5,211 ms
Paylid: {"variables":{"season":{"value":"Winter","type":"String"},"guestCount":{"value":2,"type":"Integer"}}}

Which is fine, when I looked on the cloud server where the decision table is held, not so good, the call produced the following code:-

2017-02-25 14:43:02,900 ERROR [io.undertow.request] (default task-11) UT005023: Exception handling request to /engine-rest/decision-definition/key/dish/evaluate: org.jboss.resteasy.spi.UnhandledException: java.lang.NullPointerException
        at org.jboss.resteasy.core.ExceptionHandler.handleApplicationException(ExceptionHandler.java:77)
        at org.jboss.resteasy.core.ExceptionHandler.handleException(ExceptionHandler.java:220)
        at org.jboss.resteasy.core.SynchronousDispatcher.writeException(SynchronousDispatcher.java:175)
        at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:418)
        at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:209)
        at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:221)
        at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:56)
        at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:51)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
        at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85)
        at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129)
        at org.camunda.bpm.engine.rest.filter.CacheControlFilter.doFilter(CacheControlFilter.java:41)
        at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
        at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
        at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84)
        at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
        at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
        at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
        at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131)
        at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
        at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
        at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)
        at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)
        at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77)
        at io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50)
        at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)
        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
        at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
        at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:292)
        at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:81)
        at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:138)
        at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:135)
        at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48)
        at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
        at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
        at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
        at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
        at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
        at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
        at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:272)
        at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81)
        at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:104)
        at io.undertow.server.Connectors.executeRootHandler(Connectors.java:202)
        at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:805)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NullPointerException
        at org.camunda.bpm.engine.rest.sub.repository.impl.DecisionDefinitionResourceImpl.evaluateDecision(DecisionDefinitionResourceImpl.java:130)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:139)
        at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:295)
        at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:249)
        at org.jboss.resteasy.core.ResourceLocatorInvoker.invokeOnTargetObject(ResourceLocatorInvoker.java:138)
        at org.jboss.resteasy.core.ResourceLocatorInvoker.invoke(ResourceLocatorInvoker.java:107)
        at org.jboss.resteasy.core.ResourceLocatorInvoker.invokeOnTargetObject(ResourceLocatorInvoker.java:133)
        at org.jboss.resteasy.core.ResourceLocatorInvoker.invoke(ResourceLocatorInvoker.java:101)
        at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:402)
        ... 47 more

BTW, I removed the code to handle the response, it was probably complaining because there was nothing to process (my non-expert/non-technical opinion).

So it seems to me that payload variable is formed correctly, it’s just that the decision table is not receiving anything for this value (remember it was receiving the payload when the payload was a text type and hard-coded and it worked too). So to me at least, the problem lies in how to set the variable for the payload, it doesn’t seem that having it set as the last variable in the script and having the name of the output variable seem to be enough.

Is there something really basic that any programmer should be doing that I’m not aware of?

Thanks,

Anthony

bumpty-bump bump bump