Cannot Complete a task unless i upload a file

1,194 views
Skip to first unread message

Niall Deehan

unread,
Jan 22, 2016, 9:03:49 AM1/22/16
to camunda BPM users
Hello Everyone!

I've got an embedded form and on it i want to upload a file or not - i've added the upload stuff  but not i have the problem that if i don't choose to upload the file it throws an error - is this expected?

-Niall

thorben....@camunda.com

unread,
Jan 22, 2016, 9:50:29 AM1/22/16
to camunda BPM users
Hi Niall,

What kind of error do you see? Is it a client-side, Javascript error or a server-side error when completing the task?

Cheers,
Thorben

Niall Deehan

unread,
Jan 24, 2016, 7:56:42 AM1/24/16
to camunda BPM users
It doesn't seem to happen when i change the cam-variable-type to Bytes weirdly enough. But this is the stack trace from the server when i use File as a variable type:

2016-01-24 13:54:24,944 ERROR [io.undertow.request] (default task-53) UT005023: Exception handling request to /camunda/api/engine/engine/default/task/969b8f23-c299-11e5-97fb-5cc5d460bef9/submit-form: java.lang.RuntimeException: org.jboss.resteasy.spi.UnhandledException: java.lang.NullPointerException
    at org.camunda.bpm.webapp.impl.security.auth.AuthenticationFilter$1.execute(AuthenticationFilter.java:61) [classes:]
    at org.camunda.bpm.webapp.impl.security.auth.AuthenticationFilter$1.execute(AuthenticationFilter.java:56) [classes:]
    at org.camunda.bpm.webapp.impl.security.SecurityActions.runWithAuthentications(SecurityActions.java:38) [classes:]
    at org.camunda.bpm.webapp.impl.security.auth.AuthenticationFilter.doFilter(AuthenticationFilter.java:56) [classes:]
    at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:60) [undertow-servlet-1.1.8.Final.jar:1.1.8.Final]
    at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:132) [undertow-servlet-1.1.8.Final.jar:1.1.8.Final]
    at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:85) [undertow-servlet-1.1.8.Final.jar:1.1.8.Final]
    at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62) [undertow-servlet-1.1.8.Final.jar:1.1.8.Final]
    at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) [undertow-servlet-1.1.8.Final.jar:1.1.8.Final]
    at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) [undertow-core-1.1.8.Final.jar:1.1.8.Final]
    at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131) [undertow-servlet-1.1.8.Final.jar:1.1.8.Final]
    at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57) [undertow-servlet-1.1.8.Final.jar:1.1.8.Final]
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) [undertow-core-1.1.8.Final.jar:1.1.8.Final]
    at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46) [undertow-core-1.1.8.Final.jar:1.1.8.Final]
    at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64) [undertow-servlet-1.1.8.Final.jar:1.1.8.Final]
    at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:58) [undertow-core-1.1.8.Final.jar:1.1.8.Final]
    at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:70) [undertow-servlet-1.1.8.Final.jar:1.1.8.Final]
    at io.undertow.security.handlers.SecurityInitialHandler.handleRequest(SecurityInitialHandler.java:76) [undertow-core-1.1.8.Final.jar:1.1.8.Final]
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) [undertow-core-1.1.8.Final.jar:1.1.8.Final]
    at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) [undertow-core-1.1.8.Final.jar:1.1.8.Final]
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) [undertow-core-1.1.8.Final.jar:1.1.8.Final]
    at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:261) [undertow-servlet-1.1.8.Final.jar:1.1.8.Final]
    at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:248) [undertow-servlet-1.1.8.Final.jar:1.1.8.Final]
    at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:77) [undertow-servlet-1.1.8.Final.jar:1.1.8.Final]
    at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:167) [undertow-servlet-1.1.8.Final.jar:1.1.8.Final]
    at io.undertow.server.Connectors.executeRootHandler(Connectors.java:199) [undertow-core-1.1.8.Final.jar:1.1.8.Final]
    at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:761) [undertow-core-1.1.8.Final.jar:1.1.8.Final]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [rt.jar:1.8.0_45]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [rt.jar:1.8.0_45]
    at java.lang.Thread.run(Thread.java:745) [rt.jar:1.8.0_45]
