Process engine not available in Cockpit+Tasklist after deploying Spring annotation-based process application

473 views
Skip to first unread message

Jan-Philipp Friedenstab

unread,
Apr 11, 2015, 1:07:24 PM4/11/15
to camunda-...@googlegroups.com

Hi,

I created a Spring-based process application according to the getting started guide (http://docs.camunda.org/latest/guides/getting-started-guides/spring-framework/#bonus-chapter-use-shared-process-engine-on-apache-tomcat). However, I converted the Spring configuration into an annotation-based one as follows (see attached Eclipse Maven project, too):

web.xml

 <context-param>
   
<param-name>contextClass</param-name>
   
<param-value>org.springframework.web.context.support.AnnotationConfigWebApplicationContext</param-value>
 
</context-param>

 
<context-param>
   
<param-name>contextConfigLocation</param-name>
   
<param-value>org.camunda.bpm.getstarted.loanapproval.config.LoanApprovalConfig</param-value>
 
</context-param>

 
<listener>
   
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
 
</listener>


configuration class

@Configuration
public class LoanApprovalConfig {

 
@Bean
 
public ProcessEngineService processEngineService() {
   
return BpmPlatform.getProcessEngineService();
 
}

 
@Bean
 
public ProcessEngine processEngine() {
   
return processEngineService().getDefaultProcessEngine();
 
}

 
@Bean
 
public RepositoryService repositoryService() {
   
return processEngine().getRepositoryService();
 
}

 
@Bean
 
public RuntimeService runtimeService() {
   
return processEngine().getRuntimeService();
 
}

 
@Bean
 
public TaskService taskService() {
   
return processEngine().getTaskService();
 
}

 
@Bean
 
public HistoryService historyService() {
   
return processEngine().getHistoryService();
 
}

 
@Bean
 
public ManagementService managementService() {
   
return processEngine().getManagementService();
 
}

 
@Bean
 
public SpringServletProcessApplication processApplication() {
   
return new SpringServletProcessApplication();
 
}

 
@Bean
 
public Starter starter() {
   
return new Starter();
 
}

 
@Bean
 
public CalculateInterestService calculateInterestService() {
   
return new CalculateInterestService();
 
}
}


dependencies in pom.xml

<properties>
 
<camunda.version>7.2.0</camunda.version>
 
<spring.version>3.1.2.RELEASE</spring.version>
 
<cglib.version>2.2.2</cglib.version>
</properties>

<dependencyManagement>
 
<dependencies>
 
<dependency>
   
<groupId>org.camunda.bpm</groupId>
   
<artifactId>camunda-bom</artifactId>
   
<version>${camunda.version}</version>
   
<scope>import</scope>
   
<type>pom</type>
 
</dependency>
 
</dependencies>
</dependencyManagement>

<dependencies>
 
<dependency>
   
<groupId>org.camunda.bpm</groupId>
   
<artifactId>camunda-engine</artifactId>
   
<scope>provided</scope>
 
</dependency>
 
<dependency>
   
<groupId>org.camunda.bpm</groupId>
   
<artifactId>camunda-engine-spring</artifactId>
 
</dependency>
   
<dependency>
   
<groupId>org.springframework</groupId>
   
<artifactId>spring-web</artifactId>
   
<version>${spring.version}</version>
 
</dependency>
 
<dependency>
   
<groupId>cglib</groupId>
   
<artifactId>cglib</artifactId>
   
<version>${cglib.version}</version>
 
</dependency>

</dependencies>


In general, this approach works fine and the process is executed without errors.

However, after redeploying the process application to the Tomcat server, camunda cockpit and tasklist don't work as the default process engine is not available (note: I am using the pre-configured Camunda tomcat distribution on Windows 7 with JDK 8 and I did not make any changes to the server configuration):




WARNUNG: org.camunda.bpm.engine.rest.exception.InvalidRequestException: No process engine available
 at org
.camunda.bpm.engine.rest.impl.AbstractRestProcessEngineAware.getProcessEngine(AbstractRestProcessEngineAware.java:35)
 at org
.camunda.bpm.engine.rest.impl.ProcessDefinitionRestServiceImpl.getStatistics(ProcessDefinitionRestServiceImpl.java:127)
 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:497)
 at org
