• 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Need help in deploying web application

 
Ranch Hand
Posts: 172
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!

I am learning Spring from the book Spring in Action.

I have:

HomeController.java



RootConfig.java


SpittrWebAppInitializer.java


WebConfig.java



Problem is: when I run on server in Tomcat 7 , the web application does not deploy. It gives me a 404 error.

Here is the console log:



There is a warning on line 17. It could be related to the problem.

Please help. Thanks.
 
Ranch Hand
Posts: 624
9
BSD Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do you have a JSP?
If yes, what is the name of the JSP and what is its location in the application?
 
Alan Blass
Ranch Hand
Posts: 172
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!

Yes I do. It is at WebContent/WEB-INF/views/home.jsp.



Please help. Thanks.
 
Alan Blass
Ranch Hand
Posts: 172
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Somebody? Please.
 
Ranch Hand
Posts: 672
4
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is the URL, you are trying to access? Did you make sure, it is invoking the HomeController, by writing log messages?
 
Alan Blass
Ranch Hand
Posts: 172
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!

I am trying to access http://localhost:8080/Spittr. The 404 is the Apache Tomcat 404 error.

I have done a system.out.println() text just before return "home" in the HomeController.java. It didn't print out.

Here is the log again:



Please help. Thanks.
 
Prasad Krishnegowda
Ranch Hand
Posts: 672
4
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
From the logs, i see the application is deployed correctly, can you add JSP/HTML inside WebContent, and try to access it directly, like http://localhost:8080/Spittr/<jsp/html file>.
Also, can you change the RequestMapping of HomeController, to say like /home and try accessing http://localhost:8080/Spittr/home
 
Alan Blass
Ranch Hand
Posts: 172
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!

I have placed another file named hello.jsp in WebContent/ directory. I can access it in this URL: http://localhost:8080/Spittr/hello.jsp

But my home.jsp is in WebContent/WEB-INF/views/ directory. I cannot access it using the following URLs:

1) http://localhost:8080/Spittr/
2) http://localhost:8080/Spittr/home
3) http://localhost:8080/Spittr/home/home.jsp
4) http://localhost:8080/Spittr/home.jsp

I have also change the RequestMapping of HomeController to

@RequestMapping(value="/home", method=GET)

But I am still not getting the webpage.

Please help. If you need more information/logs, please ask me. Thanks.

 
Ranch Hand
Posts: 733
7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I refer to your first post. In fact, I see some flaws right there already.

[1] In the two @ComponentScan annotations (one in an expanded form with basePacages, one in a concised form without, which is fine though), they refer to basePackages either "spitter" and "spitter.web". In fact, there isn't any package of that sort, it should be "spittr" and "spittr.web" respectively. I then check out the book referred, I conclude that the book has made these annoying typos - at a terrible key data to make such kind of typos. They should be read as I mentioned. (Two places to correct.)

[2] Then the "spittr.web" appears in the WebConfig class which has the purpose of sending you a resolver for a view. But your controller HomeController is pretended to be located in the package spittr.config, meaning incorrect and the @ComponentScan will never find it. Hence, your HomeController should be placed in the package spittr.web instead of spittr.config.

[2.1] In case you seem to have only the directory structure spittr/config. You should made the new directory spittr/web and place the HomeController.java there instead of the placing now in spittr/config.

[3] After build and deploy, you should access to http://localhost:8080/spittr/ with a slash only at the end as specified in the original @RequestMapping value also with a spittr in lower-case "s".
 
Alan Blass
Ranch Hand
Posts: 172
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Tsuji,

Thanks! I did 1,2, 2.1 and it works.

Thanks to all who tried to help.
 
reply
    Bookmark Topic Watch Topic
  • New Topic