Geek
Geek

Reputation: 3329

HTTP Status 404 while trying to run my servlet

I have a dyanmic web project with a DAO FileDao in package de.vogella.wtp.filecounter.dao; and a servlet FileCounter in package de.vogella.wtp.filecounter.servlets; packages respectively. I was trying to run the servlet and changed the ports 8088 since my 8080 is already occupied with some other application. When I run this servlet I get the below error in console:

Jun 1, 2012 2:39:13 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting propert
y 'source' to 'org.eclipse.jst.jee.server:de.vogella.wtp.filecounter' did not fi
nd a matching property.
Jun 1, 2012 2:39:13 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8088"]
Jun 1, 2012 2:39:13 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8010"]
Jun 1, 2012 2:39:13 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 380 ms
Jun 1, 2012 2:39:13 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Jun 1, 2012 2:39:13 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.27
Jun 1, 2012 2:39:13 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8088"]
Jun 1, 2012 2:39:13 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8010"]
Jun 1, 2012 2:39:13 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 260 ms

This is the error:

HTTP Status 404 - /de.vogella.wtp.filecounter/servlet/de.vogella.wtp.filecounter.servlets.FileCounter

--------------------------------------------------------------------------------

type Status report

message /de.vogella.wtp.filecounter/servlet/de.vogella.wtp.filecounter.servlets.FileCounter

description The requested resource (/de.vogella.wtp.filecounter/servlet/de.vogella.wtp.filecounter.servlets.FileCounter) is not available.


--------------------------------------------------------------------------------

Apache Tomcat/7.0.27

Any guesses on what went wrong?

Upvotes: 0

Views: 1419

Answers (2)

Alan
Alan

Reputation: 241

I was doing the same tutorial and had the same problem. I guess it's a pretty common tutorial, so I'll leave my answer here.

In my installation, Eclipse does not create a web.xml by default. When creating a Servlet, Eclipse uses annotations for mapping. I accidentaly erased the annotation when copying the tutorial's code. I guess you did the same.

To solve it I included a @WebServlet annotation before the class. Like this:

@WebServlet("/FileCounter")
public class FileCounter extends HttpServlet {
...

Upvotes: 0

Himanshu Soni
Himanshu Soni

Reputation: 461

HTTP Error 404 means page or resources not found. So you just typed incorrect URL. just check URL in web.xml and the URL typed in browser.

Here, maybe FileCounter class is misplaced. check it too.

Upvotes: 1

Related Questions