6

Morning, I already checked most of the answers to this problem (No mapping found for HTTP request with URI.... in DispatcherServlet with name) and also (No mapping found for HTTP request with URI [/ChickenTest/index] in DispatcherServlet with name 'dispatcherServlet') but I'm still getting "No mapping found for HTTP request with URI [/bmoa-surrounds/bmoa] in DispatcherServlet with name 'bmoa'", so, any help whould be apreciated:

pom:

<dependencies>
        <!-- Junit -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.11</version>
            <scope>test</scope>
        </dependency>

        <!-- Testng -->
        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <version>6.8.5</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
            <version>${spring.version}</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>${spring.version}</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context-support</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-beans</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-aspects</artifactId>
            <version>${spring.version}</version>
        </dependency>


        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.5</version>
        </dependency>    

        <!-- Log4j -->
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.17</version>
        </dependency>

        <dependency>
            <groupId>javax.xml.bind</groupId>
            <artifactId>jaxb-api</artifactId>
            <version>2.2.6</version>
        </dependency>
        <dependency>
            <groupId>javax.xml</groupId>
            <artifactId>jaxb-impl</artifactId>
            <version>2.1</version>
        </dependency>
    </dependencies>

then my web.xml

<display-name>bmoa-surrounds</display-name>

    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/bmoa-servlet.xml</param-value>
    </context-param>

    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

     <servlet>
        <servlet-name>bmoa</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>bmoa</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>


    <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>

my spring config file

<context:component-scan base-package="xxxx"/>
    <context:annotation-config/>
    <context:spring-configured/>

    <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix" value="/"/>
        <property name="suffix" value=".jsp"/>
    </bean>

and finally my controller

@Controller
public class BMOAServlet implements HttpRequestHandler {


    /**
     * 
     */
    @RequestMapping("/bmoa-surrounds/bmoa")
    public void handleRequest(final HttpServletRequest request,
            final HttpServletResponse response) throws ServletException,
            IOException {

         response.getWriter().write("result=" + handleIncomingMessage(request));
    }

I'm calling "http:// localhost :8080/bmoa-surrounds/bmoa?juan=9898" but I'm still geting No mapping found for HTTP request with URI [/bmoa-surrounds/bmoa] in DispatcherServlet with name 'bmoa', any ideas? my env is java6 a deploying to jboss

also im sure that the beans are beign loaded, I got this in the server log

12:34:06,671 INFO  [org.springframework.beans.factory.support.DefaultListableBeanFactory] (MSC service thread 1-5) Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@57ffa0: defining beans [BMOABussinesDelegate,properties,BMOAServlet,.........]; parent: org.springframework.beans.factory.support.DefaultListableBeanFactory@122d7c6

and also this

12:34:06,753 INFO  [org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping] (MSC service thread 1-5) Mapped URL path [/bmoa-surrounds/bmoa] onto handler 'BMOAServlet' 12:34:06,754 INFO  [org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping] (MSC service thread 1-5) Mapped URL path [/bmoa-surrounds/bmoa.*] onto handler 'BMOAServlet' 12:34:06,755 INFO  [org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping] (MSC service thread 1-5) Mapped URL path [/bmoa-surrounds/bmoa/] onto handler 'BMOAServlet'

doesnt the last one means that the mappings are loaded?? please help ;(

Community
  • 1
  • 1
Camilo Casadiego
  • 907
  • 3
  • 9
  • 33
  • changed acording to this http://stackoverflow.com/questions/12351777/no-mapping-found-for-http-request-with-uri-myappname-in-dispatcherservlet-wi?rq=1, my logfile changed: INFO [RequestMappingHandlerMapping] Mapped "{[/bmoa-surrounds/bmoa],... onto public void BMOAServlet.handleRequest(...) throws IOException but I'm still getting the same error WARN [PageNotFound] No mapping found for HTTP request with URI [/bmoa-surrounds/bmoa] in DispatcherServlet with name 'bmoa' – Camilo Casadiego Oct 23 '14 at 17:54
  • 1
    Change your servlet mapping url pattern to: /*. Let me know how that goes – Angad Oct 23 '14 at 17:56
  • now it doesn't even load the index.jsp 12:58:01,667 WARN [org.springframework.web.servlet.PageNotFound] (http--0.0.0.0-8080-1) No mapping found for HTTP request with URI [/bmoa-surrounds/bmoa] in DispatcherServlet with name 'bmoa' 12:58:01,943 WARN [org.springframework.web.servlet.PageNotFound] (http--0.0.0.0-8080-2) No mapping found for HTTP request with URI [/bmoa-surrounds/index.jsp] in DispatcherServlet with name 'bmoa' – Camilo Casadiego Oct 23 '14 at 17:58
  • Im guessing some miss configuration, because the log sais it has been mapped, the it says that theres no mapping :s – Camilo Casadiego Oct 23 '14 at 17:59
  • 1
    Does nobody care about [spring] anymore? [Almost 300 identical questions](http://stackoverflow.com/search?q=%22No+mapping+found+for+HTTP+request+with+URI%22+%22in+DispatcherServlet+with+name%22). Where's the canonical duplicate? Or is Stack Overflow and content curation misunderstood? – BalusC Mar 23 '16 at 07:48

3 Answers3

3

I'm feeling really dumb right now....at first (and thanks for the clue Angad), the url-pattern was wrong, it should point to the servlet, also, the loaded bean was BMOAServlet instead of bmoa, so when I changed the url-patter no bmoa, managed to see the error, at the end my web.xml needed to look like this:

<context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/bmoa-servlet.xml</param-value>
    </context-param>

    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

     <servlet>
        <servlet-name>bmoa</servlet-name>
        <servlet-class>org.springframework.web.context.support.HttpRequestHandlerServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>bmoa</servlet-name>
        <url-pattern>/bmoa</url-pattern>
    </servlet-mapping>


    <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>

and the bean class like this:

@Controller("bmoa")
public class BMOAServlet implements HttpRequestHandler {



    /**
     * 
     */
    @RequestMapping("/bmoa-surrounds/bmoa")
    public void handleRequest(final HttpServletRequest request,
            final HttpServletResponse response) throws ServletException,
            IOException {

         response.getWriter().write("result=" + handleIncomingMessage(request));
    }

Now everything works smooth, I also changed the servlet class like this:

<servlet>
        <servlet-name>bmoa</servlet-name>
        <servlet-class>org.springframework.web.context.support.HttpRequestHandlerServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
Nicholas K
  • 15,148
  • 7
  • 31
  • 57
Camilo Casadiego
  • 907
  • 3
  • 9
  • 33
0

Check this config file: src\main\webapp\WEB-INF\spring\appServlet\controllers.xml

content is like:

<context:component-scan base-package="org.springframework.samples.mvc" />

is your controller in "org.springframework.samples.mvc"?

Jerry Z.
  • 2,031
  • 3
  • 22
  • 28
-1

In pom.xml make sure packaging is set to war like <packaging>war</packaging> ,not to jar or any thing else.

Hadi Rasouli
  • 1,871
  • 3
  • 27
  • 43