aspose file tools*
The moose likes Spring and the fly likes No mapping found for HTTP request with URI [/springmvc/login.do] in DispatcherServlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "No mapping found for HTTP request with URI [/springmvc/login.do] in DispatcherServlet" Watch "No mapping found for HTTP request with URI [/springmvc/login.do] in DispatcherServlet" New topic
Author

No mapping found for HTTP request with URI [/springmvc/login.do] in DispatcherServlet

Brajesh Choudhary
Greenhorn

Joined: May 24, 2012
Posts: 8
Hi Friends

I'm getting this error

No mapping found for HTTP request with URI [/springmvc/login.do] in DispatcherServlet with name 'dispatcher'.

my web.xml file


------------------------------------------------------------------------------------------------------------------------------------------------------------------------
my dispatcher-servlet.xml

----------------------------------------------------------------------------------------------------------------------------------------
my spring-business-context.xml

----------------------------------------------------------------------------------------------------------------------------------------------------------
my Controller class

Kindly help me
Regards
Ken Rimple
author
Ranch Hand

Joined: Jul 20, 2010
Posts: 63

Just curious, does .html work?


Ken Rimple
ken.rimple@gmail.com
Co-author, Manning Spring Roo in Action
I teach for Chariot Solutions (Spring, Maven, Hibernate, other courses). Schedule here
Brajesh Choudhary
Greenhorn

Joined: May 24, 2012
Posts: 8

Hi Ken

First I use *.html but after that I use *.do extension but it also not work for me as you see in my files.
Ken Rimple
author
Ranch Hand

Joined: Jul 20, 2010
Posts: 63

Brajesh Choudhary wrote:
First I use *.html but after that I use *.do extension but it also not work for me as you see in my files.


Hum... If you only use one, does it work? i.e. just have the single servlet-mapping entry. Also can't you do multiple url-pattern entries inside of the servlet-mapping? Perhaps having two mappings screws it up.

Have you tried /login.do instead of login.do? i.e. putting the path in first?

Also, have you tried path-based mapping? If you're on Spring 3.0.6 or higher you could literally use /* for the URL mapping, coupled with the <mvc:resources /> tag that describes where the non-JSP resources reside...

Otherwise in earlier versions you could use /controllers/* or something like that. Then in your UrlMapping you could use "/controllers/foo" and it would map. Generally path-based mapping seems to be a 'best practice' these days.
Brajesh Choudhary
Greenhorn

Joined: May 24, 2012
Posts: 8
Hi Ken

I don't know how but yesterday code works today but i get a new problem today while integrating hibernate with my spring project.

Here is stack Trace


my spring-business-context.xml


my hibernate.cfg.xml file


my datasource.xml


This is a maven project so I here providing my pom.xml


Ken Rimple
author
Ranch Hand

Joined: Jul 20, 2010
Posts: 63

First question - why are you mounting both a Session Factory AND a JPA Entity Manager Factory?

You only really need the Entity Manager Factory.

You should be able to use the hbm.xml files if you use Hibernate as a provider. Apparently they will be picked up automatically when you use the Hibernate EntityManager (which you'll use in your persistence.xml file as your provider). See http://docs.jboss.org/hibernate/entitymanager/3.6/reference/en/html/configuration.html for details on that, specifically 2.2.1.

I haven't done the hbm.xml mappings as part of a JPA 2 application, but I think it should be possible as long as you use the entity manager.

I am wondering if you want to use the container's Entity Manager. It's not needed in Spring, you could be using the LocalContainerEntityManagerFactoryBean - which is app server independent. While I would think the connection pool could be fetched from a Java EE datasource in JNDI, there is no practical benefit to using the container's entity manager that I can see and you make your application slightly less portable (you could run it on Tomcat or Jetty with the Spring one). Try setting up just these things:

- a Spring LocalContainerEntityManagerFactoryBean that sets up your JPA container
- a Spring JNDI DataSource - inject it into the bean above
- a JTA transaction manager - which you currently have commented out

That's all you really need. Make sure you include core hibernate as well as the hibernate entity manager, and you're on your way. Maybe a JBoss / Hibernate / Spring person will set me straight on this though (please do as I've not done that specific config myself).

I believe it's possible your class not found exception is coming from the fact that you're using an App Server's factory bean and maybe it doesn't implement or include the jar with that class in it? I'm not sure how JBoss's hibernate configuration matches or does not match the Spring way, but if you're on Spring, you want the Spring way primarily.

Here is setting up the entity factory - see the datasource injection, that's the key thing there. The transaction manager you use is Spring's delegate to the container's JTA manager, which relies on JBoss's configured datasources and is automatically enlisted (provide you've used XA drivers).



Here is an example of setting the persistence provider to Hibernate's entity manager - it's the org.hibernate.ejb.HibernatePersistence class:

persistence.xml:





Ken Rimple
author
Ranch Hand

Joined: Jul 20, 2010
Posts: 63

More importantly, do you know that you're using <dependencyManagement> to define your dependencies?

That really means you're not defining real dependencies. You're stating a preference that if a sub-project or one of your dependencies depends on something, you want it to depend on that version. I don't see all of them being used down below, so I'm assuming some either aren't being imported or are transitive.

If you're unsure whether this build is correct, you need to do some digging... Maybe the problem is related to a mixed up jar import being missing.

You can do a mvn help:effective-pom and paste that, it will tell you how the pom evaluates and what jars end up in the project. Better yet, mvn dependency:list and mvn dependency:tree output -Dverbose=true - that will tell us what it selected, and what conflicts, if any, existed.


Brajesh Choudhary
Greenhorn

Joined: May 24, 2012
Posts: 8
Hi Ken

Thanks for your quick reply.I have solved the previous problem but now a new problem comes.

Here is the stack trace





my spring-business-context.xml


my controller class


There is also a problem when I provide the hbm file or cfg file it gives error that file not found.As you see I have commented that code.
Ken Rimple
author
Ranch Hand

Joined: Jul 20, 2010
Posts: 63

The app is running from the target, not from the source code. So it will never find files in src/main/resources, because those have all been copied to target/classes and are in your class path.

Try:

<value>hibernate.cfg.xml</value>

or

<value>classpath:hibernate.cfg.xml</value>

Ken
Ken Rimple
author
Ranch Hand

Joined: Jul 20, 2010
Posts: 63

Also, on line 52 of your spring config, the bean setter is setTblSysUserDetailDAO, so your setter name is invalid. The property should have a name of "tblSysUserDetailDAO" - that's why it can't understand this.

Best of luck continuing on your project. I'd definitely take time to match your properties to log errors - I do this all the time and whenever I hand code XML I pay the price ;)

IntelliJ, Netbeans or Springsource Tool Suite (eclipse with the Spring IDE plugins installed) should help you with CTRL-SPACE so that you are picking valid bean and field names.

Best,

Ken
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: No mapping found for HTTP request with URI [/springmvc/login.do] in DispatcherServlet
 
Similar Threads
Spring annotation no handler found
STS springMVC project how to run on tomcat application
Problem running app under Tomcat v7
spring security 3.1 login not working.
No unique bean of type [javax.persistence.EntityManagerFactory] is defined: expected single bean but