Link to home
Start Free TrialLog in
Avatar of gudii9
gudii9Flag for United States of America

asked on

rest example

hi,

trying below example

https://www.mkyong.com/webservices/jax-rs/jersey-hello-world-example/

HTTP Status 404 – Not Found


Type Status Report

Message /RESTfulExample/

getting below error

http://localhost:8080/RESTfulExample/

Description The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.


Apache Tomcat/8.5.23

please advise
Avatar of gudii9
gudii9
Flag of United States of America image

ASKER

Avatar of gudii9

ASKER

projectURL/rest/hello/

http://localhost:8080/RESTfulExample/rest/hello

is project url here is

http://localhost:8080/RESTfulExample??

how it is mapping?
ASKER CERTIFIED SOLUTION
Avatar of mccarl
mccarl
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of gudii9

ASKER

<web-app id="WebApp_ID" version="2.4"
	xmlns="http://java.sun.com/xml/ns/j2ee"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
	http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
	<display-name>Restful Web Application</display-name>

	<servlet>
		<servlet-name>jersey-serlvet</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>com.mkyong.rest</param-value>
		</init-param>
		<load-on-startup>1</load-on-startup>
	</servlet>

	<servlet-mapping>
		<servlet-name>jersey-serlvet</servlet-name>
		<url-pattern>/rest/*</url-pattern>
	</servlet-mapping>

</web-app>

Open in new window

i see web.xml as above pointing rest to jersey implementation servlet

i see resource as below
package com.mkyong.rest;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.core.Response;

@Path("/hello")
public class HelloWorldService {

	@GET
	@Path("/{param}")
	public Response getMsg(@PathParam("param") String msg) {

		String output = "Jersey say : " + msg;

		return Response.status(200).entity(output).build();

	}

}

Open in new window

Avatar of gudii9

ASKER

i may have to keep index file when i load project on server
http://localhost:8080/RESTfulExample