cancel
Showing results for 
Search instead for 
Did you mean: 

How to specify a class name for Service Task?

zlatan316
Champ on-the-rise
Champ on-the-rise
I am trying to create a Service Task. I have a .java class implemented as required. I need to provide something in the 'Class name' so it can be referenced when I deploy the Service Task onto Activiti Explorer.

It is currently located at "c:\users\myname\workspace\demo\src\main\java\TestClass.java" but this isn't working.

Can anyone advise?
6 REPLIES 6

frederikherema1
Star Contributor
Star Contributor
You need to compile the class and add it to your classpath. Best way to do this is to create a JAR-file, containing the TestClass class file. Next, add the jar-file to your classpath (since you're using tomcat, this will be WEB-INF/lib of the activiti-explorer webapp).

In the bpmn-file, reference the class using activiti:class="org.my.package.TestClass", where you replace the "org.my.package" by the package-name you're using. From your example, I see you're NOT using a package-name, but just adding the TestClass to the default package, which is discouraged in java…

Thank you for your responseSmiley Happy I have now created a package called "Classes" in src/main/java, and have set the class name to "Classes.TestClass".

I have right-clicked the Project name (Demo) and clicked Create Deployment Artifacts, which have created the MyProcess.bar and MyProcess.Jar files. The JAR file I have copied to webapps\activiti-explorer\WEB-INF\lib.

So now when I try to start the process in Activiti Explorer, it says it cannot instantiate the Classes.TestClass?

frederikherema1
Star Contributor
Star Contributor
Can you double-check the JAR-file actually contains the class-file (unzip it). Also, best to use lower-case package-names, as this is a convention in Java.

zlatan316
Champ on-the-rise
Champ on-the-rise
Have checked and it contains a "myclasses" folder with the TestClass.class inside (have renamed my package  to 'myclasses' so it is all lowercase)

I have also now restarted the Tomcat service just to be safe, and redeployed artifacts and replaced the JAR in the webapps\activiti-explorer\WEB-INF\lib folder.

Now when i try to 'Start Process' in Activity Explorer, it gives a "Warning: null" message?

frederikherema1
Star Contributor
Star Contributor
That's a nullpointer in your TestClass, probably. Check the tomcat-logs for the full stacktrace to see what's going on (logs/catalina.out).

Thank you very much for your adviceSmiley Happy

The logs have pointed to a NullPointerException which I have now resolved by correcting my logic.