Note that there are some explanatory texts on larger screens.

plurals
  1. PORest Web services returning a 404
    text
    copied!<p>This is my first time using Eclipse, and is causing me to rage a lot. </p> <p>I installed Tomcat 6.0, downloaded the Jersey libraries, and I followed the tutorials from : <a href="http://www.vogella.com/articles/REST/article.html#first_client" rel="noreferrer">http://www.vogella.com/articles/REST/article.html#first_client</a></p> <p>I created the Project Name as RestExample, and within that I have a package de.jay.jersey.first and within that I have a class HelloWorldResource, and here is what it looks like:</p> <pre><code>package de.jay.jersey.first; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; @Path("/hello") public class HelloWorldResource { // This method is called if TEXT_PLAIN is request @GET @Produces(MediaType.TEXT_PLAIN) public String sayPlainTextHello() { return "Hello Jersey"; } // This method is called if XML is request @GET @Produces(MediaType.TEXT_XML) public String sayXMLHello() { return "&lt;?xml version=\"1.0\"?&gt;" + "&lt;hello&gt; Hello Jersey" + "&lt;/hello&gt;"; } // This method is called if HTML is request @GET @Produces(MediaType.TEXT_HTML) public String sayHtmlHello() { return "&lt;html&gt; " + "&lt;title&gt;" + "Hello Jersey" + "&lt;/title&gt;" + "&lt;body&gt;&lt;h1&gt;" + "Hello Jersey" + "&lt;/body&gt;&lt;/h1&gt;" + "&lt;/html&gt; "; } } </code></pre> <p>and my web.xml looks like </p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5"&gt; &lt;display-name&gt;RestExample&lt;/display-name&gt; &lt;servlet&gt; &lt;servlet-name&gt;Jersey REST Service&lt;/servlet-name&gt; &lt;servlet-class&gt;com.sun.jersey.spi.container.servlet.ServletContainer&lt;/servlet-class&gt; &lt;init-param&gt; &lt;param-name&gt;com.sun.jersey.config.property.packages&lt;/param-name&gt; &lt;param-value&gt;de.jay.jersey.first&lt;/param-value&gt; &lt;/init-param&gt; &lt;load-on-startup&gt;1&lt;/load-on-startup&gt; &lt;/servlet&gt; &lt;servlet-mapping&gt; &lt;servlet-name&gt;Jersey REST Service&lt;/servlet-name&gt; &lt;url-pattern&gt;/rest/*&lt;/url-pattern&gt; &lt;/servlet-mapping&gt; &lt;/web-app&gt; </code></pre> <p>ANd I am trying to use curl as:</p> <p>curl <a href="http://localhost:8081/RestExample/rest/hello" rel="noreferrer">http://localhost:8081/RestExample/rest/hello</a></p> <p>Apache Tomcat/6.0.35 - Error report <h1>HTTP Status 404 - /RestExample/rest/Hello</h1><p><b>type</b> Status re port</p><p><b>message</b> /RestExample/rest/hello</p><p><b>de scription</b> The requested resource (/RestExample/rest/hello) is not available.</p>Apache Tomcat/6.0.35</p> <p>The question is what should I change in the web.xml so that I can access that resource?</p> <p>I tried RestExample/de.jay.jersey.first/rest/hello, and it still did not work. TOmcat is running without errors.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload