java - Restful Web service issue - HTTP Status 404 - The requested resource is not available -
i trying 1 restful web service example when going hit url time getting http status 404 - requested resource not available
below detail of code, if want other information let me know
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_3_0.xsd" id="webapp_id" version="3.0"> <display-name>user management</display-name> <servlet> <servlet-name>jersey restful application</servlet-name> <servlet-class>org.glassfish.jersey.servlet.servletcontainer</servlet-class> <init-param> <param-name>jersey.config.server.provider.packages</param-name> <param-value>com.tutorialspoint</param-value> </init-param> </servlet> <servlet-mapping> <servlet-name>jersey restful application</servlet-name> <url-pattern>/rest/*</url-pattern> </servlet-mapping> </web-app>
service class
package com.tutorialspoint; import java.util.list; import javax.ws.rs.get; import javax.ws.rs.path; import javax.ws.rs.produces; import javax.ws.rs.core.mediatype; @path("/userservice") public class userservice { userdao userdao = new userdao(); @get @path("/users") @produces(mediatype.application_xml) public list<user> getusers(){ return userdao.getallusers(); } }
all jars
tomcat webapps
obviously, url shoud http://localhost:8080/usermanagement/rest/userservice/users
.
also can try delete * in <url-pattern>/rest/*</url-pattern>
Comments
Post a Comment