cancel
Showing results for 
Search instead for 
Did you mean: 

Deploying .bpmn20.xml Into War file Spring MVC

rj1
Champ in-the-making
Champ in-the-making
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?
10 REPLIES 10

rj1
Champ in-the-making
Champ in-the-making
Hi

Is there no solution?

rj1
Champ in-the-making
Champ in-the-making
Hi Activiti Team

Can you please tell me I am posting this kind of query in the wrong post? I really need a solution and no one from your team seems to reply.

jbarrez
Star Contributor
Star Contributor
A bit of patience would be nice …

Anyway, I don't see anything wrong. Are you sure that the process xml are part of your war file?
Does 'classpath*:/processes.*.bpmn20.xml' matches your process filename?

rj1
Champ in-the-making
Champ in-the-making
Hi

Sorry, no reply I was thinking that you don't seem to respond.

Yes, that's correct the process xml is part of the war file. The war file structure is:

WEB-INF/processes/SendEProcess.bpmn20.xml

I also tried removing this from the WEB-INF and putting the processes folder on the classpath but no difference.

Not sure what to do.

rj1
Champ in-the-making
Champ in-the-making
Hi

Just to be clear, it works in a standalone application but not as part of the WAR file.

jbarrez
Star Contributor
Star Contributor
It feels to me that something is wrong with the classpath:*… expression. Did you try references the process without wildcards? Or put the bpmn20.ml straight away in the WEB-INF and using *.bpmn20.xml (as in the spring examples)

rj1
Champ in-the-making
Champ in-the-making
Hi

I have tried all this. Look at the classpath entry below:


<?xml version="1.0" encoding="UTF-8"?>
<classpath>
  <classpathentry kind="src" path="src/main/java"/>
<classpathentry kind="src" path="processes"/>
  <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
  <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"/>
  <classpathentry kind="output" path="target/classes"/>
</classpath>

The deployment folder exists with the bar and jar created.


<property name="deploymentResources" value="classpath*:/processes.*.bpmn20.xml"/>

I have tried removing classpath. I tried putting directly under WEB-INF but still cannot find it.

Actaully, I don't want this to be on the classpath as this is a web application. I have a folder called processes under WEB-INF. I would like it to find it from here. What should go inside this folder just the .bpmn20.xml? Or also include the .bar?

Is this correct:


<property name="deploymentResources" value="/WEB-INF/processes.*.bpmn20.xml"/>

I hope you can help.

jbarrez
Star Contributor
Star Contributor
The classpath you posted is an Eclipse classpath, not the web application classpath. So it has no influence on your webapp, as I don't know how you build your webapp.

I'm not sure your resources config is correct (see http://stackoverflow.com/questions/3294423/spring-classpath-prefix-difference).
Here's how one of our examples look like:


  <property name="deploymentResources" value="classpath*:/org/activiti/spring/test/autodeployment/autodeploy.*.bpmn20.xml" />

Note the asterix BEFORE the '/'

rj1
Champ in-the-making
Champ in-the-making
Hi

Ok, do you have any examples of using Activiti inside a webapp with Spring? I can't seem to find any. All the examples provided by Activiti are all standalone applications.

Have a look at this: http://stackoverflow.com/questions/793917/is-web-inf-in-the-classpath

Where should these proceses be located .bpmn20.xml be located inside a web application. I am sure you can help here.