4

I am trying to develop a RESTful web service using Spring framework with Apache Tomcat. I added two controller classes which had some 5-6 endpoints which were working fine. But since yesterday when I am trying add another endpoint I am getting a strange error.

@Controller
@RequestMapping("/test")
public class TextController {

    @RequestMapping(method=RequestMethod.POST)
    public void test() {
        System.out.println("Hello world");
    }
}

When i try this URL from the browser(using a REST client) I am getting the following output:

Hello world

Jun 25, 2014 7:05:55 PM org.springframework.web.servlet.PageNotFound noHandlerFound
WARNING: No mapping found for HTTP request with URI [/ChitChatApp/rest/test/test] in         DispatcherServlet with name 'chitchat-dispatcher'

The url is showing an extra "/test" appended. My other APIs are still working fine. Just the new ones I am adding are giving this error.

My web.xml looks like this:

<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"    xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>ChitChat Web Service</display-name>

<servlet>
    <servlet-name>chitchat-dispatcher</servlet-name>
    <servlet-class> org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <!-- Creates the Spring Container shared by all Servlets and Filters -->
    <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/chitchat-servlet.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>chitchat-dispatcher</servlet-name>
    <url-pattern>/rest/*</url-pattern>
</servlet-mapping>
</web-app>

Not sure why this started happening all of a sudden. Would appreciate some help on this.

Shaggy
  • 1,444
  • 1
  • 23
  • 34
araju
  • 103
  • 1
  • 5

1 Answers1

0

From the @RequestMapping("/test") it seems like the url should be "somprefix/test" but you send the request to URL "/ChitChatApp/rest/test/test", Does this a mistake?

igreenfield
  • 1,618
  • 19
  • 36