Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Moxy is not honoring "type" attribute in xml-element tag in EclipseLink 2.4.2
Moxy is not honoring "type" attribute in xml-element tag in EclipseLink 2.4.2 [message #1086837] Wed, 14 August 2013 20:15 Go to next message
Rengarajan Ramasamy is currently offline Rengarajan RamasamyFriend
Messages: 2
Registered: August 2013
Junior Member
Hello,

We have been using EclipseLink Moxy 2.3.x successfully to generate XML out of JPA entities. After recently moving to EclipseLink 2.4.2, we noticed that Moxy no longer honors the "type" attribute specified in the external mapping document.

We use interfaces to hide JPA entities from Data access layer. So, in some cases our JPA entities implement multiple interfaces, and thats what seem to be breaking in 2.4.2, even though this worked in 2.3.x.

Consider an entity class:

@Table(name="project")
public class ProjectEO implements Project
{

Set<ProjectSetting> m_settings;

...
}

@Table(name="project_setting")
public class ProjectSettingEO implements Setting, Updateable
{
...
}

and XML configuration


<java-types>
<java-type name="ProjectEO" xml-accessor-type="FIELD">
<xml-root-element />
<java-attributes>
<xml-element java-attribute="m_projectSettings"
type="ProjectSettingEO"
container-type="java.util.HashSet" xml-path="settings/ProjectSettingEO" />
...
</java-type>

<java-type name="ProjectSettingEO" xml-accessor-type="FIELD" super-type="">
<xml-root-element />
<java-attributes>
<xml-transient java-attribute="_persistence_project_vh" />
<xml-inverse-reference java-attribute="m_project"
type="entity.ProjectEO" mapped-by="m_projectSettings"/>
</java-attributes>
</java-type>
...

In 2.4.2, I get the following error:

javax.xml.bind.JAXBException:
Exception Description: The java interface entity.Setting can not be mapped by JAXB as it has multiple mappable parent interfaces. Multiple inheritence is not supported
- with linked exception:
[Exception [EclipseLink-50089] (Eclipse Persistence Services - 2.4.2.v20130514-5956486): org.eclipse.persistence.exceptions.JAXBException
Exception Description: The java interface entity.Setting can not be mapped by JAXB as it has multiple mappable parent interfaces. Multiple inheritence is not supported]
at org.eclipse.persistence.jaxb.JAXBContext$TypeMappingInfoInput.createContextState(JAXBContext.java:1001)
at org.eclipse.persistence.jaxb.JAXBContext.<init>(JAXBContext.java:169)
at org.eclipse.persistence.jaxb.JAXBContextFactory.createContext(JAXBContextFactory.java:165)
at org.eclipse.persistence.jaxb.JAXBContextFactory.createContext(JAXBContextFactory.java:152)
at org.eclipse.persistence.jaxb.JAXBContextFactory.createContext(JAXBContextFactory.java:112)
at org.eclipse.persistence.jaxb.JAXBContextFactory.createContext(JAXBContextFactory.java:102)
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:606)
at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:248)
at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:235)
at javax.xml.bind.ContextFinder.find(ContextFinder.java:385)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:637)
...

