REST API not working with WAR deployment on Tomcat

Hi guys,

in order to run my application on Tomcat with the REST API I extended the Spring Boot example from the Get Started guides (Get started with Camunda and the Spring Boot | docs.camunda.org) as follows:

  • added dependency for REST starter
  • changed packaging to WAR
  • extended the SpringBootApplication class from SpringBootServletInitializer

When I execute the WAR everything works fine but when I deploy it on Tomcat the REST API is not working.

javax.servlet.ServletException: Servlet.init() for servlet org.camunda.bpm.spring.boot.starter.rest.CamundaJerseyResourceConfig threw exception
	org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
	org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
	org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
	org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:528)
	org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1099)
	org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:672)
	org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1520)
	org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1476)
	java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	java.lang.Thread.run(Thread.java:745)
root cause

java.lang.IllegalStateException: The resource configuration is not modifiable in this context.
	org.glassfish.jersey.server.ResourceConfig$ImmutableState.register(ResourceConfig.java:274)
	org.glassfish.jersey.server.ResourceConfig$ImmutableState.register(ResourceConfig.java:221)
	org.glassfish.jersey.server.ResourceConfig.register(ResourceConfig.java:453)
	org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:387)
	org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:177)
	org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:369)
	javax.servlet.GenericServlet.init(GenericServlet.java:158)
	org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
	org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
	org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
	org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:528)
	org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1099)
	org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:672)
	org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1520)
	org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1476)
	java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	java.lang.Thread.run(Thread.java:745)

Is that a known issue? Are there any workarounds?

Thanks and best regards
Thorsten

The same issue is reported here:

It works when I extend CamundaJerseyResourceConfig with my own RESTConfig:

@Component
@ApplicationPath("/resources")
public class RESTConfig extends CamundaJerseyResourceConfig {

}

In that case the API works with the base URL /resources/…
With /rest/… I still get the same error as mentioned before.

Hi @tvetter,
thank you for this information! I’m currently investigating this problem, it seems to be a bug somewhere.

Hi @tvetter,
FYI I created the bug for this: https://app.camunda.com/jira/browse/CAM-8414

1 Like

Hi @sdorokhova,
thanks for taking care of it.

Best regards
Thorsten

What is the status of this one, I saw the comment on CAM-8414:

“Packaging as WAR is currently not supported, so I am closing this issue.”

Dos that mean suggest is to use only jar packaging if REST starter is planning to be used?
i.e. do you have ticket in some backlog to support WAR packaging?

EDIT: In my case I use embedded process engine architecture with war packaging:

Hi,

Yes, you can only use any of the Camunda Spring Boot starters as a JAR deployment with embedded Tomcat.

No, we are not planning to support this deployment mode.

By the way, here is the relevant documentation that confirms this: Spring Boot Integration | docs.camunda.org

Cheers,
Thorben

1 Like

Hi @Jovan_Zoric,

when it is not officially supported, it doesn’t mean that wouldn’t work.

I’ve talked to customers that put some effort into building a spring boot application as a war file available for Wildfly, as this was the only production setup available in their company.

They had worked on the maven packaging and put the required deployment descriptors into the war file. But I didn’t get any other details.

TL;DR: it should be possible to setup a .war file with the CamundaSpringBootStartRest and an embedded engine.

Hope this helps, Ingo

1 Like