AnsweredAssumed Answered

Deploying .bpmn20.xml Into War file Spring MVC

Question asked by rj1 on Sep 21, 2012
Latest reply on Oct 1, 2012 by jbarrez
Hi

I am created a Spring MVC application and created an Activiti database by running the DbSchemaCreate.main(). Actaully my processes don't seem to deploy on the war file. When Tomcat starts the ProcessEngine is started through Spring and works. I can access the RuntimeService. The code can be seen below:

web.xml


<?xml version="1.0" encoding="UTF-8"?>
<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_5.xsd"
       version="2.5">
      
       <display-name>WebApp</display-name>
      
       <context-param>
          <!– Specifies the list of Spring Configuration files in comma separated format.–>
          <param-name>contextConfigLocation</param-name>
          <param-value>/WEB-INF/spring/activiti.xml
          </param-value>
       </context-param>
      
       <listener>
          <!– Loads your Configuration Files–>
          <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
       </listener>
      
       <servlet>
          <servlet-name>example</servlet-name>
          <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
          <load-on-startup>1</load-on-startup>
       </servlet>
      
       <servlet-mapping>
          <servlet-name>example</servlet-name>
          <url-pattern>/</url-pattern>
       </servlet-mapping>
      
       <welcome-file-list>
          <welcome-file>index.jsp</welcome-file>
       </welcome-file-list>      
</web-app>

activiti.xml


<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:context="http://www.springframework.org/schema/context"
   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
      http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
      
      <bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">
         <property name="dataSource" ref="dataSource"/>
         <property name="databaseSchemaUpdate" value="true"/>
         <property name="jobExecutorActivate" value="false"/>
         <property name="transactionManager" ref="transactionManager"></property>
         <!– <propety name="beans">
            <map>
               <entry key="printer" value-ref="printer"/>
            </map>
            </property>–>
         <property name="deploymentResources" value="classpath*:/processes.*.bpmn20.xml"/>
      </bean>
      
      <bean id="processEngine" class="org.activiti.spring.ProcessEngineFactoryBean">
         <property name="processEngineConfiguration" ref="processEngineConfiguration"/>
      </bean>
      
      <bean id="dataSource" class="org.springframework.jdbc.datasource.SimpleDriverDataSource">
         <property name="driverClass" value="com.mysql.jdbc.Driver"/>
         <property name="url" value="jdbc:mysql://localhost:3306/activiti_example"/>
         <property name="username" value="root"/>
         <property name="password" value="password"/>
      </bean>
      
      <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
         <property name="dataSource" ref="dataSource"/>
      </bean>
      
      <bean id="repositoryService" factory-bean="processEngine" factory-method="getRepositoryService"/>
      <bean id="runtimeService" factory-bean="processEngine" factory-method="getRuntimeService"/>
      <bean id="taskService" factory-bean="processEngine" factory-method="getTaskService"/>
      <bean id="historyService" factory-bean="processEngine" factory-method="getHistoryService"/>
      <bean id="managementService" factory-bean="processEngine" factory-method="getManagementService"/>
</beans>

The automatic resosource deployment is not being deployed. I have also tried through the code to deploy but it throws an Exception:


repositoryService.createDeployment().addClasspathResource("SendEProcess.bpmn20.xml").deploy();
runtimeService.startProcessInstanceByKey("sendEProcess", mapOfProcessVariables);

org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.activiti.engine.ActivitiException: resource 'SendEProcess.bpmn20.xml' not found
   org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:656)
   org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:560)
   javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
   javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
root cause

org.activiti.engine.ActivitiException: resource 'SendEProcess.bpmn20.xml' not found
   org.activiti.engine.impl.repository.DeploymentBuilderImpl.addClasspathResource(DeploymentBuilderImpl.java:59)
   com.webchannel.web.EmailController.sendE(EController.java:46)
   sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   java.lang.reflect.Method.invoke(Method.java:597)
   org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176)
   org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:426)
   org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:414)
   org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790)
   org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
   org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
   org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:560)
   javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
   javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

How can this resource be located inside the webapp?

Outcomes