aspose file tools*
The moose likes Spring and the fly likes Where should web.xml nd psring-servlet.xml be placed in the project struture? 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 "Where should web.xml nd psring-servlet.xml be placed in the project struture? " Watch "Where should web.xml nd psring-servlet.xml be placed in the project struture? " New topic
Author

Where should web.xml nd psring-servlet.xml be placed in the project struture?

Yuta Lolap
Ranch Hand

Joined: Jun 03, 2012
Posts: 80

Hi, Where should the web.xml and the mvc-dispatcher-servlet.xml be placed exactly in the project structure? Should it be in WEB-INF directly or some place else?

Also i am getting ClassNotFoundException for DispatcherServlet when i am trying to render the jsp. I have loaded all the jars that are required.

The web.xml and spring-servlet.xml are inside WEB_CONTENT/WEB-INF .

Please can you tell me as to why this exception would occur?

Prajakta Acharya
Ranch Hand

Joined: Nov 08, 2012
Posts: 136

Hi,

If you are getting a ClassNotFoundException for DispatcherServlet, that means the container is able to forward request to the Spring controller, which means web.xml is being referred correctly.
I hope you have kept all Spring specific jars in WEB-INF\lib.
Are you using Eclipse for deployment? Quite possible that there is some deployment issue.
Can you check at installed location on server that it is deployed properly?


Regards,
Prajakta
Sahil Thadhani
Greenhorn

Joined: Jul 03, 2013
Posts: 1
You can also see if you have included web and web-mvc jar of springs. They also need to be checked. You can also refer to the classpath and see if all the jars are getting picked up. Placing the two files in WEB-INF usually does not create problem.
Bill Gorder
Bartender

Joined: Mar 07, 2010
Posts: 1632
    
    7

web.xml should be directly under WEB-INF.

I would hope you use Maven or an alternative build tool to manage your dependencies. The Spring context XMLs can be placed in a number of different places. I suggest you read the following blog by one popular Spring evangelist and Spring trainer. He shows in this blog the entire project structure that he uses. Consequently very similar to that produced by the Spring Roo project which he is very involved with.

http://gordondickens.com/wordpress/2012/07/03/enterprise-spring-best-practices-part-1-project-config/


[How To Ask Questions][Read before you PM me]
Yuta Lolap
Ranch Hand

Joined: Jun 03, 2012
Posts: 80

Prajakta i checked the tomcat installation folder. Yes i am using eclipse. Yes the jars are under the lib folder too.
Yuta Lolap
Ranch Hand

Joined: Jun 03, 2012
Posts: 80

Bill Gorder wrote:web.xml should be directly under WEB-INF.
/


It is under WEB-INF i want to learn the basic setup without maven.
Yuta Lolap
Ranch Hand

Joined: Jun 03, 2012
Posts: 80

Sahil Thadhani wrote:You can also see if you have included web and web-mvc jar of springs. They also need to be checked. You can also refer to the classpath and see if all the jars are getting picked up. Placing the two files in WEB-INF usually does not create problem.


All the jars are getting picked up!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Where should web.xml nd psring-servlet.xml be placed in the project struture?
 
Similar Threads
Confusion regarding ViewResolvers in Sppring framework
not able to run Spring MVC app
The requested resource is not available.
Location of web.xml
Spring - ClassPathXmlApplicationContext not able to load the XML file