Hi all,
I'm trying to use XmlAnyElement in a bound class:
Simply:
public classBody {
@XmlAnyElement(lax=true)
private List<Element> nodes;
public List<Element> getNodes() {
return nodes;
}
public void setNodes(final List<Element> nodes) {
this.nodes = nodes;
}
public Body() {
}
}
But, when JAXB tries to parse this, I get:
javax.ws.rs.WebApplicationException:
com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 3 counts of
IllegalAnnotationExceptions
org.w3c.dom.Element is an interface, and JAXB can't handle interfaces.
this problem is related to the following location:
at org.w3c.dom.Element
at public java.util.List Body.getNodes()
at Body
at public Body Wrapper.getBody()
at Wrapper
org.w3c.dom.Element does not have a no-arg default constructor.
this problem is related to the following location:
at org.w3c.dom.Element
at public java.util.List Body.getNodes()
at Body
at public Body Wrapper.getBody()
at Wrapper
Class has two properties of the same name "nodes"
this problem is related to the following location:
at org.w3c.dom.Element
at public java.util.List Body.getNodes()
at Body
at public Body Wrapper.getBody()
at Wrapper
this problem is related to the following location:
at org.w3c.dom.Element
at public java.util.List Body.getNodes()
at Body
at public Body Wrapper.getBody()
at Wrapper
at
com.sun.jersey.core.provider.jaxb.AbstractRootElementProvider.writeTo(AbstractRootElementProvider.java:151)
at
com.sun.jersey.spi.container.ContainerResponse.write(ContainerResponse.java:289)
at
com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1029)
at
com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:941)
at
com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:932)
at
com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:384)
at
com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:451)
at
com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:632)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at
com.sun.grizzly.http.servlet.FilterChainImpl.doFilter(FilterChainImpl.java:188)
at
com.sun.grizzly.http.servlet.FilterChainImpl.invokeFilterChain(FilterChainImpl.java:137)
at
com.sun.grizzly.http.servlet.ServletAdapter.service(ServletAdapter.java:278)
at
com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:165)
at
com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:659)
at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:577)
at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:829)
at
com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:162)
at
com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:136)
at
com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:103)
at
com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:89)
at
com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76)
at
com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:67)
at
com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:57)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:637)
I don't understand the issue at all. I mean, if you look at
https://jaxb.dev.java.net/tutorial/section_6_2_7_6-Collecting-Unspecified-Elements-XmlAnyElement.html#Collecting%20Unspecified%20Elements:%20XmlAnyElement,
you can see clearly the example uses DocType, which an interface.
Any thoughts at all what could be going wrong ? I know this could be a
JAXB-only issue, but I can't tell if it has something to do with JAXB in the
context of Jersey...
Regards,
Seth