moxy

A recommended JAX-WS framework for working with Moxy

荒凉一梦 提交于 2019-12-07 09:46:38
问题 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

MOXy's @XmlCDATA seems to have no affect

与世无争的帅哥 提交于 2019-12-07 08:38:32
问题 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

Staying DRY with JAXB

Deadly 提交于 2019-12-07 08:01:01
问题 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

JAXB: Qualified attributes disables default namespace xmlns=“”?

拈花ヽ惹草 提交于 2019-12-07 05:51:56
问题 When I use @XmlSchema(attributeFormDefault = XmlNsForm.QUALIFIED, ...) or @XmlAttribute(namespace = "sample.com/y", ...) JAXB ignores @XmlSchema(namespace = "sample.com/x", ...) and instead of: <a xmlns="sample.com/y" xmlns:ns0="sample.com/y"> <b ns0:att=""/> </a> generates something like: <ns1:a xmlns:ns1="sample.com/x" xmlns:ns0="sample.com/y"> <ns1:b ns0:att=""/> </ns1:a> Is this an expected behavior? Is there any way to correct this? 回答1: EclipseLink JAXB (MOXy) is handling the prefix

JAXBException: “package” doesnt contain ObjectFactory.class or jaxb.index

眉间皱痕 提交于 2019-12-07 04:49:39
问题 I have been playing with JAXB / MOXy a lot lately, and it works great on all my tests and example codes . I exclusively using binding files, that's why I'm using MOXy. Please note that in all my examples, I'm NEVER using an ObjectFactory nor a jaxb.index, and it works GREAT . When I get back to my business, I get a nasty JAXB Exception saying that my package does not contain an ObjectFactory or jaxb.index. My project also invovles Spring and Hibernate, JUnit and DBUnit. Here is some sample

EclipseLink MOXy: Override rules of binding files

落爺英雄遲暮 提交于 2019-12-07 01:53:28
I would, in the scenario below, like the binding of java-type name="SubClass" to be applied to set the text field on SuperClass. However it is not. Is there a problem with overriding the bindingsA.xml? According to the Overriding rules documentation : If the same java-type occurs in multiple files, any values that are set in the later file, will override values from the previous file What do I need to do to make it work? Input: <?xml version="1.0" encoding="UTF-8"?> <a text="A text">B text</a> Bindings A: <?xml version="1.0"?> <xml-bindings xmlns="http://www.eclipse.org/eclipselink/xsds

JAXB edit List getter?

让人想犯罪 __ 提交于 2019-12-06 21:36:36
问题 I have my data model in the form of XSD files from which I then generate the corresponding Java files from xjc using command line. When I generate JAXB classes from an XSD, List type elements gets a getter method generated for them (with no corresponding setter method), as follows: public List<Type> getElement3() { if (element3 == null) { element3 = new ArrayList<Type>(); } return this.element3; } I have lot of fields in almost every file generated from XSD of List type. USE case: Now, I don

Override JAXB annotation Mapping with MOXY oxm binding file

半世苍凉 提交于 2019-12-06 12:52:18
I'm trying to implement two differents mappings for certains of my objects. The first mapping is done using JAXB annotations on my classes. It's working fine. The second mapping is really simple : it should take every Java attribute. To do this I wrote a very simple xml bindings file : <?xml version="1.0"?> <xml-bindings xmlns="http://www.eclipse.org/eclipselink/xsds/persistence/oxm" package-name="com.foo" xml-mapping-metadata-complete="true"> <java-types> <java-type name="com.foo.OverridedMappingClass" xml-accessor-type="FIELD"> </java-type> <java-type name="com.foo.OverridedMappingClass2"

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

白昼怎懂夜的黑 提交于 2019-12-06 11:45:49
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. @XmlRootElement @XmlAccessorType(XmlAccessType.FIELD) public class Wrapper { @XmlNullPolicy(emptyNodeRepresentsNull

Using Moxy as JAXB Implementation and setting jaxb.properties with more than one POJO package

时光怂恿深爱的人放手 提交于 2019-12-06 11:26:57
I am currently trying to use EclipseLink Moxy as my JAXB implementation. I am trying this, because the default implementation included in the JDK seems to have a hard coded indentation level of eight with UTF-8 encoding. My problem is that it seems that I have to put a jaxb.properties file into every package that contains a JAXB POJO. My JAXB POJOs are generated by xjc, specifically by 'jaxb2-maven-plugin'. The POJOs are generated into numerous packages. Is it somehow possible to set the used implementation without creating redundant jaxb.properties files in these packages? I am trying this,