Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Name collision when using super-type in moxy oxm.xml
Name collision when using super-type in moxy oxm.xml [message #1104289] Sun, 08 September 2013 01:08 Go to next message
jason zhang is currently offline jason zhang
Messages: 19
Registered: July 2009
Junior Member
my oxm.xml
<?xml version="1.0" encoding="UTF-8"?>
<xml-bindings xmlns="http://www.eclipse.org/eclipselink/xsds/persistence/oxm" xml-accessor-type="NONE" xml-mapping-metadata-complete="true" package-name="com.flexdms.flexims.model.generated">
   <java-types>
      <java-type name="TypedQuery">
         <xml-root-element name="TypedQuery"/>
         <java-attributes>
            <xml-element java-attribute="id" name="id" xml-id="true"/>
            <java-attribute java-attribute="Name" name="Name" required="true"/>
            <java-attribute java-attribute="Type" name="Type" required="true"/>
         </java-attributes>
      </java-type>
      <java-type name="ConditionQuery" super-type="TypedQuery">
         <xml-root-element name="ConditionQuery"/>
         <java-attributes/>
      </java-type>
      <java-type name="SingleInt">
         <xml-root-element name="SingleInt"/>
         <java-attributes>
            <xml-element java-attribute="id" name="id" xml-id="true"/>
            <java-attribute java-attribute="DateCreated" name="DateCreated" required="true"/>
            <java-attribute java-attribute="DateModified" name="DateModified" required="true"/>
            <java-attribute java-attribute="defaultCase" name="defaultCase"/>
            <java-attribute java-attribute="withdefault" name="withdefault"/>
            <java-attribute java-attribute="requiredAndAuto" name="requiredAndAuto" required="true"/>
            <java-attribute java-attribute="AutoButNotRequired" name="AutoButNotRequired"/>
            <java-attribute java-attribute="withminandmax" name="withminandmax"/>
            <java-attribute java-attribute="allowedValue" name="allowedValue"/>
            <java-attribute java-attribute="allowedWithDefault" name="allowedWithDefault"/>
         </java-attributes>
      </java-type>
   </java-types>
</xml-bindings>



The exception I got

Local Exception Stack: 
Exception [EclipseLink-50007] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.JAXBException
Exception Description: Name collision.  Two classes have the XML type with uri  and name typedQuery.
	at org.eclipse.persistence.exceptions.JAXBException.nameCollision(JAXBException.java:215)
	at org.eclipse.persistence.jaxb.compiler.AnnotationsProcessor.processTypeQName(AnnotationsProcessor.java:1783)
	at org.eclipse.persistence.jaxb.compiler.AnnotationsProcessor.buildTypeInfo(AnnotationsProcessor.java:812)
	at org.eclipse.persistence.jaxb.compiler.AnnotationsProcessor.postBuildTypeInfo(AnnotationsProcessor.java:738)
	at org.eclipse.persistence.jaxb.compiler.AnnotationsProcessor.buildNewTypeInfo(AnnotationsProcessor.java:4668)
	at org.eclipse.persistence.jaxb.compiler.AnnotationsProcessor.postProcessXmlAccessorType(AnnotationsProcessor.java:1612)
	at org.eclipse.persistence.jaxb.compiler.AnnotationsProcessor.buildTypeInfo(AnnotationsProcessor.java:800)
	at org.eclipse.persistence.jaxb.compiler.AnnotationsProcessor.postBuildTypeInfo(AnnotationsProcessor.java:738)
	at org.eclipse.persistence.jaxb.compiler.XMLProcessor.processXML(XMLProcessor.java:363)
	at org.eclipse.persistence.jaxb.compiler.Generator.<init>(Generator.java:104)
	at org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext$MetadataContextInput.createContextState(DynamicJAXBContext.java:236)
	at org.eclipse.persistence.jaxb.JAXBContext.<init>(JAXBContext.java:174)
	at org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext.<init>(DynamicJAXBContext.java:71)
	at org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContextFactory.createContextFromOXM(DynamicJAXBContextFactory.java:347)
	at com.flexdms.flexims.test.unit.query.TestMoxy.setJaxbContext(TestMoxy.java:58)


My DynamicJaxbContext is created like this
Map<String, Object> properties = new HashMap<String, Object>(1); 
		properties.put(JAXBContextProperties.OXM_METADATA_SOURCE, new MoxyMetaSource(types));

		ServerSession session = JpaHelper.getEntityManagerFactory(em).getServerSession();
		DynamicClassLoader dcl =DJPAHelper.getDcl(session);
		jaxbContext = 
			    DynamicJAXBContextFactory.createContextFromOXM(dcl, properties);


The dynamicClassLoader is from DynamicJPA. The class loader is already has all the dynamicTypes. My XmlBinding is created from java code. The oxm.xml shown above is the dump of java object. I do not see any name collision in my oxm.xml. Did I do something wrong with super-type?

thanks
Re: Name collision when using super-type in moxy oxm.xml [message #1106830 is a reply to message #1104289] Wed, 11 September 2013 11:57 Go to previous messageGo to next message
Blaise Doughan is currently offline Blaise Doughan
Messages: 163
Registered: July 2009
Senior Member

I wasn't able to get the same exception as you, but I did notice some problems with your metadata file:
- You have java-attribute elements where you meant to have xml-attribute.
- You did not fully qualify the class name for the specified super-type.
- You did not specify the type for the xml-attribute mappings.

oxm.xml

Below is an updated version of your oxm.xml file.

<?xml version="1.0" encoding="UTF-8"?>
<xml-bindings xmlns="http://www.eclipse.org/eclipselink/xsds/persistence/oxm" xml-accessor-type="NONE" xml-mapping-metadata-complete="true" package-name="com.flexdms.flexims.model.generated">
   <java-types>
      <java-type name="TypedQuery">
         <xml-root-element name="TypedQuery"/>
         <java-attributes>
            <xml-element java-attribute="id" name="id" xml-id="true"/>
            <xml-attribute java-attribute="Name" name="Name" required="true" type="java.lang.String"/>
            <xml-attribute java-attribute="Type" name="Type" required="true" type="java.lang.String"/>
         </java-attributes>
      </java-type>
      <java-type name="ConditionQuery" super-type="com.flexdms.flexims.model.generated.TypedQuery">
         <xml-root-element name="ConditionQuery"/>
         <java-attributes/>
      </java-type>
      <java-type name="SingleInt">
         <xml-root-element name="SingleInt"/>
         <java-attributes>
            <xml-element java-attribute="id" name="id" xml-id="true"/>
            <xml-attribute java-attribute="DateCreated" name="DateCreated" required="true" type="java.util.Date"/>
            <xml-attribute java-attribute="DateModified" name="DateModified" required="true" type="java.util.Date"/>
            <xml-attribute java-attribute="defaultCase" name="defaultCase" type="java.lang.String"/>
            <xml-attribute java-attribute="withdefault" name="withdefault" type="java.lang.Boolean"/>
            <xml-attribute java-attribute="requiredAndAuto" name="requiredAndAuto" required="true" type="java.lang.Boolean"/>
            <xml-attribute java-attribute="AutoButNotRequired" name="AutoButNotRequired" type="java.lang.Boolean"/>
            <xml-attribute java-attribute="withminandmax" name="withminandmax" type="java.lang.Boolean"/>
            <xml-attribute java-attribute="allowedValue" name="allowedValue" type="java.lang.Boolean"/>
            <xml-attribute java-attribute="allowedWithDefault" name="allowedWithDefault" type="java.lang.Boolean"/>
         </java-attributes>
      </java-type>
   </java-types>
</xml-bindings>


Demo

Below is a simplified version of the bootstrap code:

package el520540;

import java.util.*;
import org.eclipse.persistence.jaxb.JAXBContextProperties;
import org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContextFactory;

public class Demo {

    public static void main(String[] args) throws Exception {
        Map<String, Object> properties = new HashMap<String, Object>();
        properties.put(JAXBContextProperties.OXM_METADATA_SOURCE, "el520540/oxm.xml");
        DynamicJAXBContextFactory.createContextFromOXM(Demo.class.getClassLoader(), properties);
       
    }
}

Re: Name collision when using super-type in moxy oxm.xml [message #1106863 is a reply to message #1106830] Wed, 11 September 2013 12:47 Go to previous message
jason zhang is currently offline jason zhang
Messages: 19
Registered: July 2009
Junior Member

I get it worked following your instruction. I guess the cause is the super-type is not fully qualified.

Thanks, Blaise.
Previous Topic:Name collision when using super-type in moxy oxm.xml
Next Topic:how to control marshaller conditionally?
Goto Forum:
  


Current Time: Sat Apr 19 08:46:59 EDT 2014

Powered by FUDForum. Page generated in 0.03709 seconds