Hi Emmanuel, It's great that you are porting your code to SIS! Thanks for the feedback. I think that Martin and his team are best suited to answer such a question...
Cheers, Adam On Tue, Jul 22, 2014 at 9:13 AM, Emmanuel Blondel <[email protected]> wrote: > 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: [email protected] - [email protected] > View my LinkedIn profile
