I am new bee trying to write my first rest service .
here is the code for my resource
package gov.hhs.acf.util.ws.grants.service;
import gov.hhs.acf.util.ws.grants.model.GrantsDTO;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.ProduceMime;
import javax.ws.rs.core.MediaType;
@Path("/grants")
public class GrantsResource {
@GET
@ProduceMime(MediaType.APPLICATION_XML)
public GrantsDTO getGrantsDTO(){
GrantsDTO grantsDTO= new GrantsDTO();
grantsDTO.setGranteeName("grantee name");
grantsDTO.setGrantNumber("grantNumber");
return grantsDTO;
}
}
and GrantDTO
package gov.hhs.acf.util.ws.grants.model;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement
public class GrantsDTO {
private String grantNumber;
private String granteeName;
public GrantsDTO() {
}
public String getGrantNumber() {
return grantNumber;
}
public void setGrantNumber(String grantNumber) {
this.grantNumber = grantNumber;
}
public String getGranteeName() {
return granteeName;
}
public void setGranteeName(String granteeName) {
this.granteeName = granteeName;
}
}
I end up with this exception please tell me what is wrong ?
java.io.IOException: Error marshalling out JAXB object of type "class
gov.hhs.acf.util.ws.grants.model.GrantsDTO".
at
com.sun.jersey.impl.provider.entity.XMLRootElementProvider.writeTo(XMLRootElementProvider.java:103)
at
com.sun.jersey.spi.container.ContainerResponse.write(ContainerResponse.java:220)
at
com.sun.jersey.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:681)
at
com.sun.jersey.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:631)
at
com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:291)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:806)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:502)
at
org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1121)
at
org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:265)
at
org.acegisecurity.context.HttpSessionContextIntegrationFilter.doFilter(HttpSessionContextIntegrationFilter.java:249)
at
org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
at
org.acegisecurity.util.FilterChainProxy.doFilter(FilterChainProxy.java:149)
at
org.acegisecurity.util.FilterToBeanProxy.doFilter(FilterToBeanProxy.java:98)
at
org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1112)
at
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198)
at
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at
org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1112)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:363)
at
org.mortbay.jetty.security.ConstraintsSecurityHandler.handle(ConstraintsSecurityHandler.java:220)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:822)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:305)
at
org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:229)
at
org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:113)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:324)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:550)
at
org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:876)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:535)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:209)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:407)
at
org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:421)
at
org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:520)
Caused by: com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException:
2 counts of IllegalAnnotationExceptions
net.sf.cglib.transform.impl.InterceptFieldCallback is an interface, and JAXB
can't handle interfaces.
this problem is related to the following location:
at net.sf.cglib.transform.impl.InterceptFieldCallback
at public net.sf.cglib.transform.impl.InterceptFieldCallback
gov.hhs.acf.util.ws.grants.model.GrantsDTO.getInterceptFieldCallback()
at gov.hhs.acf.util.ws.grants.model.GrantsDTO
net.sf.cglib.transform.impl.InterceptFieldCallback does not have a no-arg
default constructor.
this problem is related to the following location:
at net.sf.cglib.transform.impl.InterceptFieldCallback
at public net.sf.cglib.transform.impl.InterceptFieldCallback
gov.hhs.acf.util.ws.grants.model.GrantsDTO.getInterceptFieldCallback()
at gov.hhs.acf.util.ws.grants.model.GrantsDTO
at
com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException$Builder.check(IllegalAnnotationsException.java:66)
at
com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:422)
at
com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.(JAXBContextImpl.java:270)
at
com.sun.xml.internal.bind.v2.ContextFactory.createContext(ContextFactory.java:103)
at
com.sun.xml.internal.bind.v2.ContextFactory.createContext(ContextFactory.java:81)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:202)
at javax.xml.bind.ContextFinder.find(ContextFinder.java:376)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:574)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:522)
at
com.sun.jersey.impl.provider.entity.AbstractJAXBProvider.getJAXBContext(AbstractJAXBProvider.java:67)
at
com.sun.jersey.impl.provider.entity.XMLRootElementProvider.writeTo(XMLRootElementProvider.java:95)
... 32 more
Caused by:
com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 2 counts
of IllegalAnnotationExceptions
net.sf.cglib.transform.impl.InterceptFieldCallback is an interface, and JAXB
can't handle interfaces.
this problem is related to the following location:
at net.sf.cglib.transform.impl.InterceptFieldCallback
at public net.sf.cglib.transform.impl.InterceptFieldCallback
gov.hhs.acf.util.ws.grants.model.GrantsDTO.getInterceptFieldCallback()
at gov.hhs.acf.util.ws.grants.model.GrantsDTO
net.sf.cglib.transform.impl.InterceptFieldCallback does not have a no-arg
default constructor.
this problem is related to the following location:
at net.sf.cglib.transform.impl.InterceptFieldCallback
at public net.sf.cglib.transform.impl.InterceptFieldCallback
gov.hhs.acf.util.ws.grants.model.GrantsDTO.getInterceptFieldCallback()
at gov.hhs.acf.util.ws.grants.model.GrantsDTO
at
com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException$Builder.check(IllegalAnnotationsException.java:66)
at
com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:422)
at
com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.(JAXBContextImpl.java:270)
at
com.sun.xml.internal.bind.v2.ContextFactory.createContext(ContextFactory.java:103)
at
com.sun.xml.internal.bind.v2.ContextFactory.createContext(ContextFactory.java:81)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:202)
at javax.xml.bind.ContextFinder.find(ContextFinder.java:376)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:574)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:522)
at
com.sun.jersey.impl.provider.entity.AbstractJAXBProvider.getJAXBContext(AbstractJAXBProvider.java:67)
at
com.sun.jersey.impl.provider.entity.XMLRootElementProvider.writeTo(XMLRootElementProvider.java:95)
at
com.sun.jersey.spi.container.ContainerResponse.write(ContainerResponse.java:220)
at
com.sun.jersey.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:681)
at
com.sun.jersey.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:631)
at
com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:291)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:806)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:502)
at
org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1121)
at
org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:265)
at
org.acegisecurity.context.HttpSessionContextIntegrationFilter.doFilter(HttpSessionContextIntegrationFilter.java:249)
at
org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
at
org.acegisecurity.util.FilterChainProxy.doFilter(FilterChainProxy.java:149)
at
org.acegisecurity.util.FilterToBeanProxy.doFilter(FilterToBeanProxy.java:98)
at
org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1112)
at
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198)
at
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at
org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1112)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:363)
at
org.mortbay.jetty.security.ConstraintsSecurityHandler.handle(ConstraintsSecurityHandler.java:220)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:822)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:305)
at
org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:229)
at
org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:113)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:324)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:550)
at
org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:876)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:535)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:209)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:407)
at
org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:421)
at
org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:520)
--
View this message in context: http://n2.nabble.com/Error-marshalling-out-JAXB-object-of-type-class-gov-hhs-acf-util-ws-grants-model-GrantsDTO-tp4683828p4683828.html
Sent from the Jersey mailing list archive at Nabble.com.