cancel
Showing results for 
Search instead for 
Did you mean: 

Issues Running BPMN 2.0 HelloWorld on MySQL

zicongwang
Champ in-the-making
Champ in-the-making
Hi all,
  I installed the Eclipse designer and run a hello world example it can run smoothly. And I configure the database from h2 to mysql the example can run smoothly and no error occurs but I can not find any record in the mysql database when I run the process in the eclipse.The steps I perform is
1.Complete the hello world BPMN with eclipse designer
2.generate the unit test example with ecplise designer
3.run the unit test

The hello world can run correctly,when I deploy the hello world according to activiti expro I can find the process record in the mysql ,but I can not find any record in mysql database, when I run the process in the eclipse , How can I configure eclipse so that I can store the process detail in the mysql database? I change the activiti.cfg.xml to the following and put it in the src/test/java but it does not work

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans   http://www.springframework.org/schema/beans/spring-beans.xsd">

  <bean id="processEngineConfiguration" class="org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration">
 
    <!– Database configurations –>
    <property name="databaseType" value="mysql" />
    <property name="jdbcUrl" value="jdbc:mysql://localhost:3306/activiti?autoReconnect=true" />
    <property name="jdbcDriver" value="com.mysql.jdbc.Driver" />
    <property name="jdbcUsername" value="activiti" />
    <property name="jdbcPassword" value="activiti" />
   
  </bean>

</beans>

6 REPLIES 6

frederikherema1
Star Contributor
Star Contributor
Hi,

I recommend putting the activiti.cfg.xml in src/test/resources and check if there are more activiti.cfg.xml files on your test-classpath…

zicongwang
Champ in-the-making
Champ in-the-making
Yeah,I have put the activiti.cfg.xml in src/test/resources,but the same issue occurs, I can not get any record from mysql database

Hi,

I recommend putting the activiti.cfg.xml in src/test/resources and check if there are more activiti.cfg.xml files on your test-classpath…

frederikherema1
Star Contributor
Star Contributor
Does your test leave resources behind? If you use the @Deployment in your tests, the deployment is cascade deleted after the test is finished.

If you cant to be absolutely sure you're using the DB you want, you can add something like this in your test to check:

Assert.assertEquals("mysql", activitiRule.get((ProcessEngineImpl)activitiRule.getProcessEngine()).getProcessEngineConfiguration().getDatabaseType());

zicongwang
Champ in-the-making
Champ in-the-making
Thanks for your reply
I add the code to the test and can get the result that I use the mysql
Assert.assertEquals("mysql", activitiRule.get((ProcessEngineImpl)activitiRule.getProcessEngine()).getProcessEngineConfiguration().getDatabaseType());
I use the @Deployment in my test that may caused the problem.
If I do not use @Deployment , Any other way to replace it so that I can run the test correctly and can also get the result in the mysql databse?
Does your test leave resources behind? If you use the @Deployment in your tests, the deployment is cascade deleted after the test is finished.

If you cant to be absolutely sure you're using the DB you want, you can add something like this in your test to check:

Assert.assertEquals("mysql", activitiRule.get((ProcessEngineImpl)activitiRule.getProcessEngine()).getProcessEngineConfiguration().getDatabaseType());

frederikherema1
Star Contributor
Star Contributor
Hi,

AFAIK there is nothing wrong with your unit-test, you can check everything you want in the test-method using assertions and afterwards your data is cleaned up, so other tests get a clean DB again.

If you really want to leave things behind, you shouldn't use the @Deployment annotation, but just manually deploy the process-definition in the beginnin of your test, without removing it:

activitiRule.getProcessEngine().getRepositoryService().createDeployment()…

jbarrez
Star Contributor
Star Contributor
You can just call repositoryService.createDeployment().addClasspathResource("your-process').deploy()

That will not clean up your test afterwards.