I followed the steps in this tutorial to create a Hello World servlet in a new dynamic web project in eclipse. But when I got to the section marked "5. Run Your Servlet Code", the application failed to run (I got a 404 error message in the browser). Any suggestions?
Asked
Active
Viewed 1,813 times
0
-
I don't see any messages about the deployment of the app. what happened when you tried to deploy it? – eis Aug 14 '13 at 17:13
-
Get the URL you use correct. There's no good reason to touch the server.xml. If Eclipse is modifying it, I'd suggest that you stop using Eclipse. – duffymo Aug 14 '13 at 17:13
-
@duffymo Eclipse only modifies it when add/removing webapps from the Tomcat instance. – Sotirios Delimanolis Aug 14 '13 at 17:14
-
There's no reason at all to do so. It's a poor design. Deploy a WAR and leave that server.xml alone. – duffymo Aug 14 '13 at 17:18
-
@duffymo The reason is you can control the context path through eclipse. – Sotirios Delimanolis Aug 14 '13 at 17:20
-
Nope, IntelliJ does it without touching the server.xml. Get a smarter IDE. – duffymo Aug 14 '13 at 17:20
-
1@Duffy: Eclipse is configurable to do so. By default, it creates own copy of `server.xml` in *Servers* project. But it's configurable to "Use Tomcat Installation" instead and thus touch its `server.xml`. Related: http://stackoverflow.com/a/7114455 This is not IDE's own thing, but enduser's own choice. The smartness must then be questioned in enduser's side. – BalusC Aug 14 '13 at 17:25
-
@CodeMed It seems like your build path is not setup correctly. Is your source code in a source folder? Check the project build path by right-clicking on it. – Sotirios Delimanolis Aug 14 '13 at 17:33
-
@CodeMed No, that is correct. `Java Resources` isn't a real folder, it's just a view for Eclipse. In the Project Properties, you can look through the `Deployment Assembly` for anything that is missing. – Sotirios Delimanolis Aug 14 '13 at 17:42
-
@CodeMed No that is correct. Honestly, just JAR your file (eclipse export) and copy paste it into your Tomcat's installation `webapps` directory and startup Tomcat from /{installationDir}/bin/startup.bat`. – Sotirios Delimanolis Aug 14 '13 at 17:48
-
@CodeMed You can drop the `war` (not jar sorry, but that might work too) directly into the webapps folder. In your Tomcat installation directory, there is a `bin` folder with a `startup.bat` file you can execute from the command line. – Sotirios Delimanolis Aug 14 '13 at 17:56
-
@CodeMed Haha, I get you dude, np! It's hard to say because I'm making a million assumptions about what you about Java, Eclipse, and Tomcat. Unless I have your project in front of me, I can only offer suggestions. Try going through the tutorial steps again. – Sotirios Delimanolis Aug 14 '13 at 18:17
1 Answers
0
If the server says ClassNotFoundException, it means the Class is Not Found Exception :-)
Did you check your deploy and work directories inside tomcat? verify you really have the class inside your war (or uncompressed in the work dir)
If not: put them manually to check your code works; then check why your eclipse or netb doesn't copy them to the server deployement dir

Zied Hamdi
- 2,400
- 1
- 25
- 40