Wich field causes exception when marshalling?

14 views
Skip to first unread message

scout

unread,
Oct 2, 2019, 11:25:58 AM10/2/19
to ZUGFeRD
Hello,
I am new to Zugferd and Mustang. My goal is to add Zugferd-XML-data to PDF invoices that I create in my application.
So I added the Mustang 1.7.4 Maven dependency to my Java 11 project.
The MustangWriter-example worked so far.

Then I changed the code to use my own data from a database instead of the sample data.
Now I get the following exception:

Could not marshal ZUGFeRD transaction to XML / javax.xml.bind.MarshalException
 - with linked exception:
[com.sun.istack.SAXException2: com.sun.xml.bind.api.AccessorException: Objekt muss einen Wert im @XmlValue-Feld enthalten: org.mustangproject.ZUGFeRD.model.TextType@af6eb09
com.sun.xml.bind.api.AccessorException: Objekt muss einen Wert im @XmlValue-Feld enthalten: org.mustangproject.ZUGFeRD.model.TextType@af6eb09]

Apparently, some data isn't what it should be.
Is there a way to get to know wich data field exactly causes the problem? So the user knows what to fix.

Any help is apreciated. I am stuck there for days.

Jochen Stärk

unread,
Oct 2, 2019, 4:27:03 PM10/2/19
to ZUGFeRD
Hi,

The bad news is I have no freaking idea how to find out which field it is, which is a very unpleasant situation and one of the reasons why I am about to trash the JAXB approach for ZF1.
The good news is twofold, first that this is one of the rare cases where I accidentally have a very similar problem, so I don't need to ask for further steps to reproduce.
Secondly: it works in ZF2, so if you do sth like

 ZUGFeRDExporter ze = new ZUGFeRDExporterFromA1Factory().setProducer("My Application")

        .setCreator(System.getProperty("user.name"))

        .setZUGFeRDVersion(2)

        .load("./MustangGnuaccountingBeispielRE-20190610_507blanko.pdf"); 
already on loading, it should work or at least give you a decent stacktrace. 
It may be some attributes in payment for getTradeSettlementPayment.

Still trying to find out.
kind regards
Jochen

scout

unread,
Oct 3, 2019, 8:22:20 AM10/3/19
to ZUGFeRD

Thank you Jochen.

It was indeed a TradeSettlementPayment-problem.
The method getTradeSettlementPayment() causes a null pointer exception if you return null.
To fix this, I returned a TradeSettlementPayment-array containing a dummy entry without bank account data.
This apparently caused the problem.
Returning just an empty array instead seems to work.

Jochen Stärk

unread,
Oct 3, 2019, 8:32:47 AM10/3/19
to ZUGFeRD
Hi,
I definitely need to document that.
I solved my issue (Main.java) with a Payment that contains e.g. a german Bankleitzahl and Kontonummer (MainCompare.java). 
That was definitely replaced by IBAN but in ZF1 for historical reasons it was still possible to be specified, in ZF2 it the field has been entirely forbidden.

thanks for pointing me to that issue and
kind regards
Jochen
Main.java
MainCompare.java
Reply all
Reply to author
Forward
0 new messages