jaxbtest.SomeException

There are no available Samebug tips for this exception. Do you have an idea how to solve this issue? A short tip would help users who saw this issue last week.

  • 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.<init>(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)
    via by walec51,
    • 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.<init>(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)
    No Bugmate found.