• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

yet another HelloWorld spring/maven/eclipse configuration befuddlement

 
Ranch Hand
Posts: 141
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Greetings all,

just another newbie eclipse/maven/spring webapp configuration tangle.

I've tried to set up my project with the canonical eclipse/maven/spring
webapp structure. It compiles and deploys w/o error to my local instance of tomcat.

But I can't seem to get to my index page.


pom.xml


\webapp\WEB-INF\web.xml


\WEB-INF\spring\root-context.xml


\WEB-INF\spring\appServlet\servlet-context.xml


\WEB-INF\views\index.jsp


\WEB-INF\views\contactMe.jsp


com.webspringtester.controller.BaseController.java---------------------


going to http://localhost:8080/hopeThisWorks yields the following msg in my eclipse console:
WARN [springframework.web.servlet.PageNotFound-noHandlerFound] - No mapping found for HTTP request with URI [/hopeThisWorks/] in DispatcherServlet with name 'spring-dispatcher'

I've googled up quite a few similar problems, seems it's tricky to get right, structure and names all have to jibe, could use some help please.

And on a tangential topic, is it considered best-practice to make use of a WebApplicationInitializer or not? Obviously I'm doing this all by hand but maybe there's a better way.

TIA,

Still-learning Steve
 
Bartender
Posts: 1682
7
Android Mac OS X IntelliJ IDE Spring Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I did not look really close at all your code but it jumped out at me that the URL you are hitting is not mapped to anything.

Your controller is mapped as follows:

@RequestMapping(value="/index", method = RequestMethod.GET)

This is expecting a GET request at http://hostname/context-root/index

Based on what you have posted I expect you should be trying to go to

http://localhost:8080/hopeThisWorks/index
 
Stuart Rogers
Ranch Hand
Posts: 141
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your response.

That is correct, I desire to enter http://localhost:8080/hopeThisWorks and/or http://localhost:8080/hopeThisWorks/index and have \WEB-INF\views\index.jsp get displayed

I starting to wonder if I'm using the correct Tomcat and/or browser. I successfully publish my project to "Tomcat v7.0 Server at localhost" in the Server tab within Eclipse, no errors thrown to the console, then enter http://localhost:8080/hopeThisWorks , http://localhost:8080/hopeThisWorks/index , http://localhost:8080/hopeThisWorks/index.jsp in my browser ==external== to Eclipse and get 404s for all three. So it seems there's still some subtly of configuration I'm missing :-(

Regards,

Still-learning Steve
 
Bill Gorder
Bartender
Posts: 1682
7
Android Mac OS X IntelliJ IDE Spring Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Lets start with simplifying your POM a bit. Maven has pretty sensible defaults. Try this:



Also you can have it match both in your Request mapping.

Try getting a program like 7zip and opening the WAR and seeing what is in there? Do things look like they are there and in the right place?
 
Stuart Rogers
Ranch Hand
Posts: 141
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Found out my problem wasn't with the code at all, but rather with me not remembering to Project->Maven->Update Project after changing the <build><finalName> value . So the old value for the context-root embedded in my project's .settings file was still on hopeThisWorks. So of course trying http://localhost:8080/webspringtester drew a 404.

Solution is to explictly set the name of the context-root in <build><plugins><plugin><maven-war-plugin><configuration><warName> . This overrides what you may have set using <build><finalName> in your pom.

Thanks for your replies,

CASE CLOSED

Still-learning Steve
reply
    Bookmark Topic Watch Topic
  • New Topic