Failing with 'no-arg default constructor' on @XmlTransient · Issue #814 · javaee/jaxb-v2 (original) (raw)
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]