Caused by: Exception [EclipseLink-50089] (Eclipse Persistence Services - 2.4.2.v20130514-5956486): org.eclipse.persistence.exceptions.JAXBException
Exception Description: The java interface xxx.entity.Setting can not be mapped by JAXB as it has multiple mappable parent interfaces. Multiple inheritence is not supported
at org.eclipse.persistence.exceptions.JAXBException.invalidInterface(JAXBException.java:1110)
at org.eclipse.persistence.jaxb.javamodel.reflection.JavaClassImpl.getSuperclass(JavaClassImpl.java:356)
at org.eclipse.persistence.jaxb.javamodel.reflection.JavaClassImpl.hasCustomSuperClass(JavaClassImpl.java:450)
at org.eclipse.persistence.jaxb.javamodel.reflection.JavaClassImpl.hasCustomSuperClass(JavaClassImpl.java:450)
at org.eclipse.persistence.jaxb.javamodel.reflection.JavaClassImpl.isAssignableFrom(JavaClassImpl.java:403)
at org.eclipse.persistence.jaxb.javamodel.Helper.isCollectionType(Helper.java:409)
at org.eclipse.persistence.jaxb.compiler.AnnotationsProcessor.shouldGenerateTypeInfo(AnnotationsProcessor.java:1750)
at org.eclipse.persistence.jaxb.compiler.AnnotationsProcessor.processXmlJavaTypeAdapter(AnnotationsProcessor.java:1675)
at org.eclipse.persistence.jaxb.compiler.AnnotationsProcessor.processPropertyAnnotations(AnnotationsProcessor.java:2476)
at org.eclipse.persistence.jaxb.compiler.AnnotationsProcessor.buildNewProperty(AnnotationsProcessor.java:1909)
at org.eclipse.persistence.jaxb.compiler.AnnotationsProcessor.getFieldPropertiesForClass(AnnotationsProcessor.java:1818)
at org.eclipse.persistence.jaxb.compiler.AnnotationsProcessor.getFieldPropertiesForClass(AnnotationsProcessor.java:1801)
at org.eclipse.persistence.jaxb.compiler.AnnotationsProcessor.getPropertiesForClass(AnnotationsProcessor.java:1787)
at org.eclipse.persistence.jaxb.compiler.AnnotationsProcessor.buildTypeInfo(AnnotationsProcessor.java:766)
at org.eclipse.persistence.jaxb.compiler.AnnotationsProcessor.postBuildTypeInfo(AnnotationsProcessor.java:680)
at org.eclipse.persistence.jaxb.compiler.XMLProcessor.processXML(XMLProcessor.java:346)
at org.eclipse.persistence.jaxb.compiler.Generator.<init>(Generator.java:147)
at org.eclipse.persistence.jaxb.JAXBContext$TypeMappingInfoInput.createContextState(JAXBContext.java:997)
... 48 more


Re: Moxy is not honoring "type" attribute in xml-element tag in EclipseLink 2.4.2 [message #1088205 is a reply to message #1086837] Fri, 16 August 2013 19:00 Go to previous messageGo to next message
Blaise Doughan is currently offline Blaise DoughanFriend
Messages: 163
Registered: July 2009
Senior Member

Hello,

This appears to be a bug. I have opened the following issue to track it:
- http://bugs.eclipse.org/415254

When I created an example based on your post:
- https://bugs.eclipse.org/bugs/attachment.cgi?id=234501

I get the following exception instead of the one you received:
Exception in thread "main" javax.xml.bind.JAXBException: 
Exception Description: Class [] not found.
 - with linked exception:
[Exception [EclipseLink-50047] (Eclipse Persistence Services - 2.4.2.v20130514-5956486): org.eclipse.persistence.exceptions.JAXBException
Exception Description: Class [] not found.]
	at org.eclipse.persistence.jaxb.JAXBContext$TypeMappingInfoInput.createContextState(JAXBContext.java:1001)
	at org.eclipse.persistence.jaxb.JAXBContext.<init>(JAXBContext.java:169)
	at org.eclipse.persistence.jaxb.JAXBContextFactory.createContext(JAXBContextFactory.java:165)
	at org.eclipse.persistence.jaxb.JAXBContextFactory.createContext(JAXBContextFactory.java:152)
	at org.eclipse.persistence.jaxb.JAXBContextFactory.createContext(JAXBContextFactory.java:112)
	at org.eclipse.persistence.jaxb.JAXBContextFactory.createContext(JAXBContextFactory.java:102)
	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:601)
	at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:248)
	at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:235)
	at javax.xml.bind.ContextFinder.find(ContextFinder.java:385)
	at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:637)
	at entity.Demo.main(Demo.java:13)
