Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failing with 'no-arg default constructor' on @XmlTransient #814

Closed
Tomas-Kraus opened this issue Feb 10, 2011 · 7 comments
Closed

Failing with 'no-arg default constructor' on @XmlTransient #814

Tomas-Kraus opened this issue Feb 10, 2011 · 7 comments

Comments

@Tomas-Kraus
Copy link
Member

Hello,

I have a simple exception I want to serialize to xml like this:

@XmlRootElement
public class SomeException extends RuntimeException {

private Integer someAdditionalInformation;

public SomeException() {
}

public SomeException(Integer someAdditionalInformation)

{ this.someAdditionalInformation = someAdditionalInformation; }

public Integer getSomeAdditionalInformation() { return someAdditionalInformation; }

public void setSomeAdditionalInformation(
Integer someAdditionalInformation) { this.someAdditionalInformation = someAdditionalInformation; }

@XmlTransient
@OverRide
public StackTraceElement[] getStackTrace()

{ return super.getStackTrace(); }

@XmlTransient
@OverRide
public Throwable getCause()

{ return super.getCause(); }

}

public class Main {

public static void main(String[] args) {
try

{ JAXBContext jaxbCtx = JAXBContext.newInstance(SomeException.class); Marshaller m = jaxbCtx.createMarshaller(); m.marshal(new SomeException(5), System.out); }

catch (JAXBException ex)

{ Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); }

}

}

As I understand the stack trace should be omitted because of the @XmlTransient annotation

But I get the following exception:

2011-02-10 19:03:27 jaxbtest.Main main
SEVERE: null
com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions
java.lang.StackTraceElement does not have a no-arg default constructor.
this problem is related to the following location:
at java.lang.StackTraceElement
at public java.lang.StackTraceElement[] java.lang.Throwable.getStackTrace()
at java.lang.Throwable
at java.lang.Exception
at java.lang.RuntimeException
at jaxbtest.SomeException

at com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException$Builder.check(IllegalAnnotationsException.java:91)
at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:436)
at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.(JAXBContextImpl.java:277)
at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1100)
at com.sun.xml.internal.bind.v2.ContextFactory.createContext(ContextFactory.java:143)
at com.sun.xml.internal.bind.v2.ContextFactory.createContext(ContextFactory.java:110)
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:396)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:594)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:542)
at jaxbtest.Main.main(Main.java:22)

Environment

java version "1.6.0_20"
OpenJDK Runtime Environment (IcedTea6 1.9.5) (6b20-1.9.5-0ubuntu1~10.04.1)
OpenJDK 64-Bit Server VM (build 19.0-b09, mixed mode)

Ubuntu 10

Affected Versions

[2.2.3]

@Tomas-Kraus
Copy link
Member Author

@glassfishrobot Commented
Reported by walec51

@Tomas-Kraus
Copy link
Member Author

@glassfishrobot Commented
Was assigned to snajper

@Tomas-Kraus
Copy link
Member Author

@glassfishrobot Commented
snajper said:
Fixed in trunk and 2.2 branch.

@Tomas-Kraus
Copy link
Member Author

@glassfishrobot Commented
Marked as fixed on Monday, May 30th 2011, 11:45:57 pm

@Tomas-Kraus
Copy link
Member Author

@glassfishrobot Commented
djdenv said:
Thanks for fixing this! I've verified the fix in 2.2.5

@Tomas-Kraus
Copy link
Member Author

@glassfishrobot Commented
This issue was imported from java.net JIRA JAXB-814

@Tomas-Kraus
Copy link
Member Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants