Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 334681 - Unnecessary classes being processed
Summary: Unnecessary classes being processed
Status: RESOLVED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Blaise Doughan CLA
QA Contact:
URL: http://stackoverflow.com/questions/47...
Whiteboard:
Keywords:
Depends on:
Blocks: 334712
  Show dependency tree
 
Reported: 2011-01-18 13:13 EST by Blaise Doughan CLA
Modified: 2022-06-09 10:06 EDT (History)
2 users (show)

See Also:


Attachments
MOXy - Test Cases (9.95 KB, patch)
2011-01-18 15:38 EST, Blaise Doughan CLA
no flags Details | Diff
MOXy - Test Cases (11.89 KB, patch)
2011-01-18 16:11 EST, Blaise Doughan CLA
no flags Details | Diff
MOXy - Fix (904 bytes, patch)
2011-01-18 16:12 EST, Blaise Doughan CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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