Caused by: Exception [EclipseLink-50047] (Eclipse Persistence Services - 2.4.2.v20130514-5956486): org.eclipse.persistence.exceptions.JAXBException
Exception Description: Class [] not found.
	at org.eclipse.persistence.exceptions.JAXBException.classNotFoundException(JAXBException.java:675)
	at org.eclipse.persistence.jaxb.javamodel.reflection.JavaModelImpl.getClass(JavaModelImpl.java:91)
	at org.eclipse.persistence.jaxb.compiler.XMLProcessor.processXML(XMLProcessor.java:180)
	at org.eclipse.persistence.jaxb.compiler.Generator.<init>(Generator.java:147)
	at org.eclipse.persistence.jaxb.JAXBContext$TypeMappingInfoInput.createContextState(JAXBContext.java:997)
	... 14 more


-Blaise

Re: Moxy is not honoring "type" attribute in xml-element tag in EclipseLink 2.4.2 [message #1088234 is a reply to message #1088205] Fri, 16 August 2013 20:04 Go to previous messageGo to next message
Blaise Doughan is currently offline Blaise DoughanFriend
Messages: 163
Registered: July 2009
Senior Member

Hello,

The exception I was getting was due to an invalid line in the metadata from your post. When I change:
<java-type name="ProjectSettingEO" xml-accessor-type="FIELD" super-type="">


To the following everything works correctly.
<java-type name="ProjectSettingEO" xml-accessor-type="FIELD">


Here is a link to the corrected example.
- https://bugs.eclipse.org/bugs/attachment.cgi?id=234502


-Blaise
Re: Moxy is not honoring "type" attribute in xml-element tag in EclipseLink 2.4.2 [message #1095862 is a reply to message #1088234] Tue, 27 August 2013 16:29 Go to previous messageGo to next message
Rengarajan Ramasamy is currently offline Rengarajan RamasamyFriend
Messages: 2
Registered: August 2013
Junior Member
Blaise,

Sorry for the late reply. The issue happens only when an interface extends more than one interface. I wasn't clear on this in my earlier post. Please use the attached zip file to reproduce the issue.

Thanks,
Rajan
  • Attachment: entity.zip
    (Size: 10.95KB, Downloaded 49 times)
Re: Moxy is not honoring "type" attribute in xml-element tag in EclipseLink 2.4.2 [message #1096652 is a reply to message #1095862] Wed, 28 August 2013 17:30 Go to previous message
Blaise Doughan is currently offline Blaise DoughanFriend
Messages: 163
Registered: July 2009
Senior Member

As a workaround you could change your mapping metadata to look like the folllowing:

<?xml version="1.0"?>
<xml-bindings xmlns="http://www.eclipse.org/eclipselink/xsds/persistence/oxm"
	package-name="entity">
	<java-types>
	    <java-type name="Project" super-type="java.lang.Object"/>
	    <java-type name="ProjectSetting" super-type="java.lang.Object"/>
		<java-type name="ProjectEO" xml-accessor-type="FIELD" super-type="java.lang.Object">
			<xml-root-element />
			<java-attributes>
				<xml-element java-attribute="m_projectSettings" type="entity.ProjectSettingEO"
					container-type="java.util.HashSet" xml-path="settings/ProjectSettingEO" />
			</java-attributes>
		</java-type>
		<java-type name="ProjectSettingEO" xml-accessor-type="FIELD" super-type="java.lang.Object">
			<xml-root-element />
			<java-attributes>
				<xml-transient java-attribute="_persistence_project_vh" />
				<xml-inverse-reference java-attribute="m_project"
					type="entity.ProjectEO" mapped-by="m_projectSettings" />
			</java-attributes>
		</java-type>
	</java-types>
</xml-bindings>
Previous Topic:How to obtain sequence value?
Next Topic:How to manage two entities with the same name in one project?
Goto Forum:
  


Current Time: Sat Dec 20 14:23:35 GMT 2014

Powered by FUDForum. Page generated in 0.01601 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software