Caused by: org.jboss.resteasy.spi.UnhandledException: java.lang.NullPointerException
    at org.jboss.resteasy.core.ExceptionHandler.handleApplicationException(ExceptionHandler.java:76) [resteasy-jaxrs-3.0.10.Final.jar:]
    at org.jboss.resteasy.core.ExceptionHandler.handleException(ExceptionHandler.java:212) [resteasy-jaxrs-3.0.10.Final.jar:]
    at org.jboss.resteasy.core.SynchronousDispatcher.writeException(SynchronousDispatcher.java:149) [resteasy-jaxrs-3.0.10.Final.jar:]
    at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:372) [resteasy-jaxrs-3.0.10.Final.jar:]
    at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:179) [resteasy-jaxrs-3.0.10.Final.jar:]
    at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:220) [resteasy-jaxrs-3.0.10.Final.jar:]
    at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:56) [resteasy-jaxrs-3.0.10.Final.jar:]
    at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:51) [resteasy-jaxrs-3.0.10.Final.jar:]
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) [jboss-servlet-api_3.1_spec-1.0.0.Final.jar:1.0.0.Final]
    at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:86) [undertow-servlet-1.1.8.Final.jar:1.1.8.Final]
    at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:130) [undertow-servlet-1.1.8.Final.jar:1.1.8.Final]
    at org.camunda.bpm.engine.rest.filter.CacheControlFilter.doFilter(CacheControlFilter.java:41) [camunda-engine-rest-7.4.0-ee-classes.jar:7.4.0-ee]
    at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:60) [undertow-servlet-1.1.8.Final.jar:1.1.8.Final]
    at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:132) [undertow-servlet-1.1.8.Final.jar:1.1.8.Final]
    at org.camunda.bpm.webapp.impl.security.filter.SecurityFilter.doFilterSecure(SecurityFilter.java:67) [classes:]
    at org.camunda.bpm.webapp.impl.security.filter.SecurityFilter.doFilter(SecurityFilter.java:51) [classes:]
    at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:60) [undertow-servlet-1.1.8.Final.jar:1.1.8.Final]
    at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:132) [undertow-servlet-1.1.8.Final.jar:1.1.8.Final]
    at org.camunda.bpm.webapp.impl.security.auth.AuthenticationFilter$1.execute(AuthenticationFilter.java:59) [classes:]
    ... 31 more
Caused by: java.lang.NullPointerException
    at org.camunda.bpm.engine.variable.impl.type.FileValueTypeImpl.createValue(FileValueTypeImpl.java:44) [camunda-commons-typed-values-1.2.0.jar:1.2.0]
    at org.camunda.bpm.engine.rest.dto.VariableValueDto.toTypedValue(VariableValueDto.java:118) [camunda-engine-rest-7.4.0-ee-classes.jar:7.4.0-ee]
    at org.camunda.bpm.engine.rest.dto.VariableValueDto.toMap(VariableValueDto.java:147) [camunda-engine-rest-7.4.0-ee-classes.jar:7.4.0-ee]
    at org.camunda.bpm.engine.rest.sub.task.impl.TaskResourceImpl.submit(TaskResourceImpl.java:108) [camunda-engine-rest-7.4.0-ee-classes.jar:7.4.0-ee]
    at sun.reflect.GeneratedMethodAccessor1115.invoke(Unknown Source) [:1.8.0_45]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.8.0_45]
    at java.lang.reflect.Method.invoke(Method.java:497) [rt.jar:1.8.0_45]
    at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:137) [resteasy-jaxrs-3.0.10.Final.jar:]
    at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:296) [resteasy-jaxrs-3.0.10.Final.jar:]
    at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:250) [resteasy-jaxrs-3.0.10.Final.jar:]
    at org.jboss.resteasy.core.ResourceLocatorInvoker.invokeOnTargetObject(ResourceLocatorInvoker.java:140) [resteasy-jaxrs-3.0.10.Final.jar:]
    at org.jboss.resteasy.core.ResourceLocatorInvoker.invoke(ResourceLocatorInvoker.java:109) [resteasy-jaxrs-3.0.10.Final.jar:]
    at org.jboss.resteasy.core.ResourceLocatorInvoker.invokeOnTargetObject(ResourceLocatorInvoker.java:135) [resteasy-jaxrs-3.0.10.Final.jar:]
    at org.jboss.resteasy.core.ResourceLocatorInvoker.invoke(ResourceLocatorInvoker.java:103) [resteasy-jaxrs-3.0.10.Final.jar:]
    at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:356) [resteasy-jaxrs-3.0.10.Final.jar:]
    ... 46 more

