Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Custom rest api plugin - Error marshalling JAXB object of type "class com.atlassian.jira.rest.api.util.ErrorCollection"

Anton Reshetnikov April 24, 2013

I have custom REST API plugin with such code

import com.atlassian.jira.rest.api.util.ErrorCollection;

....

    private void throwWebException(com.atlassian.jira.util.ErrorCollection errorCollection) {

        throw new RESTException(ErrorCollection.of(errorCollection));

    }

...

When it executed in jira5.0.6 i got

2013-04-25 11:55:59,712 http-2990-7 ERROR      [500ErrorPage.jsp] Exception caught in 500 page Error marshalling JAXB object of type "class com.atlassian.jira.rest.api.util.ErrorCollection".

java.io.IOException: Error marshalling JAXB object of type "class com.atlassian.jira.rest.api.util.ErrorCollection".
at com.sun.jersey.core.provider.jaxb.AbstractRootElementProvider.writeTo(AbstractRootElementProvider.java:155)
at com.sun.jersey.spi.container.ContainerResponse.write(ContainerResponse.java:254)
at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:689)....
....
Caused by: com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 2 counts of IllegalAnnotationExceptions

java.util.Map is an interface, and JAXB can't handle interfaces.
this problem is related to the following location:
at java.util.Map
at private java.util.Map com.atlassian.jira.rest.api.util.ErrorCollection.errors
at com.atlassian.jira.rest.api.util.ErrorCollection
java.util.Map does not have a no-arg default constructor.

this problem is related to the following location:

at java.util.Map
at private java.util.Map com.atlassian.jira.rest.api.util.ErrorCollection.errors
at com.atlassian.jira.rest.api.util.ErrorCollection
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)

How to avoid it?

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Answer accepted
Anton Reshetnikov April 24, 2013

Created own JAXB representation of an error

TAGS
AUG Leaders

Atlassian Community Events