AnsweredAssumed Answered

Activiti rest process engine configuration

Question asked by ganeshr on Jun 25, 2013
Latest reply on Jun 28, 2013 by ganeshr
Hi,

  I'm trying to develop custom rest application using jersery on top of activiti-rest, by including activiti-rest jars as a dependencies. when I deploy my custom rest app in tomcat I see process engine is creating twice. Here is the console ouput,

Jun 25, 2013 7:05:50 AM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring root WebApplicationContext
25 Jun 2013 07:05:50,398 [localhost-startStop-1]  INFO org.springframework.web.context.ContextLoader:272 - Root WebApplicationContext: initialization started
25 Jun 2013 07:05:50,477 [localhost-startStop-1]  INFO org.springframework.context.support.AbstractApplicationContext:500 - Refreshing Root WebApplicationContext: startup date [Tue Jun 25 07:05:50 CDT 2013]; root of context hierarchy
25 Jun 2013 07:05:50,531 [localhost-startStop-1]  INFO org.springframework.beans.factory.xml.XmlBeanDefinitionReader:315 - Loading XML bean definitions from class path resource [config/applicationContext.xml]
25 Jun 2013 07:05:50,727 [localhost-startStop-1]  INFO org.springframework.beans.factory.xml.XmlBeanDefinitionReader:315 - Loading XML bean definitions from URL [file:/C:/Users/xprk825/apache-tomcat-servers/apache-tomcat-7.0.30%20-%20Activiti%205.12/webapps/custom-rest-api/WEB-INF/classes/activiti-context.xml]
—–
—-
25 Jun 2013 07:06:20,701 [localhost-startStop-1] DEBUG org.apache.ibatis.logging.slf4j.Slf4jImpl:47 - ==>  Preparing: select * from ACT_GE_PROPERTY where NAME_ = ?
25 Jun 2013 07:06:20,720 [localhost-startStop-1] DEBUG org.apache.ibatis.logging.slf4j.Slf4jImpl:47 - ==> Parameters: schema.version(String)
25 Jun 2013 07:06:20,831 [localhost-startStop-1]  INFO org.activiti.engine.impl.ProcessEngineImpl:81 - ProcessEngine default created
Jun 25, 2013 7:06:23 AM org.apache.catalina.startup.HostConfig deployDirectory


Jun 25, 2013 7:06:24 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 39262 ms
Jun 25, 2013 7:06:36 AM org.apache.catalina.core.ApplicationContext log
INFO: RestletServlet: [Restlet] Attaching application: org.activiti.rest.application.ActivitiRestServicesApplication@711a638a to URI: /custom-rest-api/jas/activiti-service
25 Jun 2013 07:06:36,099 [http-bio-8080-exec-1]  INFO org.activiti.engine.ProcessEngines:108 - Initializing process engine using Spring configuration 'file:/C:/Users/xprk825/apache-tomcat-servers/apache-tomcat-7.0.30%20-%20Activiti%205.12/webapps/custom-rest-api/WEB-INF/classes/activiti-context.xml'

As you can see process engine created when applicationContext.xml is loaded and the next time it is initialized when rest service is called.

Here is my web.xml configuration:

<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">

  <display-name>Activiti-Jersey-Rest-Services</display-name>

  <servlet>
    <servlet-name>jersey-servlet</servlet-name>
    <servlet-class>com.sun.jersey.spi.spring.container.servlet.SpringServlet</servlet-class>
  </servlet>

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

  <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath:config/applicationContext.xml</param-value>
  </context-param>

  <servlet>
    <servlet-name>RestletServlet</servlet-name>
    <servlet-class>org.restlet.ext.servlet.ServerServlet</servlet-class>
    <init-param>
      <param-name>org.restlet.application</param-name>
      <param-value>org.activiti.rest.application.ActivitiRestServicesApplication
         </param-value>
    </init-param>
  </servlet>

  <servlet-mapping>
    <servlet-name>RestletServlet</servlet-name>
    <url-pattern>/jas/activiti-service/*</url-pattern>
  </servlet-mapping>

  <servlet-mapping>
    <servlet-name>jersey-servlet</servlet-name>
    <url-pattern>/jas/*</url-pattern>
  </servlet-mapping>
 
 


  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>

</web-app>


and in the applicationContext.xml, I have imported the resource activiti-context.xml to initialize the process engine.
Could you help to resolve the issue of process engine getting initialized twice.

Outcomes