AnsweredAssumed Answered

null pointer exception

Question asked by habibhalaoui on May 19, 2013
Latest reply on May 21, 2013 by avc
hello I can not solve this problem of nullpinterExeption ie have the value of loan Amount
the XML file
<process id="loanrequest" name="Process to handle a loan request" isExecutable="true">
  <extensionElements>
     <activiti:executionListener class="org.bpmnwithactiviti.chapter5.listener.ProcessStartExecutionListener" event="start" />
         <activiti:executionListener class="org.bpmnwithactiviti.chapter5.listener.ProcessEndExecutionListener" event="end" />
       </extensionElements>
    <startEvent id="theStart" >
      <extensionElements>
        <activiti:formProperty id="name" name="Name" type="string" required="true"></activiti:formProperty>
        <activiti:formProperty id="emailAddress" name="Email address" type="string" required="true"></activiti:formProperty>
        <activiti:formProperty id="income" name="Income" type="long" required="true"></activiti:formProperty>
        <activiti:formProperty id="loanAmount" name="Loan amount" type="long" required="true" ></activiti:formProperty>
         
      </extensionElements>
    </startEvent>
   
    <sequenceFlow id="sequenceFlow-d450f4a5-4e6f-4b3e-8451-07228a5b1b0d" sourceRef="theStart" targetRef="checkCredit"></sequenceFlow>
    <scriptTask id="checkCredit" scriptFormat="groovy" activiti:autoStoreVariables="true">
      <script>
            out:println "Checking credit for " + name;
            creditCheckOk = false;
            if((income / 2) &gt; loanAmount){
               creditCheckOk = true;
            }
            out:println "Checked credit for " + name + " outcome is " + creditCheckOk;
         </script>
    </scriptTask>
    <sequenceFlow id="sequenceFlow-b5777c55-420a-426c-9245-44fcb83e4df4" sourceRef="checkCredit" targetRef="createApplication"></sequenceFlow>
    <serviceTask id="createApplication" activiti:class="org.bpmnwithactiviti.chapter5.CreateApplicationTask"></serviceTask>
    <sequenceFlow id="sequenceFlow-a205db56-b336-492d-92b1-3c7996441546" sourceRef="createApplication" targetRef="evaluateLoanRequest"></sequenceFlow>
    <userTask id="evaluateLoanRequest" name="Evaluate loan request" activiti:assignee="fozzie">
      <extensionElements>
        <activiti:formProperty id="customerName" name="Customer name" expression="${loanApplication.customerName}" writable="false"></activiti:formProperty>
        <activiti:formProperty id="income" name="Income of customer" expression="${loanApplication.income}" writable="false"></activiti:formProperty>
        <activiti:formProperty id="requestedAmount" name="Requested loan amount" expression="${loanApplication.requestedAmount}" writable="false"></activiti:formProperty>
        <activiti:formProperty id="creditCheckOk" name="Outcome of credit check" expression="${loanApplication.creditCheckOk}" writable="false"></activiti:formProperty>
        <activiti:formProperty id="requestApproved" name="Do you approve the request?" type="enum" required="true">
          <activiti:value id="true" name="Yes"></activiti:value>
          <activiti:value id="false" name="No"></activiti:value>
        </activiti:formProperty>
        <activiti:formProperty id="explanation" name="Explanation"></activiti:formProperty>
      </extensionElements>
    </userTask>


<h1>LoanApplication.java </h1>


public class LoanApplication implements Serializable {

   private static final long serialVersionUID = 1L;
   
   private String customerName;
   private long income;
   private long requestedAmount;
   private boolean creditCheckOk;
   private String explanation;
   private String emailAddress;
   private long loanAmount;
   
   public String getCustomerName() {
     return customerName;
  }
   public void setCustomerName(String customerName) {
     this.customerName = customerName;
  }
   public long getIncome() {
     return income;
  }
   public void setloanAmount(long loanamount) {
     this.loanAmount = loanamount;
  }
   public long getloanAmount() {
        return loanAmount;
     }
      public void setIncome(long income) {
        this.income = income;
     }
   public long getRequestedAmount() {
     return requestedAmount;
  }
   public void setRequestedAmount(long requestedAmount) {
     this.requestedAmount = requestedAmount;
  }
   public boolean isCreditCheckOk() {
     return creditCheckOk;
  }
   public void setCreditCheckOk(boolean creditCheckOk) {
     this.creditCheckOk = creditCheckOk;
  }
   public String getExplanation() {
     return explanation;
  }
   public void setExplanation(String explanation) {
     this.explanation = explanation;
  }
   public String getEmailAddress() {
     return emailAddress;
  }
   public void setEmailAddress(String emailAddress) {
     this.emailAddress = emailAddress;
  }
}

CreateApplicationTask


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);
   }
}

ProcessStartEvent.java


public class ProcessStartExecutionListener implements ExecutionListener {


   @Override
   public void notify(DelegateExecution execution) throws Exception {
      
      LoanRequestReceivedEvent event = new LoanRequestReceivedEvent(
         execution.getId(),
         new Date().getTime(),
         (Integer) execution.getVariable("loanAmount"));
      
      EventSender.send(event);
   }
}



How can I read the value of the form LoanAmount?

Outcomes