• 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

HTTP Status 404 - /ListenerTest//ListenTest.do

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

Many have gone before me and i have read through their solutions you guys handed to them. But my error is not solved by these answers.

Here are my .class files and the locations they are in. Also the log file that clearly states "java.lang.ClassNotFoundException: com.example.MyServletContextListener"

Please help me move forward. Thanks a lot.

web.xml


MyServletContextListener



ListenerTester

Dog


logging in localhost.2016-08-25.log

Locations
C:\Tomcat\webapps\listenerTest\classes\com\example\Dog.class
C:\Tomcat\webapps\listenerTest\classes\com\example\ListenerTester.class
C:\Tomcat\webapps\listenerTest\classes\com\example\MyServletContextListener.class
C:\Tomcat\webapps\listenerTest\etc\web.xml

URL in browser:
http://localhost:8080/listenerTest/ListenTest.do

Result:

HTTP Status 404 - /listenerTest/ListenTest.do

type Status report
message /listenerTest/ListenTest.do
description The requested resource is not available.

Apache Tomcat/9.0.0.M9

In the "Tomcat Web Application Manager" it also shows:
Applications
/listenerTest
Running
true



 
Rancher
Posts: 4801
50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
C:\Tomcat\webapps\listenerTest\WEB-INF\classes

Looks like you are missing a folder.
And etc should be in there as well.
And I think web.xml should be directly in WEB-INF, not etc.
 
Arend van der Kolk
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Dave,

You are so right. The folder mistake (missing WEB-INF) was just an redo error when redoing the whole folder set up again as a second attempt.

But the location of the web.xml was my crucial mistake. Its now all like below and working.

Correct location

C:\Tomcat\webapps\listenerTest\WEB-INF\classes\com\example\MyServletContextListener.class
C:\Tomcat\webapps\listenerTest\WEB-INF\classes\com\example\ListenerTester.class
C:\Tomcat\webapps\listenerTest\WEB-INF\classes\com\example\Dog.class

C:\Tomcat\webapps\listenerTest\WEB-INF\web.xml

Result:

http://localhost:8080/listenerTest/ListenTest.do

Test context attributes set by listener

Dog's breed is: Great Dane

Thanks a million for helping me out. After 2 hours i start staring at the screen, ;-)

cheers,

Arend
 
Arend van der Kolk
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The web.xml in the /etc folder is a copy/paste mistake from the development folder structure they make us use in the book.

Development folder structure: (NOT deployment)

C:\MyProjects\listenerTest\classes
C:\MyProjects\listenerTest\etc\web.xml
C:\MyProjects\listenerTest\lib
C:\MyProjects\listenerTest\src
C:\MyProjects\listenerTest\web
 
Dave Tolls
Rancher
Posts: 4801
50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's an odd structure.
I would have expected it to sit under maybe the web directory, under WEB-INF.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic