Welcome to this Blog. I am Software Engineer and work for Zühlke Engineering AG in Bern. This is my private blog, in which I will post mainly about technical stuff like Software Engineering or IT related topics. The views expressed herein do not necessarily represent those of my employer.
This is the last hint this week. While working with JiBX, I had the situation, that there were some null values in the Java class.
JiBXTestApplication Exception in thread "main" org.jibx.runtime.JiBXException: null value for element "{http://stefanjaeger.ch/CustomerSchema}city" from object of type ch.stefanjaeger.jibx.Customer at org.jibx.runtime.impl.MarshallingContext.element(MarshallingContext.java:713) at ch.admin.bit.edec.common.declaration.Versandvorgang.JiBX_binding_marshal_1_0(Unknown Source) at ch.admin.bit.edec.common.declaration.Deklaration.JiBX_binding_marshal_1_0(Unknown Source) at ch.admin.bit.edec.common.declaration.JiBX_bindingDeklaration_access.marshal() at ch.admin.bit.edec.common.declaration.Deklaration.marshal(Unknown Source) at org.jibx.runtime.impl.MarshallingContext.marshalRoot(MarshallingContext.java:1041) at org.jibx.runtime.impl.MarshallingContext.marshalDocument(MarshallingContext.java:1111) at ch.admin.bit.test.jibx.JiBXTestApplication.main(Unknown Source)
Per default, JiBX doesn’t allow null values. If there is a null value, it throws an JiBXException while marshalling.
To allow null values, you have to define explicit the attribute usage="optional" on a value or structure element in the binding file. If JiBX finds a null pointer on a member, JiBX does not fill an empty value to the xml element, JiBX will skip the element.
