Hi,
I wrote a simple RESTful service with Jersey, and am able to connect to the
resource endpoints either through curl
"
http://host:port/contextpath/resourcepath"
or using a client when I use maven to run the server/servlet (using mvn
jetty:run). However, When I try to deploy the war file in jetty's webapp
directory and use the same client or curl, I only get 404 responses. When I
curl "
http://host:port/contextpath", I can see the WEB-INF and META-INF
paths, but not able to access anything beyond that. I am trying to
understand why this works when I do mvn jetty:run, but not when I start
jetty with java -jar start.jar. Also what do I need to do to make this work
on a standalone jetty server. I have provided the web.xml, and
context/service.xml file used to deploy in jetty
The following is noticed when I run jetty in debug mode
| +-WebAppContext_at_66b51404@66b51404/testService/services,file:/private/var/folders/zz/zzzivhrRnAmviuee+++++++++++/-Tmp-/Jetty_0_0_0_0_8000_test.war__testService_services__.bqlltp/webapp/,/opt/xcal/jetty/install/jetty-distribution-7.0.2.v20100331/webapps/test.war
started
| | +-SessionHandler_at_3fbfbfb8 started
| | +-ConstraintSecurityHandler_at_4125d61e started
| | +-ServletHandler_at_45c3e9ba started
| | +-null
| | +-[/]=>default
| | +-[*.jsp, *.jspf, *.jspx, *.xsp, *.JSP, *.JSPF, *.JSPX,
*.XSP]=>jsp
| | +-[/services/*]=>Test Service
| | +=roles=[]
| | +=/={TRACE={RoleInfo,F,C[]}}
| +-ContextHandler_at_7a8d0b0f@7a8d0b0f/javadoc,file:/opt/xcal/jetty/install/jetty-distribution-7.0.2.v20100331/javadoc/
started
| +-ResourceHandler_at_11f18cbe started
+-DefaultHandler_at_37eb2c1b started
+-RequestLogHandler_at_309cbd4b started
10-06-15 14:49:32.241:DBUG::REQUEST /testService/services/testpath/ on
org.eclipse.jetty.server.nio.SelectChannelConnector$2_at_2a4bd173
2010-06-15
14:49:32.242:DBUG::sessionManager=org.eclipse.jetty.server.session.HashSessionManager_at_1b0c6cfc
2010-06-15 14:49:32.242:DBUG::session=null
2010-06-15 14:49:32.242:DBUG::servlet=default
2010-06-15 14:49:32.243:DBUG::servlet holder= default
2010-06-15 14:49:32.245:DBUG::chain=
2010-06-15 14:49:32.247:DBUG::Aliased resource:
file:/private/var/folders/zz/zzzivhrRnAmviuee+++++++++++/-Tmp-/Jetty_0_0_0_0_8000_test.war__testService_services__.bqlltp/webapp/test~=file:/private/var/folders/zz/zzzivhrRnAmviuee+++++++++++/-Tmp-/Jetty_0_0_0_0_8000_test.war__testService_services__.bqlltp/webapp/test/
2010-06-15 14:49:32.247:DBUG::RESOURCE /test/=null
2010-06-15 14:49:32.248:DBUG::Aliased resource:
file:/private/var/folders/zz/zzzivhrRnAmviuee+++++++++++/-Tmp-/Jetty_0_0_0_0_8000_test.war__testService_services__.bqlltp/webapp/test~=file:/private/var/folders/zz/zzzivhrRnAmviuee+++++++++++/-Tmp-/Jetty_0_0_0_0_8000_test.war__testService_services__.bqlltp/webapp/test/
2010-06-15 14:49:32.248:DBUG::RESOURCE /test/=null
2010-06-15 14:49:32.248:DBUG::resource=null
2010-06-15 14:49:32.255:DBUG::RESPONSE /testService/services/testpath/ 404
context/service.xml:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "
http://www.eclipse.org/jetty/configure.dtd">
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
<Set name="contextPath">/testService/services</Set>
<Set name="war"><SystemProperty name="jetty.home" default="."
/>/webapps/test.war</Set>
</Configure>
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app 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>testService</display-name>
<servlet>
<servlet-name>Test Service</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
<param-value>com.test.service</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Test Service</servlet-name>
<url-pattern>/services/*</url-pattern>
</servlet-mapping>
</web-app>
TIA