Axon.ivy 7.0 - the Digital Business Platform - is out now...

ivy 5.0.9

I created an Helper Class which should serialize / deserialize a Java Bean with the java.beans.XMLEncoder / XMLDecoder Class. Serialization works great, but if I want to deserialize the xml string within an Ivy Script Element, I got the following Error: java.lang.ArrayIndexOutOfBoundsException: 0

If I do the deserialization within the Helper Class itself (as described as follows), the deserialization works great. Is there a way to bring it working within the Ivy Script Step?

Thanks in advance for your ideas...

Helper Class "decode"

public Employee decode(String xml) {
    try {           
        XMLDecoder decoder = new XMLDecoder(IOUtils.toInputStream(xml, "UTF-8"));
        Employee employee = (Employee) decoder.readObject();
        return employee;
    } catch (Exception ex) {
        Ivy.log().error(ex.getMessage(), xml);
        return null;            

Calling the method using Ivy Script Step (Not working)

import test.XmlHelper;
import test.Employee;
try {
    XmlHelper xh = new XmlHelper();
    in.employee = xh.decode(in.usrData); 
    (in.employee is a DataClass Attr. of type Employee
    in.usrData is a DataClass Attr. of type String containing the xml String)
} catch (Exception ex) {
    in.errmsg = ex.getMessage();

Calling the method directly in the Helper Class by main method (Works great)

public static void main(String[] args) {        
    XmlHelper xh = new XmlHelper();     
    Employee employee = new Employee();
    employee = xh.decode("<java version='1.7.0_17' class='java.beans.XMLDecoder'><object class='test.Employee'><void property='firstName'><string>Vorname</string></void><void property='lastName'><string>Nachname</string></void>");


Bean Employee (in ivy located under /src/test/entity )

package test.entity;


public class Employee implements Serializable {         
private static final long serialVersionUID = 1L;
private String      lastname        = "";   
private String      firstname       = "";   
public String getLastName() {
    return lastname;
public void setLastName(String lastname) {
    this.lastname = lastname;
public String getFirstName() {
    return firstname;
public void setFirstName(String firstname) {
    this.firstname = firstname;


asked 24.02.2014 at 14:24

Stefan's gravatar image

accept rate: 50%

edited 05.03.2014 at 09:00

Flavio%20Sadeghi's gravatar image

Flavio Sadeghi ♦♦

Hi Stefan, could you please provide a stacktrace of the ArrayIndexOutOfBoundsException? Also: if you log the in.usrData is the String in the right format or is it somehow escaped?

(07.03.2014 at 12:44) Peter Stöckli ♦ Peter%20St%C3%B6ckli's gravatar image

Hi Peter

I did the serialization/deserialization with another - free available - library: the simple-xml. With it, it works without any problems and quite fast.

The library is available at

Thanks and regards, Stefan


answered 28.03.2014 at 13:13

Stefan's gravatar image

accept rate: 50%

edited 28.03.2014 at 13:57

Flavio%20Sadeghi's gravatar image

Flavio Sadeghi ♦♦

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported



Asked: 24.02.2014 at 14:24

Seen: 2,237 times

Last updated: 28.03.2014 at 13:57