Note that there are some explanatory texts on larger screens.

plurals
  1. POInheritance mapping throwing an exception with MOXy
    primarykey
    data
    text
    <p>I followed the second option mentioned in <a href="https://stackoverflow.com/questions/10874711/jaxb-inheritance-in-moxy">JAXB inheritance in MOXY</a> to map my parent class and child class listed below. MOXy is throwing the below exception and not sure what the issue is</p> <p><strong>Parent class</strong></p> <pre><code>public class UnitedStatesAddressData extends AbstractAddress implements UnitedStatesAddress, Serializable, Cloneable { private String primaryAddress; public String getPrimaryAddress() { return primaryAddress; } public void setPrimaryAddress(final String primaryAddress) { this.primaryAddress = primaryAddress; } } </code></pre> <p><strong>Child Class</strong></p> <pre><code>public class TokenizedUnitedStatesAddressData extends UnitedStatesAddressData implements TokenizedUnitedStatesAddress, CloneableAddress { private String houseNumber; private String preDirectional; private String streetName; private String streetType; //getters and setters ignored } </code></pre> <p><strong>external binding file</strong></p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;xml-bindings xmlns="http://www.eclipse.org/eclipselink/xsds/persistence/oxm" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eclipse.org/eclipselink/xsds/persistence/oxm http://www.eclipse.org/eclipselink/xsds/eclipselink_oxm_2_4.xsd" version="2.4" package-name="com.abc.ic.domain.impl.country.us" xml-accessor-type="PROPERTY"&gt; &lt;xml-schema element-form-default="QUALIFIED" namespace="http://xml.abc.com/XMLSchema/InterConnect"&gt; &lt;!-- Do not specify 'prefix'. We doesn't want the namespace prefix in our instance documents as they increase the payload size. --&gt; &lt;xml-ns namespace-uri="http://xml.abc.com/XMLSchema/InterConnect" /&gt; &lt;/xml-schema&gt; &lt;java-types&gt; &lt;java-type name="TokenizedUnitedStatesAddressData"&gt; &lt;xml-root-element name="USAddress" /&gt; &lt;xml-type prop-order="preDirectional houseNumber streetName streetType postDirection unitDesignator apartmentNumber primaryAddress secondaryAddress cityName stateAbbreviation zipCode" /&gt; &lt;java-attributes&gt; &lt;xml-element name="StreetPreDirection" java-attribute="preDirectional" /&gt; &lt;xml-element name="StreetNumber" java-attribute="houseNumber" /&gt; &lt;xml-element name="StreetName" java-attribute="streetName" /&gt; &lt;xml-element name="StreetType" java-attribute="streetType" /&gt; &lt;xml-element name="StreetPostDirection" java-attribute="postDirection" /&gt; &lt;xml-element name="UnitDesignator" java-attribute="unitDesignator" /&gt; &lt;xml-element name="UnitNumber" java-attribute="apartmentNumber" /&gt; &lt;xml-element name="AddressLine1" java-attribute="primaryAddress" /&gt; &lt;xml-element name="AddressLine2" java-attribute="secondaryAddress" /&gt; &lt;xml-element name="City" java-attribute="cityName" /&gt; &lt;xml-element name="State" java-attribute="stateAbbreviation" /&gt; &lt;xml-element name="PostalCode" java-attribute="zipCode" /&gt; &lt;/java-attributes&gt; &lt;/java-type&gt; &lt;java-type name="UnitedStatesAddressData" xml-transient="true"&gt; &lt;xml-root-element /&gt; &lt;/java-type&gt; &lt;/java-types&gt; &lt;/xml-bindings&gt; </code></pre> <p><strong>Error</strong></p> <pre><code>javax.xml.bind.JAXBException: Exception Description: The property or field primaryAddress is annotated to be transient so can not be included in the proporder annotation. - with linked exception: [Exception [EclipseLink-50009] (Eclipse Persistence Services - 2.4.0.v20120608-r11652): org.eclipse.persistence.exceptions.JAXBException Exception Description: The property or field primaryAddress is annotated to be transient so can not be included in the proporder annotation.] at org.eclipse.persistence.jaxb.JAXBContext$TypeMappingInfoInput.createContextState(JAXBContext.java:908) at org.eclipse.persistence.jaxb.JAXBContext.&lt;init&gt;(JAXBContext.java:157) at org.eclipse.persistence.jaxb.JAXBContextFactory.createContext(JAXBContextFactory.java:170) at org.eclipse.persistence.jaxb.JAXBContextFactory.createContext(JAXBContextFactory.java:157) at org.eclipse.persistence.jaxb.JAXBContextFactory.createContext(JAXBContextFactory.java:117) at org.eclipse.persistence.jaxb.JAXBContextFactory.createContext(JAXBContextFactory.java:107) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:202) at javax.xml.bind.ContextFinder.find(ContextFinder.java:331) at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:574) at com.abc.ic.platform.sts.domain.transformation.response.JaxbTest.beforeClass(JaxbTest.java:31) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27) at org.junit.runners.ParentRunner.run(ParentRunner.java:236) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) Caused by: Exception [EclipseLink-50009] (Eclipse Persistence Services - 2.4.0.v20120608-r11652): org.eclipse.persistence.exceptions.JAXBException Exception Description: The property or field primaryAddress is annotated to be transient so can not be included in the proporder annotation. at org.eclipse.persistence.exceptions.JAXBException.transientInProporder(JAXBException.java:225) at org.eclipse.persistence.jaxb.compiler.TypeInfo.setProperties(TypeInfo.java:342) at org.eclipse.persistence.jaxb.compiler.AnnotationsProcessor.buildTypeInfo(AnnotationsProcessor.java:755) at org.eclipse.persistence.jaxb.compiler.AnnotationsProcessor.postBuildTypeInfo(AnnotationsProcessor.java:669) at org.eclipse.persistence.jaxb.compiler.XMLProcessor.processXML(XMLProcessor.java:344) at org.eclipse.persistence.jaxb.compiler.Generator.&lt;init&gt;(Generator.java:145) at org.eclipse.persistence.jaxb.JAXBContext$TypeMappingInfoInput.createContextState(JAXBContext.java:904) ... 28 more </code></pre> <p><strong>UPDATE</strong></p> <p>I've tested this by removing "prop-order" and this works fine <strong>except that I can no longer control the order of the elements in generated XML</strong>. I believe this is a bug in the code.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload