Hi @thorben thank you for your response, i use static variable because public static void getDbConnection() is static function , i have changed this but this didn’t have any effect on my code and on connection too
Okay. Please write a unit test that reproduces the problem and share it on github. You can adapt the unit testing available here: https://github.com/camunda/camunda-engine-unittest. Instead of using SQL server, use the built in H2 database.
@thorben here is git link:https://github.com/sally9961/camunda-test
in this test project i have added: sql server configuration because i don;t need embeded database i want to connect to real database beyond my task, and i also want to send mail to smtp,gmail.com but at this point i can’t conplete this task the first error which i see when i run mvn clean test is:
Bean ‘processEngineConfiguration’; nested exception is org.springframework.beans.factory.parsing.BeanDe
finitionParsingException: Configuration problem: Multiple ‘property’ definitions for property ‘history’
Offending resource: class path resource [camunda.cfg.xml]
Bean ‘processEngineConfiguration’
→ Property ‘history’
at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemRepor
ter.java:68)
at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:85)
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.error(BeanDefinitionParse
rDelegate.java:323)
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseBeanDefinitionElemen
t(BeanDefinitionParserDelegate.java:578)
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseBeanDefinitionElemen
t(BeanDefinitionParserDelegate.java:476)
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseBeanDefinitionElemen
t(BeanDefinitionParserDelegate.java:445)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.processBeanDefinit
ion(DefaultBeanDefinitionDocumentReader.java:311)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseDefaultElemen
t(DefaultBeanDefinitionDocumentReader.java:202)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitio
ns(DefaultBeanDefinitionDocumentReader.java:181)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.doRegisterBeanDefi
nitions(DefaultBeanDefinitionDocumentReader.java:140)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefini
tions(DefaultBeanDefinitionDocumentReader.java:111)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBea
nDefinitionReader.java:493)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanD
efinitionReader.java:390)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDef
initionReader.java:334)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDef
initionReader.java:302)
at org.camunda.bpm.engine.impl.cfg.BeansConfigurationHelper.parseProcessEngineConfiguration(Bea
nsConfigurationHelper.java:35)
at org.camunda.bpm.engine.impl.cfg.BeansConfigurationHelper.parseProcessEngineConfigurationFrom
Resource(BeansConfigurationHelper.java:50)
at org.camunda.bpm.engine.ProcessEngineConfiguration.createProcessEngineConfigurationFromResour
ce(ProcessEngineConfiguration.java:303)
at org.camunda.bpm.engine.ProcessEngineConfiguration.createProcessEngineConfigurationFromResour
ce(ProcessEngineConfiguration.java:299)
at org.camunda.bpm.engine.impl.test.TestHelper.getProcessEngine(TestHelper.java:428)
at org.camunda.bpm.engine.test.ProcessEngineRule.initializeProcessEngine(ProcessEngineRule.java
:172)
at org.camunda.bpm.engine.test.ProcessEngineRule.apply(ProcessEngineRule.java:154)
at org.junit.rules.RunRules.applyAll(RunRules.java:26)
at org.junit.rules.RunRules.(RunRules.java:15)
at org.junit.runners.BlockJUnit4ClassRunner.withTestRules(BlockJUnit4ClassRunner.java:379)
at org.junit.runners.BlockJUnit4ClassRunner.withRules(BlockJUnit4ClassRunner.java:340)
at org.junit.runners.BlockJUnit4ClassRunner.methodBlock(BlockJUnit4ClassRunner.java:256)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
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:498)
at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:18
9)
at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:1
65)
at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
Caused by: org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration prob
lem: Multiple ‘property’ defini
Do you have any idea , what should i change or improve to complete this task(p.s this is test case i can upload whole project if it isn’t enough)
but when i run this mvn clean test i got this error:
Failed tests: shouldExecuteProcess(org.camunda.bpm.unittest.SimpleTestCase): Expecting actual ProcessInstance {id=‘107’, processDefinitionId=‘P
rocess_2:1:103’, businessKey=‘null’} to be ended, but it is not!. (Please make sure you have set the history service of the engine to at least ‘a
ctivity’ or a higher level before making use of this assertion!)
As i have seen through debug process it can’t end processInstance, in this case should i use this piece of coed or somehow make configuration which will help me end this task? ProcessEngine processEngine = ProcessEngineConfiguration
.createProcessEngineConfigurationFromResourceDefault()
.setHistory(ProcessEngineConfiguration.HISTORY_FULL)
.buildProcessEngine();
So it starts a process instance and then completes one user task.
Now look at the process model. It contains a sequence of multiple user tasks, three in the shortest path. So it is not surprising that the process instance is not finished when you only complete the first task.
What you should do: Please try to create a minimal test case. This is important to study a problem in isolation, which makes it much easier to understand. In particular, you can follow these steps:
Remove all tasks except one user task
Add the task listener, in which you try to connect to the database, to that user task
Provide any variables that the task listener expects in the RuntimeService#startProcessInstanceByKey call