[geotk] Moving from geotk to Apache-sis - problems with metadata xml marshalling
Emmanuel Blondel
emmanuel.blondel1 at gmail.com
Tue Jul 22 06:13:49 PDT 2014
Hello,
i'm moving now from geotoolkit to Apache SIS, progressively, by using
Geotk 4.0-M1 which uses some apache SIS modules (0.3-jdk7), and in the
meantime, moving from jdk6 to jdk7.
What i have is a class that extends the DefaultMetadata.
I have a marshaller unit test that works fine. And the main application
of my program works fine to marshall the metadata when i use it directly
from Eclipse.
To use the my tool outside Eclipse, i've built a shaded Jar with Maven
to embedd all dependencies.
But when i try to to run it the main application from command line, i
get an error dealing with JAXB context.
I was previously using similar code with geotk, and it was working properly.
The first error i get deals with the missing annotation
@XmlRootElement(name = "MD_Metadata") for my subclass
/Exception in thread "main" java.lang.Exception: Fail to publish
data/metadata pair//
// at
org.fao.fi.gems.publisher.Publisher.publish(Publisher.java:91)//
// at
org.fao.fi.gems.application.MetadataGenerator.main(MetadataGenerator.java:178)//
//Caused by: java.lang.Exception: Failed to publish metadata//
// at
org.fao.fi.gems.publisher.MetadataPublisher.publishMetadata(MetadataPublisher.java:104)//
// at
org.fao.fi.gems.publisher.Publisher.publish(Publisher.java:68)//
// ... 1 more//
//Caused by: javax.xml.bind.MarshalException//
// - with linked exception://
//[com.sun.istack.internal.SAXException2: unable to marshal type
"org.fao.fi.gems.GemsMetadata" as an//
//element because it is missing an @XmlRootElement annotation]//
// at
com.sun.xml.internal.bind.v2.runtime.MarshallerImpl.write(Unknown Source)//
// at
com.sun.xml.internal.bind.v2.runtime.MarshallerImpl.marshal(Unknown
Source)//
// at
javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(Unknown Source)//
// at
org.apache.sis.xml.PooledMarshaller.marshal(PooledMarshaller.java:138)//
// at org.apache.sis.xml.XML.marshal(XML.java:374)//
// at
org.fao.fi.gems.publisher.MetadataPublisher.publishMetadata(MetadataPublisher.java:84)//
// ... 2 more//
//Caused by: com.sun.istack.internal.SAXException2: unable to marshal
type "org.fao.fi.gems.GemsMetada//
//ta" as an element because it is missing an @XmlRootElement annotation//
// at
com.sun.xml.internal.bind.v2.runtime.XMLSerializer.reportError(Unknown
Source)//
// at
com.sun.xml.internal.bind.v2.runtime.ClassBeanInfoImpl.serializeRoot(Unknown
Source)//
// at
com.sun.xml.internal.bind.v2.runtime.XMLSerializer.childAsRoot(Unknown
Source)//
// ... 8 more/
After adding the missing annotation, everything still works (tests, main
app in Eclipse)
If i try to run the app with the shaded jar, i get the following error:
/Exception in thread "main" java.lang.Exception: Fail to publish
data/metadata pair//
// at
org.fao.fi.gems.publisher.Publisher.publish(Publisher.java:91)//
// at
org.fao.fi.gems.application.MetadataGenerator.main(MetadataGenerator.java:178)//
//Caused by: java.lang.Exception: Failed to publish metadata//
// at
org.fao.fi.gems.publisher.MetadataPublisher.publishMetadata(MetadataPublisher.java:104)//
// at
org.fao.fi.gems.publisher.Publisher.publish(Publisher.java:68)//
// ... 1 more//
//Caused by: javax.xml.bind.MarshalException//
// - with linked exception://
//[com.sun.istack.internal.SAXException2: unable to marshal type
"org.fao.fi.gems.GemsMetadata" as an//
//element because it is not known to this context.]//
// at
com.sun.xml.internal.bind.v2.runtime.MarshallerImpl.write(Unknown Source)//
// at
com.sun.xml.internal.bind.v2.runtime.MarshallerImpl.marshal(Unknown
Source)//
// at
javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(Unknown Source)//
// at
org.apache.sis.xml.PooledMarshaller.marshal(PooledMarshaller.java:138)//
// at org.apache.sis.xml.XML.marshal(XML.java:374)//
// at
org.fao.fi.gems.publisher.MetadataPublisher.publishMetadata(MetadataPublisher.java:84)//
// ... 2 more//
//Caused by: com.sun.istack.internal.SAXException2: unable to marshal
type "org.fao.fi.gems.GemsMetada//
//ta" as an element because it is not known to this context.//
// at
com.sun.xml.internal.bind.v2.runtime.XMLSerializer.reportError(Unknown
Source)//
// at
com.sun.xml.internal.bind.v2.runtime.ClassBeanInfoImpl.serializeRoot(Unknown
Source)//
// at
com.sun.xml.internal.bind.v2.runtime.XMLSerializer.childAsRoot(Unknown
Source)//
// ... 8 more//
/
Do you have any idea what is wrong? (and also why would i need to add
/xmlRootElement/? )
What are the differences between the geotk JAXB xml marshaller and the
Apache SIS one?
I would be very grateful if you could advice how to solve this...
Many thanks in advance
Kind regards
--
*Emmanuel Blondel*
GIS Consultant
Engineer in Agronomy & Environment
Geographic Information Systems
in Agronomy - Environment - Fisheries
Email: emmanuel.blondel1 at gmail.com - Emmanuel.Blondel at fao.org
View my LinkedIn profileView my LinkedIn profile
<http://fr.linkedin.com/in/emmanuelblondel1>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/geotoolkit/attachments/20140722/92898dd7/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: btn_in_20x15.png
Type: image/png
Size: 288 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/geotoolkit/attachments/20140722/92898dd7/attachment.png>
More information about the Geotoolkit
mailing list