java - demo jax-rs resource not bound where expected on jboss -


im trying whip small jax-rs demo.

i have resource class:

@path("/cart") public class shoppingcartresource {      @ejb     private shoppingcartservice shoppingcartservice;      @get     public string getcart() {         shoppingcart cart = shoppingcartservice.getcart();         return "cart "+cart.getproducts().size()+" items";     } } 

this class packed inside *.war called rest-1.0-snapshot.war, inside *.ear called ear-1.0-snapshot.ear placed in /deployments directory of jboss 7.1.3

my web.xml empty:

<?xml version="1.0" encoding="utf-8"?> <web-app 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"          version="3.0"> </web-app> 

and application.xml (in ear) auto-generated maven:

<?xml version="1.0" encoding="utf-8"?> <application 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/application_6.xsd" version="6">   <display-name>ear</display-name>   <module>     <ejb>services-impl-1.0-snapshot.jar</ejb>   </module>   <module>     <web>       <web-uri>rest-1.0-snapshot.war</web-uri>       <context-root>/rest</context-root>     </web>   </module>   <library-directory>lib</library-directory> </application> 

when start jboss picking war, evident log:

09:52:19,392 info  [org.jboss.web] (msc service thread 1-4) jbas018210: registering web context: /rest 09:52:19,401 info  [org.jboss.as.server] (serverservice thread pool -- 28) jbas018559: deployed "ear-1.0-snapshot.ear" 

but cant hit resource, no matter url try. i've tried:

  1. localhost:8080/rest/cart
  2. localhost:8080/ear-1.0-snapshot/rest/cart

and keep getting 404. resource bound, or if not bound, doing wrong?

apparently there legal (spec-compliant) way of deploying jax-rs resources without servlet/filter mapping, described in jax-rs docs here (the section says as7 applies java ee 6 compliant as).

the solution have empty web.xml , include application class annotated @applicationpath:

@applicationpath("/root-path") public class myapplication extends application { } 

Comments

Popular posts from this blog

php - mySql Join with 4 tables -

css - Text drops down with smaller window -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -