cancel
Showing results for 
Search instead for 
Did you mean: 

CreateApplicationTask in chapter 5

johnrd
Champ in-the-making
Champ in-the-making
Hi,

I am going through the code examples from the book Activiti in action. I have deployed the project in chapter 5 onto my tomcat server.
the jar file as well as the bar file are deployed. However when I start the  lone application process with the form data as specified in the book I am getting a error  in the createapplicationtask   as such

   … 30 more
Caused by: java.lang.NullPointerException
   at org.bpmnwithactiviti.chapter5.CreateApplicationTask.execute(CreateApplicationTask.java:10)
   at org.activiti.engine.impl.delegate.JavaDelegateInvocation.invoke(JavaDelegateInvocation.java:34)

I could not figure out how or why this is happening.

Help will much needed.

thanks

John.

6 REPLIES 6

frederikherema1
Star Contributor
Star Contributor
What is exactly on line 10 of the createApplicationTask?

johnrd
Champ in-the-making
Champ in-the-making
Hi,

The code is exactly as in the book code sample

line 10  is    la.setCreditCheckOk((Boolean) execution.getVariable("creditCheckOk"));

///// code fragment given below///

public class CreateApplicationTask implements JavaDelegate {

public void execute(DelegateExecution execution) {
  LoanApplication la = new LoanApplication();
  la.setCreditCheckOk((Boolean) execution.getVariable("creditCheckOk"));
  la.setCustomerName((String) execution.getVariable("name"));
  la.setIncome((Long) execution.getVariable("income"));
  la.setRequestedAmount((Long) execution.getVariable("loanAmount"));
  la.setEmailAddress((String) execution.getVariable("emailAddress"));
  execution.setVariable("loanApplication", la);
}
}

trademak
Star Contributor
Star Contributor
Hi,

Are you testing this with Activiti 5.12.1? The reason why I'm asking this is because we changed the automatic promotion of script variables to execution variables.

Best regards,

johnrd
Champ in-the-making
Champ in-the-making
yes it is the latest distribution from the site    activiti 5.12.1

trademak
Star Contributor
Star Contributor
Ok, please read the user guide section about script tasks (http://www.activiti.org/userguide/index.html#bpmnScriptTask)
You should explicitly set the variable now like:

<blockcode>
<script>
    def scriptVar = "test123"
    execution.setVariable("myVar", scriptVar)
</script>
</blockcode>

That should prevent the nullpointer from being thrown.

Best regards,

johnrd
Champ in-the-making
Champ in-the-making
thanks for your help.
I would like to point out that just after I had this problem with creatapplicationtask , i could no longer login to activity explorer as described here  http://forums.activiti.org/content/cant-login-activiti-explorer

I'm not sure how to fix this issue