moxy

com.sun.istack.SAXException2: class java.util.LinkedHashMap nor any of its super class is known to this context

浪子不回头ぞ 提交于 2019-12-06 10:46:57
I am sending a POST request create a resource named ContentInstance . Resource: ContentInstance . // // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 import java.math.BigInteger; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlSchemaType; import javax.xml.bind.annotation.XmlType; @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "", propOrder = {

List wrappers in JAXB MOXy

本秂侑毒 提交于 2019-12-06 10:46:55
I am declaring a List object property with: @XmlRootElement(namespace = "...") @XmlType public class Test { private List<String> myList; @XmlElementWrapper(name = "myListWrapper") @XmlElement(name = "myList") public List<String> getMyList() { return myList; } } When an instance of this class with an empty list myList is marshalled, MOXy is not generating an empty wrapper MyListWrapper . However, JAXB RI would do it. The generated XML looks like this when using the RI: <ns2:test xmlns:ns2="..."> <myListWrapper/> </ns2:intensionalSet> Is there a way to obtain the same result with MOXy? Note: I'm

Set MOXy as JAXB Provider without properties file in the same package

China☆狼群 提交于 2019-12-06 09:28:36
问题 I am trying to use MOXy as my JAXB provider in order to marshal/unmarshal content into XML/JSON. I have created the "jaxb.properties" file with as content : javax.xml.bind.context.factory=org.eclipse.persistence.jaxb.JAXBContextFactor Everything works fine. JAXBContext jaxbContext = JAXBContext.newInstance(ServerInformation.class); // The jaxb.properties must be in the same package as "ServerInformation.java" Marshaller marshaller = jaxbContext.createMarshaller(); marshaller.setProperty

Custom MOXyJsonProvider in Jersey 2 not working?

前提是你 提交于 2019-12-06 04:13:26
问题 I was reading over the answer for Moxy ignore invalid fields in json and the approach matched something I'm trying to do, so I decided to give it a shot.. I created a feature to disable the default ConfigurableMoxyJsonProvider; @Provider public class JsonFeature implements Feature { @Override public boolean configure(final FeatureContext context) { final String disableMoxy = CommonProperties.MOXY_JSON_FEATURE_DISABLE + '.' + context.getConfiguration().getRuntimeType().name().toLowerCase();

How to set namespace aware to false?

坚强是说给别人听的谎言 提交于 2019-12-06 00:32:33
问题 I'm trying to parse some XML with EclipseLink MOXy, and it's failing on the line with the xsi attribute. If I remove this, it parses fine. However, I've got 100GiB of XML to wade through and changing the source files is not an option. It's been suggested that if I can set XmlParser.setNamespaceAware(false) then it should work - but I've got no idea how to configure this, without breaking right into the guts of MOXy. <record> <header> <!-- citation-id: 14404534; type: journal_article; -->

How to remove xmlns:xsi and xsi:type from JAXB marshalled XML file

▼魔方 西西 提交于 2019-12-06 00:13:53
问题 I've got a set of JAXB generated classes and some of the classes have setter methods which accepts "Object" as the parameter. For example: @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name="Car", propOrder = { "defaultCar" } public class Car { @XmlElement(name = "DefaultCar") protected Object defaultcar; public void setDefaultCar(Object value) { this.defaultCar = value; } After I've created instances of these classes in my code, I call the setter methods passing in the required value.

A recommended JAX-WS framework for working with Moxy

拥有回忆 提交于 2019-12-05 16:27:08
Currently I'm working with CXF but because of the following code in CXF: // fall back if we're using another jaxb implementation try { riContext = JAXBUtils.createRIContext(contextClasses .toArray(new Class[contextClasses.size()]), tns); } CXF loads both Moxy and the RI JAXB context (Probably depends on non standard APIs). The overhead in startup time and memory is too high in my case. I'm looking for a good open source JAX-WS implementation (CXF replacement) which will work with Moxy as expected. The Metro implementation of JAX-WS (that GlassFish uses) can easily be configured to use MOXy as

Staying DRY with JAXB

纵饮孤独 提交于 2019-12-05 16:23:12
I'm developing a number of Java classes that must serialize to XML in the following format: <foo value="123"/> <!-- or this --> <bar value="abc"/> <!-- or this --> <baz value="true"/> In the beginning, Foo.java looked something like this: @XmlRootElement @XmlAccessorType(XmlAccessType.FIELD) class Foo { @XmlAttribute String value; // snip constructors // snip methods // getValue // equals, hashCode, toString // static valueOf(String), static valueOf(int) } It doesn't take much imagination to guess what Bar.java and Baz.java might look like. These are very simple wrapper classes for (in this

Moxy ignore invalid fields in json

大城市里の小女人 提交于 2019-12-05 16:09:10
When I send this request: {"invalidField": "value", "date": "value"} to my rest service: @PUT @Consumes("application/json") public void putJson(Test content) { System.out.println(content.toString()); } I expected to get an exception because: There is no invalidField in my domain model. Date format is not valid. But really I get test object with null values. My dmain model is: public class Test { private String name; private Date date; //getters and setters here } I think this is not a valid behavior. How can I fix that? Thanks for help. Solution: As Blaise Doughan said, it is required to

MOXy's @XmlCDATA seems to have no affect

佐手、 提交于 2019-12-05 14:07:56
I would like to have the following returned to the browser (view source) <content> <![CDATA[Please show this inside a unescaped CDATA tag]]> </content> But I acutally get <content> Please show this inside a unescaped CDATA tag </content> If, I change the value of content to be &lt ;![CDATA[Please show this inside a unescaped CDATA tag]]&gt ; , the less than and the greater than for the tag are escaped. Wondering how to achieve what I wanted???? Here is my code import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core