Jersey REST Web Service, Tomcat, Eclipse and 404's -


i've read through number of posts, can't seem solve problem. you'll see tons of posts similar one, same tutorial. following them, can't seem answer.

essentially, i'm trying follow simple tutorial at: http://www.vogella.com/articles/rest/

i've made few changes make compatible jersey 2.x

i'm using: eclipse tomcat 6 (deployed/run within eclipse) jaxrs-ri-2.0 i've enabled jax-rs facet in eclipse

everything builds fine tomcat starts fine within eclipse can static page content via:

http://localhost:8080/resttest2/index.html

however, when try access service via:

http://localhost:8080/resttest2/jaxrs/hello

i receive 404 "message not found" , "the requested resource (not found) not available."

here web.xml located @ /webcontent/web-inf/web.xml

<?xml version="1.0" encoding="utf-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns="http://java.sun.com/xml/ns/javaee" 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"> <display-name>testrest2</display-name> <welcome-file-list>     <welcome-file>index.html</welcome-file> </welcome-file-list> <servlet>   <description>jax-rs tools generated - not modify</description>   <servlet-name>jax-rs servlet</servlet-name>   <servlet-class>org.glassfish.jersey.servlet.servletcontainer</servlet-class>     <init-param>       <param-name>com.sun.jersey.config.property.packages</param-name>       <param-value>testrest</param-value>     </init-param>     <load-on-startup>1</load-on-startup>     </servlet>     <servlet-mapping>       <servlet-name>jax-rs servlet</servlet-name>       <url-pattern>/jaxrs/*</url-pattern>     </servlet-mapping> </web-app> 

here java class:

package testrest;  import javax.ws.rs.get; import javax.ws.rs.path; import javax.ws.rs.produces; import javax.ws.rs.core.mediatype;  // plain old java object not extend class or implements  // interface  // class registers methods http request using @get annotation.  // using @produces annotation, defines can deliver several mime types, // text, xml , html.   // browser requests per default html mime type.  //sets path base url + /hello @path("/hello") public class hello {    // method called if text_plain request   @get   @produces(mediatype.text_plain)   public string sayplaintexthello() {     return "hello jersey";   }    // method called if xml request   @get   @produces(mediatype.text_xml)   public string sayxmlhello() {     return "<?xml version=\"1.0\"?>" + "<hello> hello jersey" + "</hello>";   }    // method called if html request   @get   @produces(mediatype.text_html)   public string sayhtmlhello() {     return "<html> " + "<title>" + "hello jersey" + "</title>"         + "<body><h1>" + "hello jersey" + "</body></h1>" + "</html> ";   }    }  

i have jax-rs user library configured , referenced includes jax-rs jars.

thoughts on cause web service not found?

jersey 2.0 not recognize init-param name com.sun.jersey.config.property.packages (web.xml). try change jersey.config.server.provider.packages described in serverproperties.provider_packages.


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -