ELException in Spring Webflow

If an ELException has occurred in Spring Webflow, check the error message and the method where the error has occurred. In a case that I have encountered, the flowScope variable in the flow.xml file did not match the defined variable in the Service interface file. Below is an example of a correct flow.xml and service.java variable mapping. If in case the return of methodA is changed to Integer instead of String, this will throw an ELExeption on runtime. However, the code will compile without any errors.

Service Interface file (Interface.java)


public interface InterfaceService {

//....

String methodA(){

//....

}

String methodB(String parameterB){

//....

}

Service Implementation file (Implementation.java)


public class Implementation implements InterfaceService {

//implements methodA and methodB

Spring webflow (flow.xml) file


<evaluate expression="InterfaceService.methodA()" result="flowScope.stringValue" />
<evaluate expression="InterfaceService.methodB(stringValue)"/>

EL is an abreviation of Expresion Language in Spring Webflow. The flowScope variable is one of several variables provided by Spring Webflow. Other Spring Webflow variables such as requestScope, flashScope and viewScope can also cause an ELException when a mismatch of data types occur.

Spring documentation on EL ( Expression Language ) and flowScope found in 4.4.1
http://docs.spring.io/autorepo/docs/webflow/2.3.x/reference/html/el.html

JSON format

taken from http://en.wikipedia.org/wiki/JSON

JSON

{
  "firstName": "John",
  "lastName": "Smith",
  "age": 25,
  "address": {
    "streetAddress": "21 2nd Street",
    "city": "New York",
    "state": "NY",
    "postalCode": "10021"
  },
  "phoneNumber": [
    {
      "type": "home",
      "number": "212 555-1234"
    },
    {
      "type": "fax",
      "number": "646 555-4567"
    }
  ],
  "gender": {
    "type": "male"
  }
}

YAML

---
firstName: John
lastName: Smith
age: 25
address: 
  streetAddress: 21 2nd Street
  city: New York
  state: NY
  postalCode: 10021
phoneNumber: 
- type: home
  number: 212 555-1234
- type: fax
  number: 646 555-4567
gender: 
  type: male

XML

<person>
  <firstName>John</firstName>
  <lastName>Smith</lastName>
  <age>25</age>
  <address>
    <streetAddress>21 2nd Street</streetAddress>
    <city>New York</city>
    <state>NY</state>
    <postalCode>10021</postalCode>
  </address>
  <phoneNumbers>
    <phoneNumber>
      <type>home</type>
      <number>212 555-1234</number>
    </phoneNumber>
    <phoneNumber>
      <type>fax</type>
      <number>646 555-4567</number>
    </phoneNumber>
  </phoneNumbers>
  <gender>
    <type>male</type>
  </gender>
</person>