Tomcat Server running but Chapter 12 HelloWorld not running

29 views
Skip to first unread message

Javid Shamloo

unread,
Dec 27, 2016, 7:39:37 AM12/27/16
to Getting started with Spring Framework
Hello, I am having trouble running your simple helloworld spring app from chapter 12.  I downloaded your code for the third edition from your repository, and I followed all instructions in Appendix B to the letter, and was even able to run the bankapp program from Chapter 1.  However, when I try to run your helloworld app from Chapter 12, I get no errors, but a 404 error saying the requested resource isn't found.

However, I installed Tomcat server 8.0.39 according to Appendix B, and I was able to verify that it was installed correctly as I can certainly go to the Tomcat homepage, http://localhost:8080, from Eclipse.  I also verified that Maven was installed correctly and that it executes the eclipse:eclipse goal by using mvn eclipse:eclipse.  I also configured the M2_REPO classpath variable in the Eclipse IDE.  The server starts without any problems, the helloworld app builds with no errors in Maven, and I am able to open the helloworld project in Eclipse.  Everything works, except when I try to run it as described in the book, by right-clicking, going to Run As, and clicking Run on Server.  That's when I get the 404 error.  

Some extra things that I looked up and did are right-clicking and going to the properties of the helloworld app, and setting the Targeted Runtime to Apache Tomcat v8.0.  That didn't help.  I also looked up a lot of people saying to go to the properties of the server and click on the "Switch Location" button, followed by making sure the Server Locations had the "Use Tomcat Installation" radio button selected.  That didn't help.  I cleaned and ran the server and the project, as well as restarting the server a bunch of times.  Again, didn't help.

What am I missing here?  I'm assuming your code is correct, I haven't touched any of it, and I've followed all of your instructions in Appendix B, plus lots more I found online, but nothing seems to be working.  What am I doing wrong/not doing?

I am running everything on a Windows 7 64-bit machine, using Eclipse Neon, with a Tomcat Server 8.0.39 running jdk_1.8.0_102.

I'd really appreciate some help on this as I can't run any examples in the book or make any of my own without Spring working with a server :/

Thanks,

Javid

Javid Shamloo

unread,
Dec 27, 2016, 8:05:48 AM12/27/16
to Getting started with Spring Framework
Ok I solved it.  Apparently I had to go to http://localhost:8080/ch12-helloworld/helloworld/sayhello, which I wasn't doing as I was going to http://localhost:8080/ch12-helloworld/.  Clarification on this in Appendix B would be a great idea in the future, as I spent 5 hours on this supposed error and only found the solution after going to Chapter 12 and reading a little there.

Zedd

unread,
Sep 14, 2017, 6:06:48 AM9/14/17
to Getting started with Spring Framework
Hello :)

I have the same issue but can't figure out how to access to the /sayhello path.

IntelliJ seems to deploy ch12-helloworld war correctly though : 

Artifact ch12-helloworld:war: Artifact is being deployed, please wait...
sept. 14, 2017 12:00:51 PM org.apache.jasper.servlet.TldScanner scanJars
INFOS: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
INFO  org.springframework.web.servlet.DispatcherServlet - FrameworkServlet 'hello': initialization started
INFO  org.springframework.web.context.support.XmlWebApplicationContext - Refreshing WebApplicationContext for namespace 'hello-servlet': startup date [Thu Sep 14 12:00:51 CEST 2017]; root of context hierarchy
INFO  org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from ServletContext resource [/WEB-INF/spring/myapp-config.xml]
INFO  org.springframework.web.servlet.handler.SimpleUrlHandlerMapping - Mapped URL path [/sayhello] onto handler of type [class sample.spring.chapter12.web.HelloWorldController]
INFO  org.springframework.web.servlet.DispatcherServlet - FrameworkServlet 'hello': initialization completed in 583 ms
[2017-09-14 12:00:52,301] Artifact ch12-helloworld:war: Artifact is deployed successfully


Any idea that could help me ?
Reply all
Reply to author
Forward
0 new messages