[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[eclipselink-users] MOXy - property [anyChecklists] is already set as XmlAnyElement
|
Hi All,
This is a continuation of my problem today. I followed Blaise's recommendation, ran xjc to compile my JAXB bindings and then run MOXy during runtime.
When I try to unmarshal a XML that uses the xccdf-1.1.4.xsd
which is a standard schema that can be obtain from
http://scap.nist.gov/specifications/xccdf/#resource-1.1.4 , I hit an exception.
javax.xml.bind.JAXBException:
Exception Description: An attempt was made to set more than one XmlAnyElement property on class [gov.nist.checklists.xccdf._1.MetadataType]. Property [anyPurl] cannot be set as XmlAnyElement, because property [anyChecklists] is already set as XmlAnyElement.
- with linked exception:
[Exception [EclipseLink-50032] (Eclipse Persistence Services - 2.4.1.v20121003-ad44345): org.eclipse.persistence.exceptions.JAXBException
Exception Description: An attempt was made to set more than one XmlAnyElement property on class [gov.nist.checklists.xccdf._1.MetadataType]. Property [anyPurl] cannot be set as XmlAnyElement, because property [anyChecklists] is already set as XmlAnyElement.]
at org.eclipse.persistence.jaxb.JAXBContext$TypeMappingInfoInput.createContextState(JAXBContext.java:926)
at org.eclipse.persistence.jaxb.JAXBContext.<init>(JAXBContext.java:163)
at org.eclipse.persistence.jaxb.JAXBContextFactory.createContext(JAXBContextFactory.java:171)
at org.eclipse.persistence.jaxb.JAXBContextFactory.createContext(JAXBContextFactory.java:158)
at org.eclipse.persistence.jaxb.JAXBContextFactory.createContext(JAXBContextFactory.java:118)
at org.eclipse.persistence.jaxb.JAXBContextFactory.createContext(JAXBContextFactory.java:108)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:222)
at javax.xml.bind.ContextFinder.find(ContextFinder.java:351)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:594)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:542)
at xccdf_main.main(xccdf_main.java:14)
Caused by: Exception [EclipseLink-50032] (Eclipse Persistence Services - 2.4.1.v20121003-ad44345): org.eclipse.persistence.exceptions.JAXBException
Exception Description: An attempt was made to set more than one XmlAnyElement property on class [gov.nist.checklists.xccdf._1.MetadataType]. Property [anyPurl] cannot be set as XmlAnyElement, because property [anyChecklists] is already set as XmlAnyElement.
at org.eclipse.persistence.exceptions.JAXBException.xmlAnyElementAlreadySet(JAXBException.java:499)
at org.eclipse.persistence.jaxb.compiler.AnnotationsProcessor.finalizeProperties(AnnotationsProcessor.java:887)
at org.eclipse.persistence.jaxb.compiler.AnnotationsProcessor.processClassesAndProperties(AnnotationsProcessor.java:269)
at org.eclipse.persistence.jaxb.compiler.Generator.<init>(Generator.java:147)
at org.eclipse.persistence.jaxb.JAXBContext$TypeMappingInfoInput.createContextState(JAXBContext.java:922)
... 14 more
This issue only happen when running with MOXy but doesn't occur when running the built-in JAVA JAXB implementation.
Is this a bug or I have to include addition things in the jaxb.properties?
Thanks!
David
On Wed, Nov 28, 2012 at 2:36 PM, Chun Tat David Chu
<beyonddc.storage@xxxxxxxxx> wrote:
Hi Blaise,
Thanks for your suggestion. Bug 395328 has been submitted which included a tar file that contains all the XML schema to replicate the problem.
https://bugs.eclipse.org/bugs/show_bug.cgi?id=395328
For now I will generate bindings via JDK JAXB and then use MOXy during runtime.
Well before that, I have to spend time looking on JSON as well. One of the reason I would like to use MOXy is it can create JSON bindings as well.
Thanks,
DavidOn Wed, Nov 28, 2012 at 1:48 PM, Blaise Doughan
<blaise.doughan@xxxxxxxxxx> wrote:
Hi David,
Looks like there is a bug in the compiler script. Would you mind
entering a bug at the following link:
MOXy ships a version of the XJC tool from the JAXB reference
implementation. It wraps it with the MOXyXJC class. MOXyXJC simply
ensures that a jaxb.properties file specifying MOXy as the JAXB
provider is placed in the model directory. As a workaround you can
use the XJC command from the JDK and manually add the
jaxb.properties file in the generated directory.
-Blaise
On 12-11-28 1:29 PM, Chun Tat David Chu wrote:
Hi Blaise, MOXy Users,
You found my post on stackoverflow. :-)
Sorry for the multiple posts but I guess I will stick with this
mailing list since this is the EclipseLink MOXy community. I will
post back the answer to stackoverflow once I have a resolution.
Your suggestion does work only with the JAXB implementation
bundles with the JAVA JDK. See below for more detail...
Using the following external JAXB binding XML works when using the
JAXB implementation bundles with
java-1.6.0-openjdk-devel-1.6.0.0-1.45.1.11.1.el6.i686
Command Line Arg: xjc -d ./bindings ./xccdf-1.1.4.xsd -b
./xccdf-1.1.4_jaxb_property.xml
<bindings
node="//xsd:complexType[@name='metadataType']/xsd:sequence/xsd:choice">
<bindings node=".//xsd:any[@namespace='http://purl.org/dc/elements/1.1/']">
<property name="any_purl"/>
</bindings>
<bindings node=".//xsd:any[@namespace='http://checklists.nist.gov/sccf/0.1']">
<property name="any_checklists"/>
</bindings>
</bindings>
However it doesn't work when using MOXy. When running with MOXy
eclipselink-2.4.1.v20121003-ad44345, I got the following...
Command Line Arg: ${ECLIPSELINK_HOME}/bin/jaxb-compiler.sh -d
./bindings ./xccdf-1.1.4.xsd -b ./xccdf-1.1.4_jaxb_property.xml
Exception in thread "main"
java.lang.reflect.UndeclaredThrowableException
at $Proxy32.required(Unknown Source)
at
com.sun.tools.xjc.generator.bean.field.AbstractField.annotateReference(AbstractField.java:197)
at
com.sun.tools.xjc.generator.bean.field.AbstractField.annotate(AbstractField.java:156)
at
com.sun.tools.xjc.generator.bean.field.AbstractListField.generate(AbstractListField.java:124)
at
com.sun.tools.xjc.generator.bean.field.UntypedListField.<init>(UntypedListField.java:107)
at
com.sun.tools.xjc.generator.bean.field.UntypedListFieldRenderer.generate(UntypedListFieldRenderer.java:72)
at
com.sun.tools.xjc.generator.bean.field.DefaultFieldRenderer.generate(DefaultFieldRenderer.java:79)
at
com.sun.tools.xjc.generator.bean.BeanGenerator.generateFieldDecl(BeanGenerator.java:747)
at
com.sun.tools.xjc.generator.bean.BeanGenerator.generateClassBody(BeanGenerator.java:535)
at
com.sun.tools.xjc.generator.bean.BeanGenerator.<init>(BeanGenerator.java:235)
at
com.sun.tools.xjc.generator.bean.BeanGenerator.generate(BeanGenerator.java:175)
at com.sun.tools.xjc.model.Model.generateCode(Model.java:286)
at com.sun.tools.xjc.Driver.run(Driver.java:343)
at
org.eclipse.persistence.jaxb.xjc.MOXyXJC.main(MOXyXJC.java:48)
Caused by: java.lang.NoSuchMethodException:
javax.xml.bind.annotation.XmlElementRef.required()
at java.lang.Class.getDeclaredMethod(Class.java:1954)
at
com.sun.codemodel.TypedAnnotationWriter.invoke(TypedAnnotationWriter.java:107)
Is this a bug in MOXy?
Thanks,
David