cyberbemon cyberbemon - 2 months ago 6x
Java Question

Jersey hello world gives 404

I have the following code in my java class


public class Hello {
//This method is called is TEXT_PLAIN is request
public String sayPlainTextHello(){
return "Hello World";

//this method is called if TEXT_XML is requested
public String sayXMLHello(){
return "<?xml version=\"1.0\"?>"+"<Hello> Hello World"+"</hello>";

//this method is called if HTML is requested
public String sayHtmlHello(){
return "<html>"+"<title>"+"hello jersey"+"</title>"+"<body><h1>"+"hello World!!"+"</body></h1>"+"</html>";

I compiled it and exported it as a .WAR file , when I type

I get a 404 . I tried it in WTP, cURL they all return 404.. I'm using tomcat 7.0.26

Note: I am running Tomcat on port 80, and other servlets respond as expected.

web.xml config


The following URL gives me Http status 500

java.lang.ClassNotFoundException: com.sun.jersey.spi.container.servlet.ServletContainer


The problem has been fixed and this is how I did it.

I removed the jersey .jar files from the build path and replaced them in the WEB-INF\lib folder and everything worked.