ExternalTasks - fetchAndLock NullPointerException

Hi,
I want play with external tasks pattern but whenever I call fetchAndLock method I always receive HTTP 500:

{
“timestamp”: “2018-05-28T06:22:30.103+0000”,
“status”: 500,
“error”: “Internal Server Error”,
“message”: “No message available”,
“path”: “/rest/engine/default/external-task/fetchAndLock”
}

When I look at Camunda console I see NullPointerException when gathering FetchAndLockHandler from FetchAndLockRestServiceImpl:

java.lang.NullPointerException: null
at org.camunda.bpm.engine.rest.impl.FetchAndLockRestServiceImpl.fetchAndLock(FetchAndLockRestServiceImpl.java:34)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)

What am I doing wrong?

Which Camunda version do you use?

Newest one: 3.0.0.

Please check if you have the same problem with 2.3.0.

Same problem with version 2.3. I suspect some problems with my input.
Here is a post body:

{
“workerId”:“myWorker”,
“maxTasks”:23,
“topics”:
[{“topicName”: “DoSomething”,
“lockDuration”: 10000
}]
}
Unfortunately I’m unable to paste my diagram here due to newbie limitations

The request body looks fine to me and judging by the stacktrace it is not the request body that is the problem. Could you maybe share a minimal project on github with exact steps to reproduce the exception?

Thanks,
Thorben

The problem lies somewhere in the setup. The fetchAndLockHandler is never initialized in FetchAndLockContextListener, because listener is never added to the rest servlet. One solution is to produce a bean in a @Configuration class.

@Bean
public ServletContextListener fetchAndLockContextListener(){
 return new FetchAndLockContextListener();
}

But probably this is not a solution, rather a quick fix to move on.

Example @github

1 Like

Hi,

we’re currently investigating the issue and come back to you in a bit.

Cheers,
Tassilo

Hi Michał,
than you for reporting the issue, I’ve created the issue for it (https://app.camunda.com/jira/browse/CAM-9111) and will try to quickly fix it (within 3.0.0, which is not officially released yet :slight_smile: )

But your fix it totally fine, you can use it so far.

Cheers,
Svetlana

1 Like

Hi,

I use Camunda docker image (camunda/camunda-bpm-platform:tomcat-7.11.0) and I’m unable to use /external-task/fetchAndLock API as described above.

Can you please help me to get it work with my configuration ?

Thanks.

I am experiencing this as well on 7.11.3 since upgrading from 7.8. Were you able to resolve your issue ?

What exactly is going wrong?
Can you give us more information of exactly what you’re trying and how it’s failing?

Hi Niall!

I am making an api call to engine-rest/external-task/fetchAndLock
The body looks like this:

{“maxTasks”:300,“workerId”:“98e3f029-2345-4820-99ec-6a0dd298da53”,“usePriority”:false,“topics”:[{“topicName”:“xxxxxxxx”,“lockDuration”:30000,“variables”:[“y”]},{“topicName”:“yyyyy”,“lockDuration”:30000,“variables”:[“z”,“group”,“type”]},{“topicName”:“wwwwww”,“lockDuration”:20000,“variables”:[“a”,“b”]}]}

and the response is a 500 with {“type”:“NullPointerException”,“message”:null}

and in the logs I see

WARNING [http-nio-8080-exec-10] org.camunda.bpm.engine.rest.exception.ExceptionHandler.toResponse java.lang.NullPointerException
at org.camunda.bpm.engine.rest.impl.FetchAndLockRestServiceImpl.fetchAndLock(FetchAndLockRestServiceImpl.java:38)
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:140)
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:101) at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:406)
at org.jboss.resteasy.core.SynchronousDispatcher.invokePropagateNotFound(SynchronousDispatcher.java:251)
at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:232)
at org.jboss.resteasy.plugins.server.servlet.FilterDispatcher.doFilter(FilterDispatcher.java:62)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.camunda.engine.auth.jwt.JwtEngineAuthenticationFilter.doFilter(JwtEngineAuthenticationFilter.java:89)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.filters.CorsFilter.handleNonCORS(CorsFilter.java:352)
at org.apache.catalina.filters.CorsFilter.doFilter(CorsFilter.java:171)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.camunda.bpm.engine.rest.filter.CacheControlFilter.doFilter(CacheControlFilter.java:45)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.camunda.bpm.engine.rest.filter.EmptyBodyFilter.doFilter(EmptyBodyFilter.java:99)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:200)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:490)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:678)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:836)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1747)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)

Beyond changing the version of Camunda is there anything you else you changed before the call stopped working?
Also can you upload the full log file?

Hi @steel,

Additional to Niall questions, could you please share an example of your project so we can reproduce it on our side?

1 Like

@steel, keep in mind if you use an enterprise version, you can also raise a support issue

Thank you. I am going to get back with more info in the next day. I am going to start with a fresh install and test the end point and incrementally apply our changes where possible.

After some investigation it appears that the issue is related to an outdate web.xml in the engine-rest folder (due to maintaining our own customized version of this file).

We did not have the additional mappings for -

org.camunda.bpm.engine.rest.impl.FetchAndLockContextListener

It would be great if an error message could be generated to point to this missing config being a problem.

Thanks for the help!