Getting a 404 error to run a Jersey REST


I am trying to run my first HelloWorld Jersey project ever, read bunch of tutorials on it and I think theoretically it should work but of course I am doing something wrong that the page gives me a 404 error. Here is what I have:

I started with a DynamicWebProject in Eclise and using plugins convereted it to a Maven project. And added these to the POM file:

<pre class="lang-xml prettyprint-override"><dependency> <groupId>com.sun.jersey</groupId> <artifactId>jersey-core</artifactId> <version>1.8</version> </dependency> <dependency> <groupId>com.sun.jersey</groupId> <artifactId>jersey-server</artifactId> <version>1.8</version> </dependency> <dependency> <groupId>com.sun.jersey</groupId> <artifactId>jersey-json</artifactId> <version>1.8</version> </dependency> <dependency> <groupId>com.sun.jersey</groupId> <artifactId>jersey-client</artifactId> <version>1.8</version> </dependency> </dependencies>

Then I also added a pretty small class like this to have some Jersey annotations:

<pre class="lang-xml prettyprint-override">import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; @Path("/hello") public class HelloWorldResource { @GET @Produces("application/plain") public String getMessage() { // Forward request to service layer. return "Hello World"; } }

and I also registered Jersey with these in web.XML file:

<pre class="lang-xml prettyprint-override"> <servlet> <servlet-name>Jersey REST Service</servlet-name> <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class> <init-param> <param-name>com.sun.jersey.config.property.packages</param-name> <param-value>JerseyREST</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>Jersey REST Service</servlet-name> <url-pattern>/rest/*</url-pattern> </servlet-mapping>

NOTE: there were already some created in there, I haven't touched them yet. They are still there.

So with this configuration I did a Run On Server and went to




but getting a nasty HTTP Status 404 - /JerseyREST/jerseyrest/rest/hello error on that. And I can't figoure out what part I am doing wrong. Any suggesstions or places I take a look at?

Much appreciated.


I followed this link to implement my first Jersey Web Service : <a href="http://www.vogella.com/articles/REST/article.html" rel="nofollow">REST in Java</a> I run it on Tomcat v7.0 and it worked fine. Have you tried it on Tomcat? If not, I suggest you to try it. Sometimes it happened for me that I got 404 error permanently. To fix the error I deleted Tomcat and create a new server wizard and then it works fine.

As @Tom said it may related to "application/plain". Use MediaType.TEXT_PLAIN instead.

You need to add these jar files under /WEB-INF/lib/ : asm-3.1, jackson-core-asl-1.9.2, jackson-jaxrs-1.9.2, jackson-mapper-asl-1.9.2, jackson-xc-1.9.2, jersey-client-1.11, jersey-core-1.11, jersey-json-1.11, jersey-server-1.11, jersey-servlet-1.11, jettison-1.1 and jsr311-api-1.1.1.


<param-name>com.sun.jersey.config.property.packages</param-name> <param-value>JerseyREST</param-value>

the param value should point to the folder where you have created the class.


  • In Jaspersoft Studio, Sql server procedure returning fewer fields than expected
  • How to handle Service unavailable scenarios with Jersey REST
  • SQL Error : integrity constraint violation : foreign key no parent
  • WCF web service returning json format data
  • R connection to postgresql requiring SSL
  • How to get rid of “No jax-rs activator is defined for the project” warning?
  • Android: save file to downloads that can be viewed later
  • Turning String textfile into object array
  • Update recordset without updating database
  • Handle Authentication and Authorization in jax-rs webservice with cxf
  • How to get text which is not part of any element using jsoup?
  • Spring bean validation messages resolution
  • Is it possible to specialize on a static lifetime?
  • Fat binaries in iOS
  • How can I let users share their location in Bot Framework webchat channel?
  • Get a trait object reference from a vector
  • Put value at centre of bins for histogram
  • PDO error when wrong host name
  • HttpURLConnection Closing IO Streams
  • How to 'create temp table as select' in Slick?
  • Parsing a CSV string while ignoring commas inside the individual columns
  • C# - Serializing and deserializing static member
  • script to move all files from one location to another location
  • Sending data from AppleScript to FileMaker records
  • ILMerge & Keep Assembly Name
  • Symfony2: How to get request parameter
  • Display Images one by one with next and previous functionality
  • AT Commands to Send SMS not working in Windows 8.1
  • Run Powershell script from inside other Powershell script with dynamic redirection to file
  • Windows forms listbox.selecteditem displaying “System.Data.DataRowView” instead of actual value
  • How to include full .NET prerequisite for Wix Burn installer
  • json Serialization in asp
  • JTable with a ScrollPane misbehaving
  • apache spark aggregate function using min value
  • Is it possible to post an object from jquery to bottle.py?
  • unknown Exception android
  • Programmatically clearing map cache
  • Sorting a 2D array using the second column C++
  • failed to connect to specific WiFi in android programmatically
  • How can I use threading to 'tick' a timer to be accessed by other threads?