different error response body from REST API since upgrade from 5.16.3 to 5.17
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-30-2015 04:47 AM
Hi,
I throw exceptions from a (groovy)scripttask when userform input in a usertask is not valid.
Since i'm running activiti 5.17 (with jetty) the error response body no longer returns jsonobjects when I throw an exception from a scripttask to a usertask.
Anybody else has this problem?
thanks in advance
,
grts,
Yannick
I throw exceptions from a (groovy)scripttask when userform input in a usertask is not valid.
Since i'm running activiti 5.17 (with jetty) the error response body no longer returns jsonobjects when I throw an exception from a scripttask to a usertask.
Anybody else has this problem?
thanks in advance

grts,
Yannick
Labels:
- Labels:
-
Archive
7 REPLIES 7
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-30-2015 04:18 PM
Can you give an example of what was working in 5.16.3 and now isn't anymore? The groovy script is probably the most interesting, and then which call you typically do to get that exception as json object.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-01-2015 04:02 AM
I made a simple example (see exampleprocess.bpmn20.xml)
This is the script:
if (var1 != 'ok'){throw new Exception ('<error>correct value for var1 is: ok</error>')}
And the task is completed witht the REST API:
POST /activiti-rest/service/form/form-data
{
"taskId" : "${taskid}",
"properties" : [
{
"id" : "var1",
"value" : "notok"
}
]
}
thanks
This is the script:
if (var1 != 'ok'){throw new Exception ('<error>correct value for var1 is: ok</error>')}
And the task is completed witht the REST API:
POST /activiti-rest/service/form/form-data
{
"taskId" : "${taskid}",
"properties" : [
{
"id" : "var1",
"value" : "notok"
}
]
}
thanks

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-03-2015 04:30 AM
Ok, tried it here. The stacktrace was pretty clear:
<code>
rg.activiti.engine.ActivitiException: Can't find scripting engine for 'Groovy'
at org.activiti.engine.impl.scripting.ScriptingEngines.getEngineByName(ScriptingEngines.java:124)
at org.activiti.engine.impl.scripting.ScriptingEngines.evaluate(ScriptingEngines.java:85)
at org.activiti.engine.impl.scripting.ScriptingEngines.evaluate(ScriptingEngines.java:73)
at org.activiti.engine.impl.bpmn.behavior.ScriptTaskActivityBehavior.execute(ScriptTaskActivityBehavior.java:62)
at org.activiti.engine.impl.pvm.runtime.AtomicOperationActivityExecute.execute(AtomicOperationActivityExecute.java:60)
at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:96)
at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:633)
at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:626)
at org.activiti.engine.impl.pvm.runtime.AtomicOperationTransitionNotifyListenerStart.eventNotificationsCompleted(AtomicOperationTransitionNotifyListenerStart.java:52)
at org.activiti.engine.impl.pvm.runtime.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:56)
at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:96)
at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:633)
at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:626)
at org.activiti.engine.impl.pvm.runtime.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:49)
at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:96)
at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:633)
at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:626)
at org.activiti.engine.impl.pvm.runtime.AtomicOperationTransitionCreateScope.execute(AtomicOperationTransitionCreateScope.java:49)
at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:96)
</code>
The 5.17 does NOT ship with Groovy-all (which is needed to have the scripting engine). I don't recall why we removed it, but there would have been some thought in that. Or not, I'll follow up on that. Anyway, add the groovy-all jar to your Jetty classpath (see http://mvnrepository.com/artifact/org.codehaus.groovy/groovy-all/2.4.3) and you should be fine.
<code>
rg.activiti.engine.ActivitiException: Can't find scripting engine for 'Groovy'
at org.activiti.engine.impl.scripting.ScriptingEngines.getEngineByName(ScriptingEngines.java:124)
at org.activiti.engine.impl.scripting.ScriptingEngines.evaluate(ScriptingEngines.java:85)
at org.activiti.engine.impl.scripting.ScriptingEngines.evaluate(ScriptingEngines.java:73)
at org.activiti.engine.impl.bpmn.behavior.ScriptTaskActivityBehavior.execute(ScriptTaskActivityBehavior.java:62)
at org.activiti.engine.impl.pvm.runtime.AtomicOperationActivityExecute.execute(AtomicOperationActivityExecute.java:60)
at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:96)
at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:633)
at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:626)
at org.activiti.engine.impl.pvm.runtime.AtomicOperationTransitionNotifyListenerStart.eventNotificationsCompleted(AtomicOperationTransitionNotifyListenerStart.java:52)
at org.activiti.engine.impl.pvm.runtime.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:56)
at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:96)
at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:633)
at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:626)
at org.activiti.engine.impl.pvm.runtime.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:49)
at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:96)
at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:633)
at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:626)
at org.activiti.engine.impl.pvm.runtime.AtomicOperationTransitionCreateScope.execute(AtomicOperationTransitionCreateScope.java:49)
at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:96)
</code>
The 5.17 does NOT ship with Groovy-all (which is needed to have the scripting engine). I don't recall why we removed it, but there would have been some thought in that. Or not, I'll follow up on that. Anyway, add the groovy-all jar to your Jetty classpath (see http://mvnrepository.com/artifact/org.codehaus.groovy/groovy-all/2.4.3) and you should be fine.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-03-2015 04:57 AM
Well I have the Groovy-all in my classpath.
I think my question was a little unclear. Allow me to explain it more elaborate:
The thing is that I want to create a stacktrace/exception. In this example it looks like this:
10:40:19,292 [qtp966396367-12] WARN org.activiti.engine.impl.bpmn.behavior.ScriptTaskActivityBehavior - Exception while executing sid-01B97437-D665-477F-B56A-BF4DF2BF5EF4 : problem evaluating script: javax.script.ScriptException: java.lang.Exception: correct value for var1 is: ok
2015-07-03 10:40:19.332:WARN
ejs.ServletHandler:qtp966396367-12:
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.activiti.engine.ActivitiException: problem evaluating script: javax.script.ScriptException: java.lang.Exception: correct value for var1 is: ok
This is what I actually want because I use this exception message to communicate the result of the inputvalidation to the frontend.
I used to get a JSON respons that looked like this:
{
"statusCode" :500 ,
"errorMessage" : "correct value for var1 is: ok'."
}
Now I still get the exception which is great, but instead of a jsonstring I get a html blob with the stacktrace.
thanks again for all your help
I think my question was a little unclear. Allow me to explain it more elaborate:
The thing is that I want to create a stacktrace/exception. In this example it looks like this:
10:40:19,292 [qtp966396367-12] WARN org.activiti.engine.impl.bpmn.behavior.ScriptTaskActivityBehavior - Exception while executing sid-01B97437-D665-477F-B56A-BF4DF2BF5EF4 : problem evaluating script: javax.script.ScriptException: java.lang.Exception: correct value for var1 is: ok
2015-07-03 10:40:19.332:WARN

org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.activiti.engine.ActivitiException: problem evaluating script: javax.script.ScriptException: java.lang.Exception: correct value for var1 is: ok
This is what I actually want because I use this exception message to communicate the result of the inputvalidation to the frontend.
I used to get a JSON respons that looked like this:
{
"statusCode" :500 ,
"errorMessage" : "correct value for var1 is: ok'."
}
Now I still get the exception which is great, but instead of a jsonstring I get a html blob with the stacktrace.
thanks again for all your help

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-03-2015 10:59 AM
Ah, now I understand.
That's indeed currently not happening. I've fixed it on master: https://github.com/Activiti/Activiti/commit/2e0d0b3b23945e86e2f11f7a98540e750fdfad6e
You could work around it with the current release, by having a ControllerAdvice (in the org.activiti.rest.exceptio package) on your classpath with the method I added:
<code>
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) // 500
@ExceptionHandler(Exception.class)
@ResponseBody
public ErrorInfo handleOtherException(Exception e) {
return new ErrorInfo("Internal server error", e);
}
</code>
It's my hope Spring would pick up multiple advices…. but haven't tried it.
That's indeed currently not happening. I've fixed it on master: https://github.com/Activiti/Activiti/commit/2e0d0b3b23945e86e2f11f7a98540e750fdfad6e
You could work around it with the current release, by having a ControllerAdvice (in the org.activiti.rest.exceptio package) on your classpath with the method I added:
<code>
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) // 500
@ExceptionHandler(Exception.class)
@ResponseBody
public ErrorInfo handleOtherException(Exception e) {
return new ErrorInfo("Internal server error", e);
}
</code>
It's my hope Spring would pick up multiple advices…. but haven't tried it.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-06-2015 03:40 AM
Thanks a lot!
We will try it out and post the results here.
keep u posted!
We will try it out and post the results here.

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-11-2015 04:59 AM
works in 5.18!
thanks again
thanks again

