Tomcat installation of Camunda & REST API - cannot start REST API

Hey Camunders

I’ve installed the Tomcat distro of Camunda and it worked out really easily. Now trying to setup the REST API is proving more difficult.

Following the instructions from here:

I was not able to find a WAR file, so I’ve downloaded camunda-engine-rest-7.12.0-tomcat.war from Central Repository: org/camunda/bpm/camunda-engine-rest/7.12.0

I start up the WAR and see these errors in the logs:

18-Feb-2020 09:33:47.080 SEVERE [http-nio-8080-exec-79] org.apache.catalina.core.StandardContext.listenerStart Exception sending context initialized event to listener instance of class [org.camunda.bpm.engine.rest.impl.FetchAndLockContextListener]
	java.util.ServiceConfigurationError: org.camunda.bpm.engine.rest.spi.FetchAndLockHandler: Provider org.camunda.bpm.engine.rest.impl.FetchAndLockHandlerImpl could not be instantiated
		at java.base/java.util.ServiceLoader.fail(ServiceLoader.java:581)
		at java.base/java.util.ServiceLoader$ProviderImpl.newInstance(ServiceLoader.java:803)
		at java.base/java.util.ServiceLoader$ProviderImpl.get(ServiceLoader.java:721)
		at java.base/java.util.ServiceLoader$3.next(ServiceLoader.java:1394)
		at org.camunda.bpm.engine.rest.impl.FetchAndLockContextListener.lookupFetchAndLockHandler(FetchAndLockContextListener.java:57)
		at org.camunda.bpm.engine.rest.impl.FetchAndLockContextListener.contextInitialized(FetchAndLockContextListener.java:38)

Is there something I’m missing?
Thanks

Were you previously running camunda-bpm-tomcat-7.12.0.zip ?

This distribution already contains the rest api under
server\apache-tomcat-9.0.24\webapps\engine-rest

When working with different camunda distributions (wildfly, prepackage tomcat, docker, Spring boot,…) the rest base url can differ. Spring boot per default does not include the web root “camunda” and the rest API is deployed under “rest” only, so the url can be e.g. localhost:8080/rest or localhost:8080/camunda/engine-rest

Hi @rob2universe, thanks for the response.

Yes, I’m running the Camunda 7.12.0 Tomcat Standalone distro.

