Spring MVC and 406 Error XML request

Posted by Asp1de on Stack Overflow See other posts from Stack Overflow or by Asp1de
Published on 2012-07-09T15:12:35Z Indexed on 2012/07/09 15:15 UTC
Read the original article Hit count: 403

Filed under:
|
|
|
|

Hi i have a problem when running my code outside eclipse.

This is my Equinox enviroment:

Framework is launched.

id      State       Bundle
0       ACTIVE      org.eclipse.osgi_3.7.0.v20110221
1       ACTIVE      org.eclipse.equinox.common_3.6.0.v20110506
2       ACTIVE      org.eclipse.update.configurator_3.3.100.v20100512
3       RESOLVED    catalina-config_1.0.0
                Master=20
4       ACTIVE      org.springframework.osgi.catalina.start.osgi_1.0.0
                Fragments=62
5       ACTIVE      com.springsource.javax.activation_1.1.1
6       ACTIVE      com.springsource.javax.annotation_1.0.0
7       ACTIVE      com.springsource.javax.ejb_3.0.0
8       ACTIVE      com.springsource.javax.el_1.0.0
9       ACTIVE      com.springsource.javax.mail_1.4.0
10      ACTIVE      com.springsource.javax.persistence_1.0.0
11      ACTIVE      com.springsource.javax.servlet_2.5.0
12      ACTIVE      com.springsource.javax.servlet.jsp_2.1.0
13      ACTIVE      com.springsource.javax.servlet.jsp.jstl_1.1.2
14      ACTIVE      com.springsource.javax.xml.bind_2.0.0
15      ACTIVE      com.springsource.javax.xml.rpc_1.1.0
16      ACTIVE      com.springsource.javax.xml.soap_1.3.0
17      ACTIVE      com.springsource.javax.xml.stream_1.0.1
18      ACTIVE      com.springsource.javax.xml.ws_2.1.1
19      ACTIVE      com.springsource.org.aopalliance_1.0.0
20      ACTIVE      com.springsource.org.apache.catalina_6.0.18
                Fragments=3, 22
21      ACTIVE      com.springsource.org.apache.commons.logging_1.1.1
22      RESOLVED    com.springsource.org.apache.coyote_6.0.18
                Master=20
23      ACTIVE      com.springsource.org.apache.el_6.0.18
24      ACTIVE      com.springsource.org.apache.juli.extras_6.0.18
25      ACTIVE      com.springsource.org.apache.log4j_1.2.15
                Fragments=33
26      ACTIVE      com.springsource.org.apache.taglibs.standard_1.1.2
27      ACTIVE      org.springframework.osgi.commons-el.osgi_1.0.0.SNAPSHOT
28      ACTIVE      data_1.0.0
29      ACTIVE      Api_1.0.0
30      ACTIVE      connector_1.0.0
31      ACTIVE      core_1.0.0
32      ACTIVE      org.springframework.osgi.jasper.osgi_5.5.23.SNAPSHOT
33      RESOLVED    com.springsource.org.apache.log4j.config_1.0.0
                Master=25
34      ACTIVE      testController_1.0.0
35      ACTIVE      org.eclipse.core.contenttype_3.4.100.v20100505-1235
36      ACTIVE      org.eclipse.core.jobs_3.5.0.v20100515
37      ACTIVE      org.eclipse.equinox.app_1.3.0.v20100512
38      ACTIVE      org.eclipse.equinox.preferences_3.3.0.v20100503
39      ACTIVE      org.eclipse.equinox.registry_3.5.0.v20100503
40      ACTIVE      org.eclipse.osgi.services_3.2.100.v20100503
41      ACTIVE      osgi.core_4.3.0.201102171602
42      ACTIVE      dataImplementation_1.0.0
43      ACTIVE      org.springframework.osgi.servlet-api.osgi_2.4.0.SNAPSHOT
44      ACTIVE      org.springframework.aop_3.1.1.RELEASE
45      ACTIVE      org.springframework.asm_3.1.1.RELEASE
46      ACTIVE      org.springframework.beans_3.1.1.RELEASE
47      ACTIVE      org.springframework.context_3.1.1.RELEASE
48      ACTIVE      org.springframework.context.support_3.1.1.RELEASE
49      ACTIVE      org.springframework.core_3.1.1.RELEASE
50      ACTIVE      org.springframework.expression_3.1.1.RELEASE
51      ACTIVE      org.springframework.osgi.extensions.annotations_1.2.1
52      ACTIVE      org.springframework.osgi.core_1.2.1
53      ACTIVE      org.springframework.osgi.extender_1.2.1
54      ACTIVE      org.springframework.osgi.io_1.2.1
55      ACTIVE      org.springframework.osgi.mock_1.2.1
56      ACTIVE      org.springframework.osgi.web_1.2.1
57      ACTIVE      org.springframework.osgi.web.extender_1.2.1
58      ACTIVE      org.springframework.oxm_3.1.1.RELEASE
59      ACTIVE      org.springframework.transaction_3.1.1.RELEASE
60      ACTIVE      org.springframework.web_3.1.1.RELEASE
61      ACTIVE      org.springframework.web.servlet_3.1.1.RELEASE
62      RESOLVED    tomcat-configuration-fragment_1.0.0
                Master=4

My controller is:

    @RequestMapping(value = "/test1", method = RequestMethod.GET, produces = "application/json")
public @ResponseBody
Person test1() {

    logger.info(" <--- Test 1 ---> \n");

    Person p = new Person("a", "b", "c");

    return p;

}

@RequestMapping(value = "/test2", method = RequestMethod.GET, produces = "application/xml")
public @ResponseBody
Person test3() {

    logger.info(" <--- Test 1 ---> \n");

    Person p = new Person("a", "b", "c");

    return p;

}

@RequestMapping(value = "/test2", method = RequestMethod.GET, headers =  "Accept=*/*")
public @ResponseBody
Person test4() {

    logger.info(" <--- Test 1 ---> \n");

    Person p = new Person("a", "b", "c");

    return p;

}

@RequestMapping(value = "/parent", method = RequestMethod.GET, headers = "Accept=application/xml")
public @ResponseBody
Parent test2() {

    logger.info(" <--- Test 1 ---> \n");

    Parent p = new Parent("a", "b");

    return p;

}

If i run the TEST 1(json request) it works perfectly but when i run the test 2, 3 and 4 the browser give me back that error:

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

Could someone help me?

PS: if i run the bundle inside ECLIPSE it works perfectly. I generate the bundles with maven.

© Stack Overflow or respective owner

Related posts about spring

Related posts about mvc