Solved

No mapping found for HTTP request with URI in DispatcherServlet with name 'dispatcher'

Posted on 2014-02-12
8
8,808 Views
Last Modified: 2014-02-21
Hi,

I am  getting an error while running the application, I am using jboss 7.1

what is the issue


11:27:13,409 WARN  [org.springframework.web.servlet.PageNotFound] (http-localhost-127.0.0.1-8000-1) No mapping found for HTTP request with URI [/SpringExample11/userRegistration.htm] in DispatcherServlet with name 'dispatcher'

Here is my web.xml
<?xml version="1.0" encoding="UTF-8"?>
<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>SpringExample11</display-name>
  <servlet>
        <servlet-name>dispatcher</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>dispatcher</servlet-name>
        <url-pattern>*.htm</url-pattern>
    </servlet-mapping>
    <welcome-file-list>
        <welcome-file>redirect.jsp</welcome-file>
    </welcome-file-list>
</web-app>

Open in new window



 <?xml version="1.0" encoding="UTF-8" ?> 
- <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
  <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver" p:prefix="/WEB-INF/jsp/" p:suffix=".jsp" /> 
  <bean id="userService" class="com.vaannila.service.UserServiceImpl" /> 
  <context:component-scan base-package="com.vaannila.web" /> 
  <bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping" /> 
  <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" /> 
  </beans>

Open in new window

0
Comment
Question by:roy_sanu
  • 5
  • 2
8 Comments
 
LVL 20

Expert Comment

by:chaitu chaitu
ID: 39855418
check whether userRegistration.htm exists or not in SpringExample11.war directory.
0
 

Author Comment

by:roy_sanu
ID: 39855428
it is working tomcat 7 but not with Jboss 7, what might be the reason
0
 
LVL 35

Expert Comment

by:mccarl
ID: 39855721
I think the difference between Tomcat and JBoss is in the way the app is getting deployed. If this is the url that you are currently using...

http://localhost:8000/SpringExample11/userRegistration.htm

...then try the following instead...

http://localhost:8000/userRegistration.htm



If this isn't the problem, then can you please post the code for your Spring controller class?
0
 

Author Comment

by:roy_sanu
ID: 39855745
No, it is not working with the above url, same error

Here is the piece of controller code...........
@Controller
@RequestMapping("/userRegistration.htm")
@SessionAttributes("user")
public class UserController {

	private UserService userService;

	@Autowired
	public void setUserService(UserService userService) {
		this.userService = userService;
	}
	
	@RequestMapping(method = RequestMethod.GET)
	public String showUserForm(ModelMap model)
	{
		User user = new User();
		model.addAttribute(user);
		return "userForm";
	}

	@RequestMapping(method = RequestMethod.POST)
	public String onSubmit(@ModelAttribute("user") User user) {
		userService.add(user);
		return "redirect:userSuccess.htm";
	}
	
}

Open in new window

0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
LVL 35

Expert Comment

by:mccarl
ID: 39855969
Can you post the full logs, including before the error message. Spring should have logged what controllers it found and their request mappings which should help debug why it can't find this one.
0
 

Author Comment

by:roy_sanu
ID: 39856713
22:50:41,455 INFO  [org.jboss.as] (MSC service thread 1-7) JBAS015874: JBoss AS 7.1.1.Final "Brontes" started in 125162ms - Started 222 of 299 service
s (76 services are passive or on-demand)
22:50:42,105 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS018559: Deployed "SpringExample11.war"
23:01:36,891 WARN  [org.springframework.web.servlet.PageNotFound] (http--127.0.0.1-8080-1) No mapping found for HTTP request with URI [/SpringExample1
1/userRegistration.htm] in DispatcherServlet with name 'dispatcher'
23:01:57,812 WARN  [org.springframework.web.servlet.PageNotFound] (http--127.0.0.1-8080-1) No mapping found for HTTP request with URI [/SpringExample1
1/userRegistration.htm] in DispatcherServlet with name 'dispatcher'

Open in new window



In the redirect.jsp page

%@page contentType="text/html" pageEncoding="UTF-8"%>
<% response.sendRedirect("userRegistration.htm"); %>

Open in new window

0
 

Accepted Solution

by:
roy_sanu earned 0 total points
ID: 39862984
Added BeanNameUrlHandlerMapping it is working fine...............
	<bean class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping"/>

		<bean name="/userRegistration.htm" class="com.vaannila.web.UserController" />
	<bean name="/userSuccess.htm" class="com.vaannila.web.UserSuccessController" />
	

Open in new window


thanks
0
 

Author Closing Comment

by:roy_sanu
ID: 39876318
This is working fine now..........
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn how to implement Singleton Design Pattern in Java.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now