Ms. Flo
Ms. Flo

Reputation: 31

Resource not available problem

I get a HTTP Status 404 - Requested resource (/Fun/hello) is not available.
I am running Tomcat 7.0, Jersey 1.8, Java 1.6, Eclipse Helios 2.
I am working from a tutorial by Lars Vogel.

As far as I can tell, the resource is being loaded:

INFO: Root resource classes found:
  class bighello.Hello

web.xml

<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee                       http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"> 
  <display-name>Fun</display-name>
  <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>bighello</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>

</web-app>

Any ideas?

Upvotes: 3

Views: 2728

Answers (1)

Ken Chan
Ken Chan

Reputation: 90497

In the web.xml , you only map one URL pattern , which is /rest/* to call the servlet.

But now , your request URL is /Fun/hello , which does not match any URL patterns you defined in the web.xml , so it returns HTTP Status 404

In fact, refer to section 3.4 of your mentioned tutorial , you should test your REST service under: http://localhost:8080/de.vogella.jersey.first/rest/hello.

Upvotes: 5

Related Questions