Expecting ProcessInstance to be ended, but it is not!

Hi,

I am quite new to using Camunda.

I have a process with 2 Service Class (Implementation: Java Class) and a gateway.
When I compile under Eclipse it is working well.

But I have an issue when I add a User Task (need to input a number before proceeding) at the beginning of the process.

This is the error when compiling:
java.lang.AssertionError: Expecting ProcessInstance {id='4', processDefinitionId='PolicyRule:1:3', businessKey='null'} to be ended, but it is not!. (Please make sure you have set the history service of the engine to at least 'activity' or a higher level before making use of this assertion!)

I have tried several ways to solve this problem but in vain.
Grateful if you guys could help (I have attached the bpmn file as well).

process.bpmn (5.9 KB)

Regards,

Hi @Rambo27
Welcome to the forum.
Can you explain how and when this error occurs - also details on the Camunda deployment.

Hi @Niall,

Thank you.

The error occurs when I compile under Eclipse (Run As → Maven install).
I have noticed that the error occurred when I added the “Input application number” process which is a User Task. If I remove this process, then it is working fine. But the thing is that I need to read the user’s input so that I may use the variable in the service task “Check customer status”.

Additionally if I replace the User Task by a simple Task and compile again, then there are no errors. I don’t understand why the error is happening when simply adding a user task.

I hope you can help.

Are you running tests?
If you haven’t changed the default JUnit test to match your process then it’s going to fail.
Either remove the test or run the maven built and skip tests to see if that works.

By the looks of things - yes.

Results :

Failed tests:   testHappyPath(proj.camunda.demo.PolicyRule.ProcessUnitTest): Expecting ProcessInstance {id='4', processDefinitionId='PolicyRule:1:3', businessKey='null'} to be ended, but it is not!. (Please make sure you have set the history service of the engine to at least 'activity' or a higher level before making use of this assertion!)

Tests run: 1, Failures: 1, Errors: 0, Skipped: 0

You mean I can comment out the test or is there a particular way to disable/skip it?
Thanks.

I recall that there is a tickbox somewhere that lets you run a maven built that skips the Unit test.
If you can’t figure that out then commenting out the tests will have the same affect.

@Niall,

I have been able to skip the test by specifying it in the pom.xml.
It is now compiling ok.

<properties>
    <camunda.version>7.14.0</camunda.version>
    <!--
    Adjust if you want to use Camunda Enterprise Edition (EE):
    <camunda.version>7.14.0-ee</camunda.version>
    Make sure you also switch to EE repository below
    -->
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <failOnMissingWebXml>false</failOnMissingWebXml>
      **<skipTests>true</skipTests>**
  </properties>

But, now I am encountering another issue when running the process in Camunda (see below).
Unknown property used in expression: #{blacklisted}. Cause: Cannot resolve identifier 'blacklisted'

It seems that now, Camunda cannot see the variable “blacklisted” which is being declared and computed in the Service Task “Check customer status”.

As said before, the process was working fine before the addition of the user task at the beginning.

1 Like

Can you upload your model and show the code being run by the service task?
I would also ask that if you post the code here can you take a look at how to format it correctly so that i can easily read it.

Please find the model as requested.

process.bpmn (5.9 KB)

The code of the service task is given below:

package proj.camunda.demo.BusinessRule;

import java.sql.*;
import java.util.*;

import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.engine.delegate.JavaDelegate;

public class CheckCustomerStatusDelegate implements JavaDelegate {

	@Override
	public void execute(DelegateExecution execution) throws Exception {
				
		Statement stmt = null;
		Connection conn = null;
		String strQuery = "";		
		//URL is hidden on purpose
		String URL = "jdbc:informix-sqli://XX.X.XX.XX:XXXX/xxx:informixserver=xxx;user=xxxxx;password=xxxxxx";		
		
		try 
	    {
		    Class.forName("com.informix.jdbc.IfxDriver");
		    conn = DriverManager.getConnection(URL);
		    System.out.println("--->> SUCCESS: Informix JDBC driver successfully loaded <<---");	
		    
		    int apply_no = 0;		    
		    String nationalID = "";		
		    Boolean blacklisted = false;		    
		    
		    apply_no = (int) execution.getVariable("ApplicationNo");
		    System.out.println("\n\n--->> application no = " + apply_no);		    
		    
		    strQuery = "select nat_id "
		    		    + "from my_table "
		    		    + "where apply_no = " + apply_no;			    
		    
		    stmt = conn.createStatement();		    
		    ResultSet rs = stmt.executeQuery(strQuery);		    
		    if (rs.next())
		    {		    
		    	nationalID = rs.getString("nat_id");		    	
		    			    	
		    	strQuery = "SELECT nat_id FROM myblacklist where nat_id = '"  + nationalID + "'";		    	
		    	rs = stmt.executeQuery(strQuery);
		    	if (rs.next())
		    	{
		    		blacklisted = true;		    		
		    	}
		    	else
		    	{
		    		blacklisted = false;		    		
		    	};
		    			    	
		    	System.out.println("\n\n--->> blacklisted flag = " + blacklisted);		    	
		    }
		    else
		    {
		    	System.out.println("\n--->> Application " + apply_no + " has not yet been treated!");
		    };
		    		        
			execution.setVariable("blacklisted", blacklisted);	
		   	 		    
	    }
		catch (Exception e)
	    {
		    System.out.println("--->> ERROR: failed to load Informix JDBC driver. <<---");
		    System.out.println("ERROR: " + e.getMessage());
		    e.printStackTrace();
		    return;
	    }
		finally
		{
			if (stmt != null) stmt.close();
			if (conn != null) conn.close();
		}
	}

}

Hello @Niall,

I have been able to solve the problem by changing the type of apply_no from int to long (same type declared in the model).
I am now able to launch the process, input the application number and the service task is being correctly executed. :grinning:

Thank you for your kind help on this one @Niall

.
 Long apply_no = (long) 0;
.
.
apply_no = (Long) execution.getVariable("ApplicationNo");
System.out.println("\n\n--->> application no = " + apply_no);
.
.
}

Form Field “ApplicationNo” as declared in the bpmn:

1 Like

Thank you Rambo, this addition in pom.xml helped me :slightly_smiling_face:
Cheers.

1 Like