• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

org.springframework.web.servlet.PageNotFound

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I downloaded a spring mvc hibernate integration example from the net, but could not get it to work. The error I am getting is:

org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/SpringMVCHibernate/] in DispatcherServlet with name 'appServlet'

My folder structure is attached as an image

PersonController.java


PersonDAO.java


PersonDAOImpl.java



Person.java


PersonService.java


PersonServiceImpl.java


servlet-context.xml


web.xml

save.png
[Thumbnail for save.png]
 
J Mohandos
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A silly mistake. Didn't add /persons to the url.After adding it, it works

Now I have a question. In the personController the method listPersons, editPerson use model object but other methods like addPerson and removePerson don't use model object. Why?
 
Ranch Hand
Posts: 672
4
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
listPerson is called to list the users, so they need the model object containing the users to display in the front end, so model object is used, in case of removePerson, there is no need of model object, so they are not using it.
 
J Mohandos
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok.

There is a use of @Qualifier annotation in the controller. When I remove that, I get an error:

No qualifying bean of type [com.journaldev.spring.service.PersonService] is defined: expected single matching bean but found 2: personService,personServiceImpl

Now both personService and personService are interface and corresponding implementing class respectively. Why would it give error on that?

I can understand if there are two beans defined for the same class with different ids, but that is not the case.

 
Prasad Krishnegowda
Ranch Hand
Posts: 672
4
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There might be multiple beans decalred for the personservice class.. can you post us your root-context.xml file.
 
J Mohandos
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is only bean declared for personservice class

servlet-context.xml
 
Prasad Krishnegowda
Ranch Hand
Posts: 672
4
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As i see in web.xml and the package image, i see root-context.xml inside WEB-INF/spring, I had asked for this file, Please post that.
 
J Mohandos
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nothing much is there in that file. Anyway, I will post it

root-context.xml
 
Prasad Krishnegowda
Ranch Hand
Posts: 672
4
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have no idea, then, we might have to wait for someone to help us on this.
 
J Mohandos
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you please just try out the example yourself by removing and adding the @Qualifier annotation? The tutorial I am referring to is:

http://www.journaldev.com/3531/spring-mvc-hibernate-mysql-integration-crud-example-tutorial
 
Rancher
Posts: 2759
32
Eclipse IDE Spring Tomcat Server
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have a @Service annotation on the PersonServiceImpl class. This means that spring will create an instance of PersonServiceImpl. You also have a PersonServiceImpl declared in your spring XML. THis creates another instance of PersonServiceImpl. SO, you have 2 instances of PersonServiceImpl
 
The two armies met. But instead of battle, they decided to eat some pie and contemplate this tiny ad:
create, convert, edit or print DOC and DOCX in Java
https://products.aspose.com/words/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!