Reputation: 11053
I am trying just to run a servlet on my local Tomcat with Eclipse.
But I keep getting this error and do not have any idea what to do differently.
I actually recorded it here : http://www.screenr.com/ZyD8
Many thanks!
Also I changed the web.xml to this:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID"
version="3.0"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" >
<display-name>
TEST3
</display-name>
<welcome-file-list>
<welcome-file>
TEST3
</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>
helloServlet
</servlet-name>
<servlet-class>
HelloServlet
</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>
helloServlet
</servlet-name>
<url-pattern>
/hello
</url-pattern>
</servlet-mapping>
</web-app>
Upvotes: 11
Views: 60166
Reputation: 1
I am gonna divide this problem in two scenarios:
scenario 1: you are trying to run/execute html/jsp file but getting this error.
scenario 2: you have successfully executed jsp/html file but it is not executing next servlet file. example: there is jsp submit form in webcontent/webapp, it is getting executed but after filling and submitting form you are getting this error.
Scenario 1:
Make sure that your jsp/html file are in webcontent/webapp folder that you created at the time of project creation.
check web.xml
file where content should be like this:
try changing tomcat server version.
Scenario 2:
Upvotes: 0
Reputation: 1243
Normally, when you modify the web.xml file, you should "clean" Tomcat. Just right-click on Tomcat in Eclipse and clean. Do same for project. You may also stop Tomcat, remove the app from Tomcat (right-click on app under Tomcat and remove) and then add it back. Restart Tomcat.
Upvotes: 0
Reputation: 41
I have been seeing these types of issue for quite sometime and have seen multiple solutions which work for some and rest still face the same issue.
One of the simple solution is traverse to the .java/.jsp/etc., right click and select run from server option.
I found this solution to be simple yet effective way of running.
path Java Resource->src->->example.java-->right click-->run as-->run on server.
Even after this also you can face few issues like port 8005 not available, please follow the below link to clean out your current Apache setting and re-setting the same.
Deployment error:Starting of Tomcat failed, the server port 8080 is already in use
Hope this finding was helpful.
Upvotes: 4
Reputation: 151
This is based on the answer from Hardik Mishra with some highlights: 1. From the file explorer (not from Eclipse), Manually create the "/WEB-INF/classes" under /WebContent 2. Right Click Project --> Properties, Select Java Build Path --> source Tab --> Change Default output folder to the folder you just created above. 3. go to the file explorer, not from Eclipse, since the Eclipse "project Explorer" may have some filters that doesnot show the classes folder. You should see the .class files compiled under this directory
Try to test it again. If it does not work, restart Eclipse for one time and then it should work.
Upvotes: 7
Reputation: 14877
I have seen your link.
When ever you run any dynamic web project. By default Servlet
container (which is Tomcat in this case) searches for files specified in wel-come list. Check your web.xml
, it should contains entry like
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
You haven't created file from any of the above list. So, running
http://localhost:8080/TEST2
will give you 404 error.
Rather run : http://localhost:8080/TEST2/HelloSerlvet
will invoke the servlet which you have created.
Edit: Check Project Menu of eclipse and verify "Build Automatically" is checked and Servlet container is running (http://localhost:8080
).
Edit 2: Right Click Project --> Properties, Select Java Build Path --> source Tab --> Change Default output folder. Create /WEB-INF/classes
under /WebContent
(default in eclipse)
Upvotes: 21