JavaBeans serialization to XML - suggestions?

28 views
Skip to first unread message

Robert Bates

unread,
Oct 5, 2017, 12:22:21 PM10/5/17
to Units Users

Hello all!  I'm using the UOM-SE library in a simulation project, and am running into a bit of trouble when trying to serialize objects containing ComparableQuantity objects via XMLEncoder.  A minimal sample codebase that exhibits the problem (with most of the original classes involved intact) can be found at https://gist.github.com/arpieb/d9f469ef9bd7ecefea510f1d2e255e60.  The SimulationParameter objects export, but due to exceptions thrown trying to export the UOM objects, no values show up in the XML output.  Errors I am seeing are:

java.lang.InstantiationException: tec.uom.se.quantity.NumberQuantity
Continuing ...
java
.lang.RuntimeException: failed to evaluate: <unbound>=Class.new();
Continuing ...
java
.lang.InstantiationException: tec.uom.se.quantity.DoubleQuantity
Continuing ...
java
.lang.RuntimeException: failed to evaluate: <unbound>=Class.new();
Continuing ...

(repeated several times)

I tried to register a DefaultPersistenceDelegate on the XMLEncoder to handle ComparableQuantity by converting the quantity to a string but it is never getting called - and neither does one registered for NumberQuantity.  Apparently the DoubleQuantity class does not exist so I cannot register a DefaultPersistenceDelegate for it.  Any suggestions as to how I can get this to work?

Thanks!
-R

Werner Keil

unread,
Oct 5, 2017, 3:51:04 PM10/5/17
to Units Users
Hello,

Thanks for your message. DoubleQuantity does exist but it is package-local and considered an implementation detail as it is now (accessible by NumberQuantity only) I will check out your example and possible remedies after I come back from JavaOne. 

Regards,
Werner
Message has been deleted

Werner Keil

unread,
Oct 6, 2017, 5:07:03 PM10/6/17
to Units Users
You could also file an issue under https://github.com/unitsofmeasurement/uom-se/issues describing the problem if you want.

Robert Bates

unread,
Oct 7, 2017, 12:01:54 PM10/7/17
to Units Users
For reference, I have opened an issue on the uom-se project on Github here: https://github.com/unitsofmeasurement/uom-se/issues/182
Reply all
Reply to author
Forward
0 new messages