moxy

JAXB inheritance in MOXY

我怕爱的太早我们不能终老 提交于 2019-12-19 08:53:09
问题 I have two classes: package a; class A { private <type> fieldOfClassA; // getters, and setters } package b; class B extends A{ private <type> fieldOfClassB; // getters, and setters } I want to marshal class B to an xml element and add the attribute fieldOfClassB, and fieldOfClassA from class A but it prints the following warning message during marshalling: Ignoring attribute [fieldOfClassA] on class [b.B] as no Property was generated for it. Note that the two class is from two different

JAXB @XmlAdapter: Map -> List adapter? (marshall only)

邮差的信 提交于 2019-12-18 16:30:46
问题 I have a Map<String, String> . The first idea everyone has is to convert it to a List<Pair<String,String>> ( Pair being a custom class). I've tried a @XmlAdapter like this: public class MapPropertiesAdapter extends XmlAdapter<List<Property>, Map<String,String>> { ... } But Eclipse MOXy, the JAXB impl I use, ended up with a ClassCastException - "can't convert HashMap to Collection". Is this conversion supported by JAXB? Or did I overlook some documentation part which explains why it isn't? PS:

Can I replace jaxb.properties with code?

﹥>﹥吖頭↗ 提交于 2019-12-18 13:25:20
问题 I am using some non-standard extensions from EclipseLink's implementation of JAXB, and to enable that implementation, I have to configure it using jaxb.properties. Works well. However, due to a build error, the properties file was not included in the proper place, resulting in the default JAXB being used, which without any errors just continued to parse the XML file, ignoring the non-standard extension, leaving me with a non-working bean. To make this more robust, I'd like to get rid off the

EclipseLink MOXy JSON Serialization

☆樱花仙子☆ 提交于 2019-12-18 05:51:36
问题 I have got a sample class: class Zoo { public Collection<? extends Animal> animals; } When serialized with MOXy, I am getting: { "bird": [ { "name": "bird-1", "wingSpan": "6 feets", "preferredFood": "food-1" } ], "cat": [ { "name": "cat-1", "favoriteToy": "toy-1" } ], "dog": [ { "name": "dog-1", "breed": "bread-1", "leashColor": "black" } ] } Why is it using array indicators "[]", while bird, cat, and dog are not arrays? Second, is there a way to get rid of "bird", "cat", and "dog"? In other

Unmarshal a single element list fails

可紊 提交于 2019-12-17 21:07:13
问题 I'm running a sample (which i can't find anymore) from Blaise Doughans blog on Glassfish 3 using EclipseLink 2.5 MOXy for JAXB service. @XmlRootElement @XmlAccessorType(XmlAccessType.FIELD) public class Company { @XmlElementWrapper(name="employees") @XmlElement(name = "employee", type=Employee.class) private List<Employee> employees; } @XmlAccessorType(XmlAccessType.FIELD) public class Employee { private String id; private String name; } I added some annotations to the classes, to produce the

JAXB unmarshalling multiple XML elements into single class

断了今生、忘了曾经 提交于 2019-12-17 19:01:48
问题 I have the following XML structure, which is modelling a single concept across multiple XML elements. This format is not in my control. <Output> <Wrapper> <Channel> <id>1</id> <type>x</type> </Channel> <Channel> <id>2</id> <type>y</type> </Channel> <ChannelName> <id>1</id> <name>Channel name</name> </ChannelName> <ChannelName> <id>2</id> <name>Another channel name</name> </ChannelName> </Wrapper> </Output> I want to model this in a database that I do have control over and can have a more

Jersey 2.0 equivalent to POJOMappingFeature

妖精的绣舞 提交于 2019-12-17 18:10:10
问题 I have some experience using Jersey < 2.0. Now I am trying to build a war application to provide a JSON Webservice API. I am now struggling for a considerable amount of time trying to configure Moxy and it seams to be way more complicated than what was adding <init-param> <param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name> <param-value>true</param-value> </init-param> to your web.xml back in Jersey < 2.0. Is there some possibility to just say "please add json support"?

RunTime Retention policy java annotations doesn't work in Weblogic 12C

南笙酒味 提交于 2019-12-13 19:25:25
问题 We are planning to upgrade our product to Web-logic 12.C and WebSphere 8 stack ( Earlier it was WLC 10.3.5 and WAS 7). But issue in one of the web service component causing entire application failed to deploy in web logic. It works perfectly fine with WebSphere 8. When deploying the EAR, Application sever throws 'Exception [EclipseLink-59] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.DescriptorException' . After more analysis, I found below code

@XmlDiscriminatorNode/@XmlDescriminatorValue not working on WebLogic Server

若如初见. 提交于 2019-12-13 13:29:50
问题 Following are the classes I am using for create sub classes using MOXy JAXB conversion on WebLogic 10.3.2 version. I am using the EclipseLink 2.4.1 MOXy for generating the XML. I am unable to generate the type attribute in the following code. Let me know if I am doing anything wrong here. I am using EclipseLink MOXy 2.4.1 and WebLogic 10.3.2 and MOXy 2.4.1 is configured in the WebLogic import javax.xml.bind.annotation.*; import org.eclipse.persistence.oxm.annotations.XmlDiscriminatorNode;

Can I get MOXy to convert a string to a boolean when generating json

梦想与她 提交于 2019-12-13 13:15:55
问题 The object model has an element ended of type String public class LifeSpan { protected String begin; protected String end; @XmlJavaTypeAdapter(CollapsedStringAdapter.class) protected String ended; .... but its actually only ever a boolean, (I dont know the significance of the XmlJavaTypeAdapter annotation) When output as XML gives <life-span><begin>1999-04</begin><ended>true</ended></life-span> so doesn't really matter if defined as boolean or string but JSON output is "life-span" : { "begin"