-
1. Re: Simple JAX-RS
jaysensharma Mar 12, 2013 3:21 PM (in response to klind)1 of 1 people found this helpfulHi,
Try altering your Class "ProfitMock.java" as following:
import javax.inject.Inject; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import javax.ws.rs.ApplicationPath; import javax.ws.rs.core.Application; @ApplicationPath("profitmock") // ======> ** NOTICE ** Also notice this class extends "Application" @Path("api") @Produces(MediaType.APPLICATION_JSON) public class ProfitMock extends Application { @GET @Path("list") @Produces(MediaType.APPLICATION_JSON) public String list() { return "Hello World, I still need some work to be useful!"; } }
Depoy your application and then access it as folllowing : http://localhost:8080/profitMock-3.30.2-SNAPSHOT/profitmock/api/list
Basically you will need to follow any of the 3 options in the following link: https://docs.jboss.org/author/display/AS7/JAX-RS+Reference+Guide
The ApplicationPath annotation you have to use your POJO will not work, or use web.xml to do that.
try the Attached WAR : https://github.com/jaysensharma/MiddlewareMagicDemos/blob/master/Resteasy_JBoss_EAP6.1.Alpha/build/ResteasyService.war
Access the application as following: http://localhost:8080/ResteasyService/profitmock/api/list
-
2. Re: Simple JAX-RS
klind Mar 12, 2013 3:45 PM (in response to jaysensharma)Nope.. that didn't help
As I reed the documentation, I shouldn't use the javax.ws.rs.core.Application when using JBoss 7.
-
3. Re: Simple JAX-RS
klind Mar 12, 2013 5:33 PM (in response to klind)Well this worked...
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"> <!-- Default page to serve --> <welcome-file-list> <welcome-file>test.html</welcome-file> </welcome-file-list> </web-app>
@Path("api") @Produces(MediaType.APPLICATION_JSON) public class ProfitMock { @GET @Path("list") @Produces(MediaType.APPLICATION_JSON) public String list() { return "Hello World, I still need some work to be useful!"; } }
@ApplicationPath("/profitmock") public class JaxRsActivator extends Application { }
-
4. Re: Simple JAX-RS
mp911de Mar 13, 2013 4:06 AM (in response to klind)Hi,
RESTeasy does not discover by itself sub-context paths. You've got to set the resteasy.servlet.mapping.prefix parameter. If you don't set the parameter, RESTeasy expects to be mapped at /.
Look here: http://docs.jboss.org/resteasy/docs/2.3.5.Final/userguide/html/Installation_Configuration.html
Best regards, Mark