File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Web Services and the fly likes getting exception while accessing REST API Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "getting exception while accessing REST API" Watch "getting exception while accessing REST API" New topic

getting exception while accessing REST API

Rajit Patel

Joined: Aug 01, 2008
Posts: 9
Hi All..

I am writting a REST based webservices using REST Easy API. Webservice is giving result in either application/xml or application/json as per accept Header. When my result is application/xml, i am gettting a below exception on console..

SEVERE: An exception occured writing the response entity
at org.restlet.ext.jaxrs.internal.provider.AbstractJaxbProvider.getJaxbContext(
at org.restlet.ext.jaxrs.internal.provider.AbstractJaxbProvider.marshal(
at org.restlet.ext.jaxrs.internal.provider.JaxbProvider.writeTo(
at org.restlet.ext.jaxrs.internal.wrappers.provider.SingletonProvider.writeTo(
at org.restlet.ext.jaxrs.internal.util.JaxRsOutputRepresentation.write(
at com.noelios.restlet.http.HttpServerCall.writeResponseBody(
at com.noelios.restlet.http.HttpServerCall.sendResponse(
at com.noelios.restlet.http.HttpServerConverter.commit(
at com.noelios.restlet.http.HttpServerHelper.handle(
at com.noelios.restlet.http.StreamServerHelper$
at java.util.concurrent.Executors$ Source)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$ Source)
at Source)

One more thing, I am using Jaxb to convert object to xml..

Please anybody can help me???
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
Just curious: Are you really using RESTEasy? It looks like you are using RESTlets from the stacktrace. It could be that RESTEasy uses RESTlets internally.
Anyway, it looks like your problem is related to JAXB not being able to obtain a context. Do you have unit tests that tests marshalling of Java objects to XML? If not, I would recommend writing at least one to make sure things work as they should without having to run the service.
Best wishes!
I agree. Here's the link:
subject: getting exception while accessing REST API
It's not a secret anymore!