cancel
Showing results for 
Search instead for 
Did you mean: 

failure calling Java ServiceTask

arno1
Champ in-the-making
Champ in-the-making
Hello,
I'd like to call a method called doSomething() (it returns a string) from a small Java Class myJavaClass using the java service task. I'd like to use the returned string for showing it in the following user task.
Therefore my process looks like this here:

<process id="myJavaServiceTask" name="myJavaServiceTask">
    <startEvent id="startevent1" name="Start"></startEvent>
    <serviceTask id="servicetask2" name="Service Task" activiti:class="org.myJavaClass"
    activiti:resultVariable="varFromJavaTask" activiti:expression="#{myObj.doSomething()}"></serviceTask>
    <sequenceFlow id="flow3" name="" sourceRef="startevent1" targetRef="servicetask2"></sequenceFlow>
    <endEvent id="endevent2" name="End"></endEvent>
    <sequenceFlow id="flow4" name="" sourceRef="servicetask2" targetRef="usertask1"></sequenceFlow>
    <userTask id="usertask1" name="User Task" activiti:assignee="kermit">
      <documentation textFormat="text/plain">Message from JavaTask: ${varFromJavaTask}</documentation>
    </userTask>
    <sequenceFlow id="flow5" name="" sourceRef="usertask1" targetRef="endevent2"></sequenceFlow>
  </process>


But when I start a process instance in Activiti explorer there comes an exception which tells me that the given class cannot be instanciated: 03110005 Wrapped Exception (with status template): couldn't instantiate class org.myJavaClass
1 REPLY 1

frederikherema1
Star Contributor
Star Contributor
Hi,

Do you deploy your process on tomcat? If so, make sure the jar containing your classes in in the web-inf/lib of your webapp.
If not in webapp-context, check your classpath, the class should be present on it.