Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 334681

Summary: Unnecessary classes being processed
Product: z_Archived Reporter: Blaise Doughan <blaise.doughan>
Component: EclipselinkAssignee: Blaise Doughan <blaise.doughan>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: clittleton, guoliangqian
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
URL: http://stackoverflow.com/questions/4726764/jaxb-provider-eclipselink-moxy-ignores-xmlaccessortypexmlaccesstype-none
Whiteboard:
Bug Depends on:    
Bug Blocks: 334712    
Attachments:
Description Flags
MOXy - Test Cases
none
MOXy - Test Cases
none
MOXy - Fix none

Description Blaise Doughan CLA 2011-01-18 13:13:52 EST
For the following object model:

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;

@XmlAccessorType(XmlAccessType.NONE)
public class Foo {

    private Bar bar;

    public Bar getBar() {
        return bar;
    }

    public void setBar(Bar bar) {
        this.bar = bar;
    }

}

and:

public class Bar {

    public Bar(String name) {
    }

}

When a JAXBContext is created on these classes the following exception is thrown:

Exception in thread "main" javax.xml.bind.JAXBException: 
Exception Description: The class example.Bar requires a zero argument constructor or a specified factory method.  Note that non-static inner classes do not have zero argument constructors and are not supported.
 - with linked exception:
[Exception [EclipseLink-50001] (Eclipse Persistence Services - 2.3.0.qualifier): org.eclipse.persistence.exceptions.JAXBException
Exception Description: The class example.Bar requires a zero argument constructor or a specified factory method.  Note that non-static inner classes do not have zero argument constructors and are not supported.]
	at org.eclipse.persistence.jaxb.JAXBContextFactory.createContext(JAXBContextFactory.java:266)
	at org.eclipse.persistence.jaxb.JAXBContextFactory.createContext(JAXBContextFactory.java:213)
	at org.eclipse.persistence.jaxb.JAXBContextFactory.createContext(JAXBContextFactory.java:110)
	at org.eclipse.persistence.jaxb.JAXBContextFactory.createContext(JAXBContextFactory.java:100)
	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 javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:522)
	at forum119.Demo.main(Demo.java:8)
Caused by: Exception [EclipseLink-50001] (Eclipse Persistence Services - 2.3.0.qualifier): org.eclipse.persistence.exceptions.JAXBException
Exception Description: The class example.Bar requires a zero argument constructor or a specified factory method.  Note that non-static inner classes do not have zero argument constructors and are not supported.
	at org.eclipse.persistence.exceptions.JAXBException.factoryMethodOrConstructorRequired(JAXBException.java:122)
	at org.eclipse.persistence.jaxb.compiler.AnnotationsProcessor.finalizeProperties(AnnotationsProcessor.java:651)
	at org.eclipse.persistence.jaxb.compiler.AnnotationsProcessor.processClassesAndProperties(AnnotationsProcessor.java:228)
	at org.eclipse.persistence.jaxb.compiler.Generator.<init>(Generator.java:147)
	at org.eclipse.persistence.jaxb.JAXBContextFactory.createContext(JAXBContextFactory.java:263)
	... 12 more


This exception should not be thrown since Bar should never be processed.
Comment 1 Blaise Doughan CLA 2011-01-18 15:38:30 EST
Created attachment 187041 [details]
MOXy - Test Cases
Comment 2 Blaise Doughan CLA 2011-01-18 16:11:14 EST
Created attachment 187043 [details]
MOXy - Test Cases
Comment 3 Blaise Doughan CLA 2011-01-18 16:12:06 EST
Created attachment 187044 [details]
MOXy - Fix

If the property is "transient" do not attempt to process its type.
Comment 4 Blaise Doughan CLA 2011-01-19 10:48:18 EST
Fix checked into trunk at rev:  8845

Code reviewed by:  Matt MacIvor
Comment 5 clittleton CLA 2011-02-28 18:21:49 EST
This still appears to be broken in build: 2.3.0.v20110225-r9029

I am using externally defined xml mapping files instead of annotations, could it be that this is still broken for that case?
Comment 6 Eclipse Webmaster CLA 2022-06-09 10:06:10 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink