Prerequisites
The REST API classes are tested with , Jersey and as the JAX-RS implementation.Furthermore, the engine classes and Jackson’s artifact (as well as transitive Jackson dependencies) have to be on the classpath.
Required Steps
Step 1: Add the REST API to your project as a Maven dependency.
Step 2: Add the REST resources that you need to your JAX-RS application. Example:
@ApplicationPath("/")
public class MyApplication extends Application {
@Override
Set<Class<?>> classes = new HashSet<Class<?>>();
// add your own classes
...
// add all camunda engine rest resources (or just add those that you actually need).
classes.addAll(CamundaRestResources.getResourceClasses());
// mandatory
return classes;
}
CamundaRestResources.getResourceClasses()
contains two JAX-RS resources that serve as the entry points. One of these (org.camunda.bpm.engine.rest.impl.NamedProcessEngineRestServiceImpl
) provides all of the REST resources listed in this document on paths beginning with /engine/{name}
while the other (org.camunda.bpm.engine.rest.impl.DefaultProcessEngineRestServiceImpl
) provides access to the default engine’s resources on the root path /
.
The configuration class JacksonConfigurator
is required to correctly configure the serialization of date fields.You may also have to add the following Jackson providers: com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider
,org.camunda.bpm.engine.rest.exception.JsonMappingExceptionHandler
and org.camunda.bpm.engine.rest.exception.JsonParseExceptionHandler
.Depending on the runtime environment, this may not be necessary.On JBoss AS 7/Wildfly 8 these should be automatically added as an implicit module dependency.
For proper exception responses of the format as described in the Introduction,it is necessary to include RestExceptionHandler
. ProcessEngineExceptionHandler
is used to translate any exception thrown by theengine that is not explicitly handled by the REST API classes to a generic HTTP 500 error with the same response body format.If you would like to have all kinds of exceptions translated to this format, you can use org.camunda.bpm.engine.rest.exception.ExceptionHandler
instead of ProcessEngineExceptionHandler
.