If i look at WEB-INF/web.xml, I see

  <servlet>
    <servlet-name>Engine Api</servlet-name>
    <servlet-class>org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher</servlet-class>
    <init-param>
      <param-name>javax.ws.rs.Application</param-name>
      <param-value>org.camunda.bpm.webapp.impl.engine.EngineRestApplication</param-value>
    </init-param>
    <init-param>
      <param-name>resteasy.servlet.mapping.prefix</param-name>
      <param-value>/api/engine</param-value>
    </init-param>
  </servlet>
  <servlet-mapping>
    <servlet-name>Engine Api</servlet-name>
    <url-pattern>/api/engine/*</url-pattern>
  </servlet-mapping>

Is this the embedded REST API? It doesn’t respond the way the REST API usually does though…

For example, if I query http://localhost:8080/camunda/api/engine/deployment, I receive:

< Content-Type: application/json
< Transfer-Encoding: chunked
< Date: Tue, 18 Feb 2020 09:16:12 GMT
< Connection: close
< 
* Closing connection 0
{"type":"NotFoundException","message":"Could not find resource for relative : /deployment of full path: http://localhost:8080/camunda/api/engine/deployment"}

On this prepackaged tomcat try: http://localhost:8080/engine-rest/process-definition

< Content-Type: text/html;charset=utf-8
< Content-Language: en
< Content-Length: 729
< Date: Tue, 18 Feb 2020 09:23:50 GMT
< 
* Connection #0 to host localhost left intact
<!doctype html><html lang="en"><head><title>HTTP Status 404 – Not Found</title><style type="text/css">body {font-family:Tahoma,Arial,sans-serif;} h1, h2, h3, b {color:white;background-color:#525D76;} h1 {font-size:22px;} h2 {font-size:16px;} h3 {font-size:14px;} p {font-size:12px;} a {color:black;} .line {height:1px;background-color:#525D76;border:none;}</style></head><body><h1>HTTP Status 404 – Not Found</h1><hr class="line" /><p><b>Type</b> Status Report</p><p><b>Message</b> &#47;engine-rest</p><p><b>Description</b> The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.</p><hr class="line" /><h3>Apache Tomcat/8.5.50 (Debian)</h3></body></html>

The pre-packaed tomcat camunda-bpm-tomcat-7.12.0 from https://camunda.org/release/camunda-bpm/tomcat/7.12/camunda-bpm-tomcat-7.12.0.zip or https://camunda.org/release/camunda-bpm/tomcat/7.12/camunda-bpm-tomcat-7.12.0.tar.gz uses tomcat version 9.0.24.0. Your stack shows “Apache Tomcat/8.5.50 (Debian)”. Are you working with the right server?

Oh! Interesting…

That dependency is not expressed clearly anywhere, from what I can see?
https://docs.camunda.org/manual/7.12/installation/full/tomcat/manual/

Also, how did you determine this? (Sorry, I’ve not used Java in over a decade, so slowly getting back into it)

Thanks for pointing this out. Is there a Tomcat 8 build available?

Supported platforms are listed here;https://docs.camunda.org/manual/7.12/introduction/supported-environments/ There is no hard dependency on tomcat 9.

Didn’t you want to use the prepackage distribution? That would be the one under the link above, following the quick start tutorial here: https://docs.camunda.org/get-started/quick-start/
This distribution already includes all you need and will get you started much easier and faster. Or do you have a specific need for Tomcat 8?

If you want to compose an environment yourself I would recommend looking into the Spring Boot option: https://docs.camunda.org/get-started/spring-boot/ but if your are just getting back to Java dealing with Maven and Spring Boot not be the first step.

Sorry @rob2universe, just to be clear: I downloaded https://camunda.org/release/camunda-bpm/tomcat/7.12/camunda-webapp-tomcat-standalone-7.12.0.war - unzipping this file, it looks very different to the zip/tar.gz files you’re referring to; it does not seem to contain Tomcat, which was my expectation.

I’m deploying that https://camunda.org/release/camunda-bpm/tomcat/7.12/camunda-webapp-tomcat-standalone-7.12.0.war file onto a Tomcat 8.5 instance, which as far as I could see should work.

Camunda itself works fine, it’s just the REST API that I can’t seem to access.

Danny, you do not seem to have a strict requirement for Tomcat 8.5. To get to the fun BPM part faster, I would recommend to just use the prepackage distribution. If you prefer to fix your Tomcat 8.5 setup then I suggest you check the contents of the prepackage distribution and compare your setup to it.

I’ve already got a working BPM installation working locally - I’m now trying to setup a staging/production setup.

The prepackage distributions you’re referring to - would that be https://camunda.org/release/camunda-bpm/tomcat/7.12/camunda-bpm-tomcat-7.12.0.tar.gz? I’d prefer to not use this since I want to install Tomcat via my package manager on Debian.

Out of interest, when I call this URL http://localhost:8080/camunda/api/engine/engine I get this response:
[{"name":"default"}]

Which looks correct, to me. It’s the same response I get when I call it in my local (testing) environment.

However when I try hit a resource on the API:

{"type":"NotFoundException","message":"Could not find resource for relative : /deployment of full path: http://localhost:8080/camunda/api/engine/deployment"}

Could this maybe be a datasource issue? Is this an expected response from the REST engine?

I see. Yes, that is the prepackaged distro I am referring to. The rest api should become available via the camunda-engine-rest war you deployed, e.g. here: http://localhost:8080/engine-rest/deployment
not under camunda/api/engine.

You followed this instrucution and also renamed the file?

Copy the war file to $TOMCAT_HOME/webapps . Optionally you may rename it or extract it to a folder to deploy it to a specific context like /engine-rest .

If you renamed it then the REST base URL should be http://localhost:8080/**yourname**/

You can see this was done in the prepackaged distro.

(Nowadays a production deployment would frequently leverage docker or Spring boot)

I should’ve clarified - in my last message I was referring to the REST engine that comes bundled with the standalone instance as you indicated.

I’ve now gotten to a point where I’m getting a 401 back for the following call:

curl http://localhost:8080/camunda/api/engine/engine/default/deployment
<!doctype html><html lang="en"><head><title>HTTP Status 401 – Unauthorized</title><style type="text/css">body {font-family:Tahoma,Arial,sans-serif;} h1, h2, h3, b {color:white;background-color:#525D76;} h1 {font-size:22px;} h2 {font-size:16px;} h3 {font-size:14px;} p {font-size:12px;} a {color:black;} .line {height:1px;background-color:#525D76;border:none;}</style></head><body><h1>HTTP Status 401 – Unauthorized</h1><hr class="line" /><p><b>Type</b> Status Report</p><p><b>Description</b> The request has not been applied because it lacks valid authentication credentials for the target resource.</p><hr class="line" /><h3>Apache Tomcat/8.5.50 (Debian)</h3></body></html>

This to me does not look like an error message returned by the engine, though.

Is there some documentation on using the embedded REST API in the Camunda Tomcat distribution?

That endpoint is used exclusively by the webapps - it’s not indeed to be used in any other way, it’s different to the REST API that @rob2universe is suggesting you use

@Niall hi, and to your hawk

OK. In that case, I’m thoroughly confused.
How do I get the REST API working with this standalone Tomcat distro? I’m back to square one

Usually you just need to follow these instructions.
The REST API is another WAR file you need to drop into the webapps folder.

@Niall please see the original problem statement - this is exactly what I’ve done, to no avail…

I see that, but I’m actually not sure what the problem could be.
I think @rob2universe already suggeste the likely issues, e.g. that the version of the engine does not match the version of the REST API. Beyond that i’m not really sure what could be wrong.

OK, that’s a great pity - this step is critical for us to move forward.
I’ll keep digging, thanks