I am new to RestFul API. I have a sample Project which uses Maven. Am using Jboss server to deploy.
Problem is file is deployed but when i try to access the URl it says 404 error
url : http://localhost:8080/RESTEasy/rest/RESTEasyHelloWorld/data
There is no error in Console
Following are my files:
pom.xml
<project xmlns="http://ift.tt/IH78KX" xmlns:xsi="http://ift.tt/ra1lAU"
xsi:schemaLocation="http://ift.tt/IH78KX http://ift.tt/VE5zRx">
<modelVersion>4.0.0</modelVersion>
<groupId>com.rest</groupId>
<artifactId>RESTEasy</artifactId>
<version>0.0.1-SNAPSHOT</version>
<repositories>
<repository>
<id>JBoss repository</id>
<url>http://ift.tt/RvTNo3;
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jaxrs</artifactId>
<version>3.0.4.Final</version>
</dependency>
</dependencies>
</project>
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://ift.tt/ra1lAU"
xmlns="http://ift.tt/nSRXKP"
xsi:schemaLocation="http://ift.tt/nSRXKP http://ift.tt/1eWqHMP"
id="WebApp_ID" version="3.0">
<display-name>RESTEasy</display-name>
<servlet-mapping>
<servlet-name>resteasy-servlet</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
<!-- Auto scan REST service -->
<context-param>
<param-name>resteasy.scan</param-name>
<param-value>true</param-value>
</context-param>
<!-- this should be the same URL pattern as the servlet-mapping property -->
<context-param>
<param-name>resteasy.servlet.mapping.prefix</param-name>
<param-value>/rest</param-value>
</context-param>
<listener>
<listener-class>
org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap
</listener-class>
</listener>
<servlet>
<servlet-name>resteasy-servlet</servlet-name>
<servlet-class>
org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher
</servlet-class>
</servlet>
</web-app>
Rest Java file:
package com.rest;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.core.Response;
@Path("/RESTEasyHelloWorld")
public class RESTEasyHelloWorldService {
@GET
@Path("/{pathParameter}")
public Response responseMsg( @PathParam("pathParameter") String pathParameter
) {
String response = "Hello from: " + pathParameter;
return Response.status(200).entity(response).build();
}
}
Server Log:
08:51:54,288 INFO [org.jboss.as.server.deployment] (MSC service thread 1-6) JBAS015876: Starting deployment of "RESTEasy-0.0.1-SNAPSHOT.jar" (runtime-name: "RESTEasy-0.0.1-SNAPSHOT.jar")
08:51:54,300 INFO [org.jboss.as.server] (DeploymentScanner-threads - 1) JBAS018565: Replaced deployment "RESTEasy-0.0.1-SNAPSHOT.jar" with deployment "RESTEasy-0.0.1-SNAPSHOT.jar"
Aucun commentaire:
Enregistrer un commentaire