thorben....@camunda.com

unread,
Jan 25, 2016, 2:45:23 AM1/25/16
to camunda BPM users
Hi Niall,

Thanks for the stacktrace. I created a bug ticket [1]. However, the request is invalid as well. It appears that the valueInfo property for the file value variable is not set (confer the documentation [2]). I'm not familiar with the forms SDK, so I'm not sure if this is a bug there or in the way you use it. Perhaps Sebastian Stamm can shed some light on this.

Cheers,
Thorben

[1] https://app.camunda.com/jira/browse/CAM-5292
[2] https://docs.camunda.org/manual/latest/reference/rest/task/post-submit-form/

Sebastian Stamm

unread,
Jan 25, 2016, 3:14:16 AM1/25/16
to camunda BPM users
Hi Niall,

I had a look at the issue and can share some insights: Whenever you have a input field with the cam-variable-name and cam-variable-type fields set, it tries to create a process instance variable with that name and type when you submit the form. When you do not select a file, it cannot create this variable (as it needs a filename).

So you have two options: You could either not use the cam-variable-name directive [1], or you could delete the variable before submitting the form (similar to [2], but instead of adding a variable to the variableManager, you would remove the existing entry for the file, if no file has been provided).

Cheers
Sebastian

stephan...@de.rhenus.com

unread,
Feb 17, 2016, 5:23:45 AM2/17/16
to camunda BPM users
Hello Sebastian,

I have the same problem and tried to destroy the variable but it ends in another error: "The process could not be started. : n is undefined". It seems to be a problem on the client side, because I see nothing in the server log.

In my embedded form I use the following code (just as a test):

camForm.on('submit', function() {
variableManager.destroyVariable('document1');
});

Can you give me a hint what I do wrong?

Regards,
Stephan

Sebastian Stamm

unread,
Feb 17, 2016, 7:37:16 AM2/17/16
to camunda BPM users, stephan...@de.rhenus.com
Hi Stephan,

did you make the variableManager accessible as a local variable? If not, you have to access it via the camForm variable, e.g. camForm.variableManager.destroyVariable()

Also, if you used the cam-variable-name directive for the file upload, you have to make sure to remove it from then list of registered fields in the camForm in the submit event handler. This would look something like this:

<script cam-script type="text/form-script">
  camForm.on('submit', function() {
      var fieldIdx = findFieldIdxFor('document1');
      camForm.fields.splice(fieldIdx, 1);
      camForm.variableManager.destroyVariable('document1');
  });
</script>

Cheers
Sebastian

stephan...@de.rhenus.com

unread,
Feb 17, 2016, 10:03:04 AM2/17/16
to camunda BPM users, stephan...@de.rhenus.com
Hi Sebastian,

thanks for the answer. Not it works for me!

I use the following code to filter all empty File inputs (just a prototype):

```javascript
camForm.fields = camForm.fields.filter(function(item) {

if( camForm.variableManager.variable(item.variableName).type === 'File'
&& document.getElementById(item.variableName).files.length === 0 ) {

camForm.variableManager.destroyVariable(item.variableName);

return false;
}
return true;
});
```

regards,
Stephan

Daniel Meyer

unread,
Mar 10, 2016, 5:42:37 AM3/10/16
to camunda BPM users, stephan...@de.rhenus.com
Reply all
Reply to author
Forward
0 new messages