MartinoMensio / DP2-Labs

Distributed Programming 2 Laboratories @ Polytechnic University of Turin
MIT License
1 stars 0 forks source link

Not producing XML #21

Closed MartinoMensio closed 7 years ago

MartinoMensio commented 7 years ago

The service only produces JSON. When requesting XML, HTTP error 500 is thrown. In catalina log:

org.glassfish.jersey.message.internal.WriterInterceptorExecutor$TerminalWriterInterceptor aroundWriteTo
GRAVE: MessageBodyWriter not found for media type=application/xml, type=class it.polito.dp2.NFFG.sol3.service.jaxb.NffgT, genericType=class it.polito.dp2.NFFG.sol3.service.jaxb.NffgT.

The cause of this problem is that the Entity provider for the generated types cannot be found. This is probably due to a missing library

MartinoMensio commented 7 years ago

this issue exists also on client side, both XML and JSON

MartinoMensio commented 7 years ago

This is due to the fact that global elements with named type have no correspondance to generated classes, because the generated class is for the named type. If the global element has an anonymous type, the generated class is annotated with @XmlRootElement. This annotation makes the Entity provider to work with XML.

Currently the main issues are two:

MartinoMensio commented 7 years ago

Can create root elements by using the public JAXBElement<LinkT> createLink(LinkT value) methods that create the element from the type Objects. In this way the two issues are avoided

MartinoMensio commented 7 years ago

If JAXBElement is used, XML clients works perfectly while JSON clients get strange objects. Better to have unnamed types