this example not working with Spring 3.2.2 and 3.2.3. It only work on Spring 3.1.4 and older version. I tested it with tomcat 7.x and JDK 1.7

For Spring 3.2.2 and 3.2.3 I got: HTTP Status 406 – The resource identified by this request is only capable of generating responses with characteristics not acceptable according to the request “accept” headers.

Can any one help me?

Jeff

@mykong.. as usual.. simple and perfect example.. It worked.. thnx..

@alapierre… I used Spring 3.2.4.. didnot have any problem, it worked. for you Http status 406 error, please include “jackson-core-asl” and “jackson-mapper-asl” jars in your lib folder.

moez

hi, I m khaled moez i have probleme when i want to recuperate the object employe but when i put de type string or int it’s work and we recuperate this string . i don’t undrestand what is the probleme

make sure that you add two jackson related jar files. jackson-core-asl-1.9.8.jar jackson-mapper-asl-1.9.8.jar

http://mariuzzo.com Rubens Mariuzzo

@Ahmad, Apache Maven will just handle the dependencies correctly by adding the core required library.

huhongyu

hello,when i user ie open this, ie would make me downlaod.

http://Verycoolsupportandoutstandingsupports Sripati Das

It really helped me to configure json in spring 3.0. Big thanks to you from me :)

Trung

Hi in Your source Exsample and your description, there has not “/kfc/brands” folder. in that folder, what does it have? so, I can not run your Example. You would like to show me, please

Karthick

Hi, Im getting the below error when trying to do this(@ResponseBody),

com.ibm.ws.webcontainer.webapp.WebApp logServletError SRVE0293E: [Servlet Error]-[chpServlet]: com.ibm.ws.webcontainer.webapp.WebAppErrorReport: SRVE0295E: Error reported: 500 at com.ibm.ws.webcontainer.webapp.WebAppDispatcherContext.sendError(WebAppDispatcherContext.java:624) at com.ibm.ws.webcontainer.webapp.WebAppDispatcherContext.sendError(WebAppDispatcherContext.java:642) at com.ibm.ws.webcontainer.srt.SRTServletResponse.sendError(SRTServletResponse.java:1236) at com.ibm.ws.webcontainer.srt.SRTServletResponse.sendError(SRTServletResponse.java:1210) at org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver.handleHttpMessageNotWritable(DefaultHandlerExceptionResolver.java:344) at org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver.doResolveException(DefaultHandlerExceptionResolver.java:131) at org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver.resolveException(AbstractHandlerExceptionResolver.java:136) at org.springframework.web.servlet.DispatcherServlet.processHandlerException(DispatcherServlet.java:1120) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:944) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778) at javax.servlet.http.HttpServlet.service(HttpServlet.java:575) at javax.servlet.http.HttpServlet.service(HttpServlet.java:668) at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1214) at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:774) at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:456) at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:178) at com.ibm.ws.webcontainer.filter.WebAppFilterChain.invokeTarget(WebAppFilterChain.java:125) at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:77) at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:926) at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1023) at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:87) at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:895) at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1662) at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:195) at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:452) at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:511) at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:305) at com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:83) at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165) at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217) at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161) at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138) at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204) at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775) at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905) at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1659)

Any inputs on this. Although this happens for one type of object only. Im running Spring 3.1.2 on WAS 8.

Jack Beukering

I now have exacltly the same problem, did you find any solution for your problem? Please help me.

Karthick

Yeah I was able to figure that out. I had an empty class(that was JAXB Generated). It was causing the issue. Like, public class DataIndicator{}. There was no variable within it. I changed the schema(that was in my case). Check if you have a similar empty class(that is a part of the response object that ur trying to convert it to JSON). Hope this helps!!

Thanks for this post. I dont see an configuration which explicitly sets the response type to json. Is that something that happens by default. For example if i wanted to have an xml response type what would i need to do?

Thanks, N

ruofeng

how to do ,i want to know too

swapnil narvekar

This is very nice website… Very useful articles are posted here.. Thanks for you…

Kevin_405

Would be nice if u can enhance the tutorial for WADL and some way of generating the code from the WADL like we could do using WSDL

I just hate REST because it got rid of the Service Definition part of SOAP for convenience.

what about post how to get the json data post in the json format … please give an example

Faheem

i am getting this error when running this example in browser. plz help

The resource identified by this request is only capable of generating responses with characteristics not acceptable according to the request “accept” headers ().

raghavendra.katta

Hi,

You should in servlet.xml file and ensure the file should be error free.

raghavendra.katta

add in servlet.xml

ATaK

I get this same exact error in response. Status 406: “The resource identified by this request is only capable of generating responses with characteristics not acceptable according to the request “accept” headers ().”

Solution – This is a followup to the problem I had posted earlier which is now resolved. Hopefully this helps anybody else who might face this. The solution for the “406” error in my case was to make the POJO getter methods public [I had them protected]

Since the servlet name, as defined in web.xml, is mvc-dispatcher, the default dispatcher servlet name is mvc-dispatcher-servlet.xml, which coincides with the given name in the web.xml If you try to give any other name via this mechanism, the application will not work. You need to specify via servlet’s init-param as follows:

Code snippet such as the following will allow UI to get to the controller: $(document).ready(function() { $.getJSON(“http://localhost:8080/SpringMVC/rest/kfc/brands/kfc-kampar”, function(shop) { alert(shop.name); }); });

DT

When I run this example, its giving me Open/Save dialog on UI instead of printing JSOn data on browser.