moxy

How do you get MOXy oxml mapping file to recognise static classes

廉价感情. 提交于 2019-12-10 16:37:42
问题 Using MOXy I can flatten parts of my object model in my json output i.e <java-type name="Medium"> <java-attributes> <xml-element java-attribute="trackList" xml-path="."/> </java-attributes> </java-type> but when I want to fold in a class that is a child of a static class as follows <java-type name="Medium.TrackList"> <java-attributes> <xml-element java-attribute="artistList" xml-path="."/> </java-attributes> </java-type> it complains Exception Description: Could not load class [Medium

How to generate Java from an XSD using MOXy under Maven-3?

早过忘川 提交于 2019-12-10 15:49:06
问题 What's the easiest/best way to generate Java from an XSD using MOXy under Maven-3? The reference JAXB interface has a nice Maven plugin, but it doesn't appear to support MOXy. Does anyone have anything concrete to offer? (I know I can write ant-script, or a plugin, or ...) 回答1: EclipseLink MOXy, does not yet offer a Maven plugin to run the XML schema to Java compiler. I have entered the following enhancement request to track this functionality: https://bugs.eclipse.org/346486 MOXy leverages

Moxy, JSON and Jersey 2.0 does not deserialize plain String array

旧时模样 提交于 2019-12-10 14:43:49
问题 In my current setup I use Jersey 2.0 with MOXy as discribed in jersey docs. I rely completely on the “Auto-Discoverable Features”, so I do not use any extra configuration or JAXB annotation. My task is to deserialize an array of strings on the server side. The client is sending the JSON message: ["foo","bar"] And on the server side the following method header should deserialize it: @POST @Path("/stringArray") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) public

Cannot get EclipseLink MOXy to work

大憨熊 提交于 2019-12-10 13:25:34
问题 I'm new to JAXB and I want to change the default namespace prefix using EclipseLink MOXy. My package-info.java has the following code lines: @javax.xml.bind.annotation.XmlSchema ( namespace="http://namespace.mysite.com/", xmlns = { @javax.xml.bind.annotation.XmlNs(prefix="myns", namespaceURI="http://namespace.mysite.com/") }, elementFormDefault = javax.xml.bind.annotation.XmlNsForm.UNQUALIFIED ) package com.core.mymodel; And my jaxb.properties file has the following line: javax.xml.bind

MOXy/JAXB interface annotation

雨燕双飞 提交于 2019-12-10 11:34:30
问题 I have a model that consists of an interface with one annotated property, and a concrete implementor that does not re-annotate the implementation of that property. Why doesn't this unmarshal correctly (using MOXy 2.5.0)? I get a correctly constructed object, but the property is never bound to the XML: <!-- XML --> <InterfaceImpl id="5150" /> /** * Annotated interface */ @XmlRootElement(name="IInterface") public interface IInterface { @XmlAttribute(name="id") public void setId(int id); } /** *

EclipseLink MOXy: Logical operators in XmlPath annotation

≯℡__Kan透↙ 提交于 2019-12-10 11:05:32
问题 Do logical operators work in XmlPath annotations of EclipseLink MOXy? I tried and could not make it work (no Exception is thrown and nothing is bound to "elements"). For example, I would like to have in a bindings file something like this: <java-type name="Content"> <java-attributes> <xml-element java-attribute="elements" xml-path="/a/b/ | /c/d" type="ElementType" container-type="java.util.List" /> </java-attributes> </java-type> Is there a way to achieve the same result from a modification

How to configure JAXB / Moxy to throw an error on potential lost data in XML

陌路散爱 提交于 2019-12-10 10:52:23
问题 Is it possible to configure JAXB to throw an exception if the supplied data is not unmarshalable into the expected data type? We have a Integer XmlElement and sometimes get values like "1.1" as input - Jaxb / Moxy just silently ignores these values and sets them to null. We solved it for the known cases by using a @XmlJavaTypeAdapter that rounds those values, but we won't know if any other fields get silently ignored on wrong data and would prefer a exception for clear feedback.

Jersey 2.0 and Moxy Internal Server Error But No Server Log

為{幸葍}努か 提交于 2019-12-10 01:38:32
问题 I followed the Jersey 2.0 document (https://jersey.java.net/documentation/latest/user-guide.html#json.moxy), modified pom.xml, included jersey-media-moxy artifact, compiled and installed. I could get basic POJO to JSON mapping work for both Produces and Consumes cases. However, when I tried with some POJO with complex data type as resource return type, I got a lot Status 500 Internal Server Error but without any server log. It is very annoying. Does anybody know if it is a bug or I missed

Using generic @XmlJavaTypeAdapter to unmarshal wrapped in Guava's Optional

牧云@^-^@ 提交于 2019-12-09 20:19:41
问题 I'm trying to unmarshal some xml into java objects wrapped in Guava's Optional using a generic XmlJavaTypeAdapter. However, I can't get it to work properly using generics. I'm using eclipselink 2.5.1 / moxy XML: <?xml version="1.0" encoding="UTF-8"?> <page> <label>Test</label> <description>Test</description> </page> Page.java: import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind

MOXy/JAXB interface annotation

那年仲夏 提交于 2019-12-09 06:26:26
I have a model that consists of an interface with one annotated property, and a concrete implementor that does not re-annotate the implementation of that property. Why doesn't this unmarshal correctly (using MOXy 2.5.0)? I get a correctly constructed object, but the property is never bound to the XML: <!-- XML --> <InterfaceImpl id="5150" /> /** * Annotated interface */ @XmlRootElement(name="IInterface") public interface IInterface { @XmlAttribute(name="id") public void setId(int id); } /** * Concrete implementor */ @XmlRootElement(name="InterfaceImpl") public class InterfaceImpl implements