.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:167)
 at org
.jboss.resteasy.core.ResourceMethod.invokeOnTarget(ResourceMethod.java:257)
 at org
.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:222)
 at org
.jboss.resteasy.core.ResourceLocator.invokeOnTargetObject(ResourceLocator.java:159)
 at org
.jboss.resteasy.core.ResourceLocator.invoke(ResourceLocator.java:92)
 at org
.jboss.resteasy.core.SynchronousDispatcher.getResponse(SynchronousDispatcher.java:542)
 at org
.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:524)
 at org
.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:126)
 at org
.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:208)
 at org
.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:55)
 at org
.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:50)
 at javax
.servlet.http.HttpServlet.service(HttpServlet.java:728)
 at org
.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
 at org
.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
 at org
.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
 at org
.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
 at org
.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
 at org
.camunda.bpm.engine.rest.filter.CacheControlFilter.doFilter(CacheControlFilter.java:47)
 at org
.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
 at org
.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
 at org
.camunda.bpm.webapp.impl.security.filter.SecurityFilter.doFilterSecure(SecurityFilter.java:67)
 at org
.camunda.bpm.webapp.impl.security.filter.SecurityFilter.doFilter(SecurityFilter.java:51)
 at org
.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
 at org
.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
 at org
.camunda.bpm.webapp.impl.security.auth.AuthenticationFilter$1.execute(AuthenticationFilter.java:59)
 at org
.camunda.bpm.webapp.impl.security.auth.AuthenticationFilter$1.execute(AuthenticationFilter.java:56)
 at org
.camunda.bpm.webapp.impl.security.SecurityActions.runWithAuthentications(SecurityActions.java:38)
 at org
.camunda.bpm.webapp.impl.security.auth.AuthenticationFilter.doFilter(AuthenticationFilter.java:56)
 at org
.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
 at org
.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
 at org
.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
 at org
.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
 at org
.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
 at org
.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
 at org
.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
 at org
.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
 at org
.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
 at org
.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:409)
 at org
.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1044)
 at org
.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)
 at org
.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:315)
 at java
.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
 at java
.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
 at java
.lang.Thread.run(Thread.java:745)


Unfortunately, I don't have any idea what is going wrong here. So any help on this issue would be greatly appreciated!
camunda-get-started-spring-annotations.zip

Jan-Philipp Friedenstab

unread,
Apr 11, 2015, 1:15:40 PM4/11/15
to camunda-...@googlegroups.com
Two additional remarks:
  • a Tomcat restart is required to get camunda cockpit and tasklist working again
  • the issue does not occur when the application is implemented exactly as described in the getting starting guide (with XML-based configuration instead of using Java annotations)

Christian Lipphardt

unread,
Apr 11, 2015, 3:57:38 PM4/11/15
to camunda-...@googlegroups.com
Hi Jan,

The problem you are facing is that spring calls the methods 'destroy' or 'close' on beans configured through @Bean annotation when shutting down. This does not happen when you use the XML configuration way. Only when you do configure it explicitly or implement the DisposableBean interface. In your case this leads to spring destroying the default process engine because the process engine object has a 'close'-method which will be invoked when you undeploy the process application. Then Cockpit and Tasklist just stop working.
You can workaround this by specifying an empty string as destroy method on the @Bean annotation, see [1].

Example:

@Bean(destroyMethod="")
 public ProcessEngine processEngine() {
    
return processEngineService().getDefaultProcessEngine();
 
}

Jan-Philipp Friedenstab

unread,
Apr 12, 2015, 4:20:32 AM4/12/15
to camunda-...@googlegroups.com
Hello Christian,

thank you very much for your immediate response. Your solution works perfectly. Again, I've learned something about some kind of "Spring magic" going on behind the scenes ;)

Best regards,
Jan
Reply all
Reply to author
Forward
0 new messages