cancel
Showing results for 
Search instead for 
Did you mean: 

ActivitiEngine object coming as null in standalone java class

penusila611621
Champ in-the-making
Champ in-the-making
I am newbie in activiti and below is my problem

1. Downloaded activiti 5.14 distribution
2. Downloaded eclipse plug in 5.14.1 and setup the eclipse to work with activit
3. Developed a simple process
4. Created test java class with the help of JUnit test option
5. The following statement is returning null means processEngine object is null
ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();

6. Attached the java class & activit-cfg.xml file(tried with h2 properties and with out h2 db properties in xml file)
7. Commented the lines in java class to check step by step

i am not able to proceed because of NullPointer exception. All the activiti related jar's downloaded added to classpath.

I am doing a poc and prompt response is very much appreciated.
18 REPLIES 18

penusila611621
Champ in-the-making
Champ in-the-making
Have activiti.cfg.xml in my classpath (path: src\test\resource) ut still the line (activitiRule.getRepositoryService():smileywink: returning null. activiti.cfg file has the entries as attached in my first comment.

May I know how can I upload my project to check something wrong I am doing here.

cquiqui
Champ in-the-making
Champ in-the-making
hello all

I had the same pb, I changed the JUnit version in my pom.xml from 4.11 to 4.11-beta-1 and it worked for me !!!
I am using activiti version 5.16.1

    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.11-beta-1</version>
    </dependency>

cheers/JEFF

cquiqui
Champ in-the-making
Champ in-the-making
sorry, I made a mistake, it's not working either
I confirm that there is a pb with the following construct when we use the test unit with JUnit 4:
public class TaskServiceTest {

@Rule
public ActivitiRule activitiRule = new ActivitiRule("activiti.cfg-mem.xml");

private void startProcessInstance() {
  RuntimeService runtimeService = activitiRule.getRuntimeService();
  Map<String, Object> variableMap = new HashMap<String, Object>();
  variableMap.put("isbn", "123456");
  runtimeService.startProcessInstanceByKey("bookorder", variableMap);
}


my object activitiRule contains only null pointers, exept for configurationResource :

configurationResource = {java.lang.String@1133}"activiti.cfg-mem.xml"
deploymentId = null
processEngineConfiguration = null
processEngine = null
repositoryService = null
runtimeService = null
taskService = null
historyService = null
identityService = null
managementService = null
formService = null
mockSupport = null

what can we do to help you find why we encounter this problem ?

regards / JEFF

jbarrez
Star Contributor
Star Contributor
Could you wrap that whole project up in a zip file and post it here so we can have  a look?

cquiqui
Champ in-the-making
Champ in-the-making
I try to upload ActivitiRuleTest.zip.txt binary file, hope it will work
thank's for your help.

cquiqui
Champ in-the-making
Champ in-the-making
hello Joram,

did you have an oportunity to look at the source code I uploaded previously

it' s a very simple code example created in eclipse, the project has been created from the activiti eclipse plugin

the code is just doing this, and the result is that the activity rul object contains only null pointers inside it:

public class TestRule {
  @Rule
  public ActivitiRule activitiRule = new ActivitiRule("activiti.cfg-mem.xml");
 
  @Test
  @Deployment(resources={"bookorder.bpmn20.xml"})
  public void ruleUsageExample() {
    RuntimeService runtimeService = activitiRule.getRuntimeService();
    Map<String, Object> variableMap = new HashMap<String, Object>();
    variableMap.put("isbn", "123456");
    runtimeService.startProcessInstanceByKey("bookorder", variableMap);


martin_grofcik
Confirmed Champ
Confirmed Champ
Hi,

change

  @Rule
  public ActivitiRule activitiRule = new ActivitiRule("activiti.cfg.xml");
 
  @Test
  @Deployment(resources={"diagrams/bookorder.bpmn20.xml"})

Regards
Martin

cquiqui
Champ in-the-making
Champ in-the-making
YES of course
shame on me for this big mistake
thank's a million for your help Martin

best regards

cquiqui
Champ in-the-making
Champ in-the-making
post scriptum : of course it's working now.
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.