No hot deployment in Jetty 9.0.6 - jetty

I have set up a Jetty context by a context.xml for using virtual hosts. So my directory structure looks like this:
webapps
--mycontext.xml
--mycontext.war
Now when i upload a new war, no hot deployment occurs any more. It only happens when i modify mycontext.xml. That was not the case when i worked without a mycontext.xml.
Here is the content of mycontext.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd">
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<!-- Required minimal context configuration : -->
<!-- + contextPath -->
<!-- + war OR resourceBase -->
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<Set name="contextPath">/</Set>
<Set name="war"><Property name="jetty.webapps" default="."/>/mycontext.war</Set>
<Set name="virtualHosts">
<Array type="String">
<Item>example.com</Item>
<Item>www.example.com</Item>
<Item>localhost</Item>
<Item>127.0.0.1</Item>
</Array>
</Set>
</Configure>
Any ideas how i regain hot deployment by updating the war file?

You need to put your mycontext.xml in the contexts directory of your server. Also you probably need to enable hot deployment in etc/jetty-deploy.xml for the war files in webapps directory as mentioned here. As you can see the configuration enables the hot deployment
......
<Set name="monitoredDirName"><Property name="jetty.home" default="." />/webapps</Set>
.....
Following is the configuration which is working for me
jetty.home/contextx/mycontext.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd">
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<!-- Required minimal context configuration : -->
<!-- + contextPath -->
<!-- + war OR resourceBase -->
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<Set name="contextPath">/mycontext</Set>
<Set name="war"><SystemProperty name="jetty.home"/>/webapps/mycontext.war</Set>
<Set name="virtualHosts">
<Array type="String">
<Item>example.com</Item>
<Item>www.example.com</Item>
<Item>localhost</Item>
<Item>127.0.0.1</Item>
</Array>
</Set>
</Configure>
Please note how I have supplied the war file name and location
<Set name="war"><SystemProperty name="jetty.home"/>/webapps/mycontext.war</Set>
jetty.home/etc/jetty-deploy.xml
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
<!-- =============================================================== -->
<!-- Create the deployment manager -->
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<!-- The deplyment manager handles the lifecycle of deploying web -->
<!-- applications. Apps are provided by instances of the -->
<!-- AppProvider interface. Typically these are provided by -->
<!-- one or more of: -->
<!-- jetty-webapps.xml - monitors webapps for wars and dirs -->
<!-- jetty-contexts.xml - monitors contexts for context xml -->
<!-- jetty-templates.xml - monitors contexts and templates -->
<!-- =============================================================== -->
<Configure id="Server" class="org.eclipse.jetty.server.Server">
<Call name="addBean">
<Arg>
<New id="DeploymentManager" class="org.eclipse.jetty.deploy.DeploymentManager">
<Set name="contexts">
<Ref id="Contexts" />
</Set>
<Call name="setContextAttribute">
<Arg>org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern</Arg>
<Arg>.*/servlet-api-[^/]*\.jar$</Arg>
</Call>
<Call id="webappprovider" name="addAppProvider">
<Arg>
<New class="org.eclipse.jetty.deploy.providers.WebAppProvider">
<Set name="monitoredDirName"><Property name="jetty.home" default="." />/webapps</Set>
<Set name="defaultsDescriptor"><Property name="jetty.home" default="." />/etc/webdefault.xml</Set>
<Set name="scanInterval">1</Set>
<Set name="extractWars">true</Set>
</New>
</Arg>
</Call>
</New>
</Arg>
</Call>
</Configure>
With this configuration, when I put a modified mycontext.war in webapps, jetty happily
redeploys the war.

Related

reach a webservice on a java angular project deployed on jetty 9.4.12

I have a java angular project that I deploy on jetty 9.4.12
Here is my web.xml file
<?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">
<display-name>Tourism Applicationwith Angular</display-name>
<description>
This is a simple web application with a source code organization
based on the recommendations of the Application Developer's Guide.
</description>
<display-name>Archetype Created Web Application</display-name>
<listener>
<listener-class>org.jboss.weld.environment.servlet.Listener</listener-class>
</listener>
<listener>
<listener-class>
org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap
</listener-class>
</listener>
<resource-env-ref>
<description>Object factory for the CDI Bean Manager</description>
<resource-env-ref-name>BeanManager</resource-env-ref-name>
<resource-env-ref-type>javax.enterprise.inject.spi.BeanManager</resource-env-ref-type>
</resource-env-ref>
<servlet>
<servlet-name>Resteasy</servlet-name>
<servlet-class>
org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher
</servlet-class>
<init-param>
<param-name>javax.ws.rs.Application</param-name>
<param-value>webservice.TourismWebService</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>Resteasy</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
<context-param>
<param-name>resteasy.injector.factory</param-name>
<param-value>org.jboss.resteasy.cdi.CdiInjectorFactory</param-value>
</context-param>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
</web-app>
Here is my web service
package webservice;
import java.util.ArrayList;
import java.util.List;
import javax.inject.Inject;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.Application;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import org.jboss.resteasy.cdi.CdiInjectorFactory;
import org.slf4j.Logger;
import business.TourismBusinessService;
import dto.SearchPathDto;
import dto.TourismPathDto;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
#Path("/tourism")
#Api(value = "analyses", description = "search path by userId, location and max distance")
#Produces(MediaType.APPLICATION_JSON)
#Consumes(MediaType.APPLICATION_JSON)
public class TourismWebService extends Application {
#Inject
private Logger logger;
#Inject
private TourismBusinessService tourismBusinessService;
#GET
#Path("searchPath/{userId}/{longitude}/{latitude}/{distanceMax}")
#ApiOperation("Get analysis by Id")
#ApiResponse(code = 200, message = "OK")
public Response searchPath(#PathParam("userId") long userId,#PathParam("longitude") double longitude,#PathParam("latitude") double latitude,#PathParam("distanceMax") double distanceMax) {
SearchPathDto responseDto = new SearchPathDto();
//org.jboss.resteasy.cdi.CdiInjectorFactory test = new org.jboss.resteasy.cdi.CdiInjectorFactory();
List<TourismPathDto> tourismPathDtoList = new ArrayList<>();
TourismPathDto tourismPathDto1 = new TourismPathDto();
tourismPathDto1.setCategoryId(1);
tourismPathDto1.setDistance((double)100);
tourismPathDto1.setLongitude(2.3313926);
tourismPathDto1.setLatitude(48.873278);
tourismPathDto1.setRoot("root1");
tourismPathDto1.setLeaf("leaf1");
tourismPathDto1.setWeight((double)2);
tourismPathDto1.setMark((double)3);
tourismPathDtoList.add(tourismPathDto1);
TourismPathDto tourismPathDto2 = new TourismPathDto();
tourismPathDto2.setCategoryId(2);
tourismPathDto2.setDistance((double)200);
tourismPathDto2.setLongitude(2.3368291);
tourismPathDto2.setLatitude(48.8747394);
tourismPathDto2.setRoot("root2");
tourismPathDto2.setLeaf("leaf2");
tourismPathDto2.setWeight((double)3);
tourismPathDto2.setMark((double)4);
tourismPathDtoList.add(tourismPathDto2);
responseDto.setDistanceMax(distanceMax);
responseDto.setLatitude(latitude);
responseDto.setLongitude(longitude);
responseDto.setUserId(userId);
responseDto.setTourismPathDtoList(tourismPathDtoList);
//SearchPathDto responseDto = tourismBusinessService.getTourismPathList(userId, longitude, latitude, distanceMax);
if (responseDto == null)
throw new WebApplicationException(Response.Status.NOT_FOUND);
return Response.ok(responseDto).build();
}
}
I ran jetty : java -jar start.jar
But when I try to reach the following web service
http://localhost:8080/tourism-services/tourism/searchPath/1/2.3313926/48.873278/200
I have a
HTTP ERROR 404
Problem accessing /tourism-services/tourism/searchPath/1/2.3313926/48.873278/200. Reason:
Not Found
error
Thank you for your help
Here is the continuation......
the jetty.xml that I modified is the following
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_3.dtd">
<!-- =============================================================== -->
<!-- Documentation of this file format can be found at: -->
<!-- https://www.eclipse.org/jetty/documentation/current/ -->
<!-- -->
<!-- Additional configuration files are available in $JETTY_HOME/etc -->
<!-- and can be mixed in. See start.ini file for the default -->
<!-- configuration files. -->
<!-- -->
<!-- For a description of the configuration mechanism, see the -->
<!-- output of: -->
<!-- java -jar start.jar -? -->
<!-- =============================================================== -->
<!-- =============================================================== -->
<!-- Configure a Jetty Server instance with an ID "Server" -->
<!-- Other configuration files may also configure the "Server" -->
<!-- ID, in which case they are adding configuration to the same -->
<!-- instance. If other configuration have a different ID, they -->
<!-- will create and configure another instance of Jetty. -->
<!-- Consult the javadoc of o.e.j.server.Server for all -->
<!-- configuration that may be set here. -->
<!-- =============================================================== -->
<Configure id="Server" class="org.eclipse.jetty.server.Server">
<Arg name="threadpool"><Ref refid="threadPool"/></Arg>
<!-- =========================================================== -->
<!-- Add shared Scheduler instance -->
<!-- =========================================================== -->
<Call name="addBean">
<Arg>
<New class="org.eclipse.jetty.util.thread.ScheduledExecutorScheduler"/>
</Arg>
</Call>
<Ref refid="DeploymentManager">
<Call name="addLifeCycleBinding">
<Arg>
<New
class="org.eclipse.jetty.cdi.servlet.WeldDeploymentBinding">
</New>
</Arg>
</Call>
</Ref>
<!-- =========================================================== -->
<!-- Http Configuration. -->
<!-- This is a common configuration instance used by all -->
<!-- connectors that can carry HTTP semantics (HTTP, HTTPS, etc.)-->
<!-- It configures the non wire protocol aspects of the HTTP -->
<!-- semantic. -->
<!-- -->
<!-- This configuration is only defined here and is used by -->
<!-- reference from other XML files such as jetty-http.xml, -->
<!-- jetty-https.xml and other configuration files which -->
<!-- instantiate the connectors. -->
<!-- -->
<!-- Consult the javadoc of o.e.j.server.HttpConfiguration -->
<!-- for all configuration that may be set here. -->
<!-- =========================================================== -->
<New id="httpConfig" class="org.eclipse.jetty.server.HttpConfiguration">
<Set name="secureScheme"><Property name="jetty.httpConfig.secureScheme" default="https" /></Set>
<Set name="securePort"><Property name="jetty.httpConfig.securePort" deprecated="jetty.secure.port" default="8443" /></Set>
<Set name="outputBufferSize"><Property name="jetty.httpConfig.outputBufferSize" deprecated="jetty.output.buffer.size" default="32768" /></Set>
<Set name="outputAggregationSize"><Property name="jetty.httpConfig.outputAggregationSize" deprecated="jetty.output.aggregation.size" default="8192" /></Set>
<Set name="requestHeaderSize"><Property name="jetty.httpConfig.requestHeaderSize" deprecated="jetty.request.header.size" default="8192" /></Set>
<Set name="responseHeaderSize"><Property name="jetty.httpConfig.responseHeaderSize" deprecated="jetty.response.header.size" default="8192" /></Set>
<Set name="sendServerVersion"><Property name="jetty.httpConfig.sendServerVersion" deprecated="jetty.send.server.version" default="true" /></Set>
<Set name="sendDateHeader"><Property name="jetty.httpConfig.sendDateHeader" deprecated="jetty.send.date.header" default="false" /></Set>
<Set name="headerCacheSize"><Property name="jetty.httpConfig.headerCacheSize" default="4096" /></Set>
<Set name="delayDispatchUntilContent"><Property name="jetty.httpConfig.delayDispatchUntilContent" deprecated="jetty.delayDispatchUntilContent" default="true"/></Set>
<Set name="maxErrorDispatches"><Property name="jetty.httpConfig.maxErrorDispatches" default="10"/></Set>
<Set name="blockingTimeout"><Property deprecated="jetty.httpConfig.blockingTimeout" name="jetty.httpConfig.blockingTimeout.DEPRECATED" default="-1"/></Set>
<Set name="persistentConnectionsEnabled"><Property name="jetty.httpConfig.persistentConnectionsEnabled" default="true"/></Set>
<Set name="cookieCompliance"><Call class="org.eclipse.jetty.http.CookieCompliance" name="valueOf"><Arg><Property name="jetty.httpConfig.cookieCompliance" default="RFC6265"/></Arg></Call></Set>
<Set name="multiPartFormDataCompliance"><Call class="org.eclipse.jetty.server.MultiPartFormDataCompliance" name="valueOf"><Arg><Property name="jetty.httpConfig.multiPartFormDataCompliance" default="RFC7578"/></Arg></Call></Set>
</New>
<!-- =========================================================== -->
<!-- Set the default handler structure for the Server -->
<!-- A handler collection is used to pass received requests to -->
<!-- both the ContextHandlerCollection, which selects the next -->
<!-- handler by context path and virtual host, and the -->
<!-- DefaultHandler, which handles any requests not handled by -->
<!-- the context handlers. -->
<!-- Other handlers may be added to the "Handlers" collection, -->
<!-- for example the jetty-requestlog.xml file adds the -->
<!-- RequestLogHandler after the default handler -->
<!-- =========================================================== -->
<Set name="handler">
<New id="Handlers" class="org.eclipse.jetty.server.handler.HandlerCollection">
<Set name="handlers">
<Array type="org.eclipse.jetty.server.Handler">
<Item>
<New id="Contexts" class="org.eclipse.jetty.server.handler.ContextHandlerCollection"/>
</Item>
<Item>
<New id="DefaultHandler" class="org.eclipse.jetty.server.handler.DefaultHandler"/>
</Item>
</Array>
</Set>
</New>
</Set>
<!-- =========================================================== -->
<!-- extra server options -->
<!-- =========================================================== -->
<Set name="stopAtShutdown"><Property name="jetty.server.stopAtShutdown" default="true"/></Set>
<Set name="stopTimeout"><Property name="jetty.server.stopTimeout" default="5000"/></Set>
<Set name="dumpAfterStart"><Property name="jetty.server.dumpAfterStart" deprecated="jetty.dump.start" default="false"/></Set>
<Set name="dumpBeforeStop"><Property name="jetty.server.dumpBeforeStop" deprecated="jetty.dump.stop" default="false"/></Set>
</Configure>
In this file, I added the following
<Ref refid="DeploymentManager">
<Call name="addLifeCycleBinding">
<Arg>
<New
class="org.eclipse.jetty.cdi.servlet.WeldDeploymentBinding">
</New>
</Arg>
</Call>
and I added this dependency to maven
<dependency>
<groupId>org.eclipse.jetty.cdi</groupId>
<artifactId>cdi-servlet</artifactId>
<version>9.4.12.v20180830</version>
</dependency>
But I got this error
MBP-de-Admin:jetty-distribution-9.4.12.v20180830 admin$ java -jar start.jar
2019-02-06 07:49:05.745:INFO::main: Logging initialized #841ms to org.eclipse.jetty.util.log.StdErrLog
2019-02-06 07:49:05.912:WARN:oejx.XmlConfiguration:main: Config error at <Ref refid="DeploymentManager"><Call name="addLifeCycleBinding"><Arg>| <New class="org.eclipse.jetty.cdi.servlet.WeldDeploymentBinding"/>| </Arg></Call></Ref> java.lang.IllegalStateException: No object for refid=DeploymentManager in file:/Users/admin/Application-Marwen/Jetty/jetty-distribution-9.4.12.v20180830/etc/jetty.xml
2019-02-06 07:49:05.913:WARN:oejx.XmlConfiguration:main:
java.lang.IllegalStateException: No object for refid=DeploymentManager
at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.refObj(XmlConfiguration.java:891)
at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.configure(XmlConfiguration.java:487)
at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.configure(XmlConfiguration.java:413)
at org.eclipse.jetty.xml.XmlConfiguration.configure(XmlConfiguration.java:311)
at org.eclipse.jetty.xml.XmlConfiguration$1.run(XmlConfiguration.java:1558)
at org.eclipse.jetty.xml.XmlConfiguration$1.run(XmlConfiguration.java:1512)

Unable to load Context Configuration by IoC XML inside WAR by jetty-9

I am trying to load my webcontext using jetty IoC.
My war name git.ctr-0.0.1-SNAPSHOT.war
My Jetty IoC xml file name ,
jetty-web.xml which is placed inside git.ctr-0.0.1-SNAPSHOT/WEB-INF/
As per document of jetty is says IoC file placed inside war file can be scanned by jetty-deployer and war can be deployed using XML .
Link http://www.eclipse.org/jetty/documentation/current/quickstart-config-what.html
My Ioc XML,
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd">
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
<Set name="war"><SystemProperty name="jetty.home" default="."/>/webapps/git.ctr-0.0.1-SNAPSHOT.war</Set>
<Set name="contextPath">/git</Set>
<Get name="securityHandler">
<!-- Either: -->
<Set name="loginService">
<New class="matrix.git.ctr.MyLoginService">
<Set name="name">matrix-aa</Set>
<Set name="idpUrl">https://10.100.20.83:8091</Set>
</New>
</Set>
<!-- or if you defined a LoginService called "Test Realm" in jetty.xml : -->
<Set name="realmName">matrix-aa</Set>
</Get>
</Configure>
Please suggest how can this configuration loaded by jetty.

How to get Jetty in Karaf to serve static content from file system?

I need to serve static content from outside a bundle in Karaf. Since it already has Pax Web and Jetty built in, I've thought it wouldn't be a problem, but no success so far :(
I have jetty, http, http-whiteboard and war features installed. Following http://team.ops4j.org/wiki/display/paxweb/Advanced+Jetty+Configuration, I've added this to etc/jetty.xml:
<Get name="handler">
<Call name="addHandler">
<Arg>
<New class="org.eclipse.jetty.servlet.ServletContextHandler">
<Set name="contextPath">/app</Set>
<Set name="resourceBase">/home/aromanov/workspaces/odp-server/ru.focusmedia.odp.server.poim.resources-rodniki/
</Set>
<Call name="addServlet">
<Arg>org.eclipse.jetty.servlet.DefaultServlet</Arg>
<Arg>/</Arg>
</Call>
</New>
</Arg>
</Call>
</Get>
The complete file is:
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//
DTD Configure//EN" "http://jetty.mortbay.org/configure.dtd">
<Configure class="org.eclipse.jetty.server.Server">
<!-- =========================================================== -->
<!-- Set connectors -->
<!-- =========================================================== -->
<!-- One of each type! -->
<!-- =========================================================== -->
<!-- Use this connector for many frequently idle connections and for threadless
continuations. -->
<Call name="addConnector">
<Arg>
<New class="org.eclipse.jetty.server.nio.SelectChannelConnector">
<Set name="host">
<Property name="jetty.host" default="0.0.0.0" />
</Set>
<Set name="port">
<Property name="jetty.port" default="8282" />
</Set>
<Set name="maxIdleTime">300000</Set>
<Set name="Acceptors">2</Set>
<Set name="statsOn">false</Set>
<Set name="confidentialPort">8443</Set>
<Set name="lowResourcesConnections">20000</Set>
<Set name="lowResourcesMaxIdleTime">5000</Set>
</New>
</Arg>
</Call>
<!-- =========================================================== -->
<!-- Configure Authentication Realms -->
<!-- Realms may be configured for the entire server here, or -->
<!-- they can be configured for a specific web app in a context -->
<!-- configuration (see $(jetty.home)/contexts/test.xml for an -->
<!-- example). -->
<!-- =========================================================== -->
<Call name="addBean">
<Arg>
<New class="org.eclipse.jetty.plus.jaas.JAASLoginService">
<Set name="name">karaf</Set>
<Set name="loginModuleName">karaf</Set>
<Set name="roleClassNames">
<Array type="java.lang.String">
<Item>org.apache.karaf.jaas.modules.RolePrincipal</Item>
</Array>
</Set>
</New>
</Arg>
</Call>
<Call name="addBean">
<Arg>
<New class="org.eclipse.jetty.plus.jaas.JAASLoginService">
<Set name="name">default</Set>
<Set name="loginModuleName">karaf</Set>
<Set name="roleClassNames">
<Array type="java.lang.String">
<Item>org.apache.karaf.jaas.modules.RolePrincipal</Item>
</Array>
</Set>
</New>
</Arg>
</Call>
<Get name="handler">
<Call name="addHandler">
<Arg>
<New class="org.eclipse.jetty.servlet.ServletContextHandler">
<Set name="contextPath">/app</Set>
<Set name="resourceBase">/home/aromanov/workspaces/odp-server/ru.focusmedia.odp.server.poim.resources-rodniki
</Set>
<Call name="addServlet">
<Arg>org.eclipse.jetty.servlet.DefaultServlet</Arg>
<Arg>/</Arg>
</Call>
</New>
</Arg>
</Call>
</Get>
</Configure>
And created the file org.ops4j.pax.web.cfg with this content:
org.ops4j.pax.web.config.file=/home/aromanov/workspaces/odp-server/ru.focusmedia.odp.server.karaf.launcher/etc/jetty.xml
In the log I see
2012-06-02 12:03:52,800 | INFO | g.ops4j.pax.web) | Server | - - | jetty-7.5.4.v20111024
2012-06-02 12:03:52,848 | INFO | g.ops4j.pax.web) | ContextHandler | - - | started o.e.j.s.ServletContextHandler{/app,file:/home/aromanov/workspaces/odp-server/ru.focusmedia.odp.server.poim.resources-rodniki/}
2012-06-02 12:03:52,907 | INFO | g.ops4j.pax.web) | AbstractConnector | - - | Started SelectChannelConnector#0.0.0.0:8282 STARTING
2012-06-02 12:03:52,914 | INFO | g.ops4j.pax.web) | JettyServerImpl | 124 - org.ops4j.pax.web.pax-web-jetty - 1.0.9 | Pax Web available at [0.0.0.0]:[8080]
2012-06-02 12:03:52,927 | INFO | g.ops4j.pax.web) | AbstractConnector | - - | Started NIOSocketConnectorWrapper#0.0.0.0:8080 STARTING
But the files aren't visible. E.g., I have a file /home/aromanov/workspaces/odp-server/ru.focusmedia.odp.server.poim.resources-rodniki/.style, but going to either http://192.168.1.9:8080/app/.style or http://192.168.1.9:8282/app/.style gives 404 error.
A bit late, perhaps, but..
Doing the same thing worked well for me, i.e. i copied the code snippet from http://team.ops4j.org/wiki/display/paxweb/Advanced+Jetty+Configuration and changed the two paths. I restarted karaf and my files were served.
Are you running karaf as a user that has access to /home/aromanov?

My Jetty server will dead after a long time, why?

Recently, I host a website in Amazon EC2, and I use Jetty 7.4 as my server.
I test it in my machine and EC2, and it works properly.
But after a few weeks, it suddenly can't be accessed. Checking the log, it just said "/WEB-INF/view/index.jsp" not found. And then the whole site can't be used any more until restarting the Jetty server.
BTW: in my project I used Spring Framework, Spring MVC, Ehcache, Shiro, Hibernate, Google Web Toolkit, etc.
Why?
I almost use the default configuration file for Jetty:
Jetty configuration file:
<!-- =========================================================== -->
<!-- Server Thread Pool -->
<!-- =========================================================== -->
<Set name="ThreadPool">
<!-- Default queued blocking threadpool -->
<New class="org.eclipse.jetty.util.thread.QueuedThreadPool">
<Set name="minThreads">10</Set>
<Set name="maxThreads">200</Set>
<Set name="detailedDump">false</Set>
</New>
</Set>
<!-- =========================================================== -->
<!-- Set connectors -->
<!-- =========================================================== -->
<Call name="addConnector">
<Arg>
<New class="org.eclipse.jetty.server.nio.SelectChannelConnector">
<Set name="host"><Property name="jetty.host" /></Set>
<Set name="port"><Property name="jetty.port" default="8080"/></Set>
<Set name="maxIdleTime">300000</Set>
<Set name="Acceptors">2</Set>
<Set name="statsOn">false</Set>
<Set name="confidentialPort">8443</Set>
<Set name="lowResourcesConnections">20000</Set>
<Set name="lowResourcesMaxIdleTime">5000</Set>
</New>
</Arg>
</Call>
<!-- =========================================================== -->
<!-- Set handler Collection Structure -->
<!-- =========================================================== -->
<Set name="handler">
<New id="Handlers" class="org.eclipse.jetty.server.handler.HandlerCollection">
<Set name="handlers">
<Array type="org.eclipse.jetty.server.Handler">
<Item>
<New id="Contexts" class="org.eclipse.jetty.server.handler.ContextHandlerCollection"/>
</Item>
<Item>
<New id="DefaultHandler" class="org.eclipse.jetty.server.handler.DefaultHandler"/>
</Item>
</Array>
</Set>
</New>
</Set>
<New id="ServerLog" class="java.io.PrintStream">
<Arg>
<New class="org.eclipse.jetty.util.RolloverFileOutputStream">
<Arg><Property name="jetty.logs" default="./logs"/>/yyyy_mm_dd.stderrout.log</Arg>
<Arg type="boolean">false</Arg>
<Arg type="int">90</Arg>
<Arg><Call class="java.util.TimeZone" name="getTimeZone"><Arg>GMT</Arg></Call></Arg>
<Get id="ServerLogName" name="datedFilename"/>
</New>
</Arg>
</New>
<Call class="org.eclipse.jetty.util.log.Log" name="info"><Arg>Redirecting stderr/stdout to <Ref id="ServerLogName"/></Arg></Call>
<Call class="java.lang.System" name="setErr"><Arg><Ref id="ServerLog"/></Arg></Call>
<Call class="java.lang.System" name="setOut"><Arg><Ref id="ServerLog"/></Arg></Call>
<!-- =========================================================== -->
<!-- extra options -->
<!-- =========================================================== -->
<Set name="stopAtShutdown">true</Set>
<Set name="sendServerVersion">true</Set>
<Set name="sendDateHeader">true</Set>
<Set name="gracefulShutdown">1000</Set>
<Set name="dumpAfterStart">false</Set>
<Set name="dumpBeforeStop">false</Set>
Error details:
org.apache.jasper.JasperException: PWC6117: File "/WEB-INF/view/index.jsp" not found
at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:89)
at org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:375)
at org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:169)
at org.apache.jasper.compiler.JspUtil.getInputStream(JspUtil.java:910)
at org.apache.jasper.xmlparser.XMLEncodingDetector.getEncoding(XMLEncodingDetector.java:143)
at org.apache.jasper.compiler.ParserController.determineSyntaxAndEncoding(ParserController.java:376)
at org.apache.jasper.compiler.ParserController.doParse(ParserController.java:210)
at org.apache.jasper.compiler.ParserController.parse(ParserController.java:140)
at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:199)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:435)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:608)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:360)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:486)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:380)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:538)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:478)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:119)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:517)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:225)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:937)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:406)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:183)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:871)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117)
at org.eclipse.jetty.server.Dispatcher.forward(Dispatcher.java:284)
at org.eclipse.jetty.server.Dispatcher.forward(Dispatcher.java:115)
at org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:238)
at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:250)
at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1047)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:817)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:549)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:538)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1352)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1323)
at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1323)
at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:359)
at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:275)
at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)
at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)
at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:344)
at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:272)
at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:81)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1323)
at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:359)
at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:275)
at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)
at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)
at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:344)
at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:272)
at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:81)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1323)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:476)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:119)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:480)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:225)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:937)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:406)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:183)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:871)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117)
at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:247)
at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:149)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:110)
at org.eclipse.jetty.server.Server.handle(Server.java:346)
at org.eclipse.jetty.server.HttpConnection.handleRequest(HttpConnection.java:589)
at org.eclipse.jetty.server.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:1048)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:601)
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:214)
at org.eclipse.jetty.server.HttpConnection.handle(HttpConnection.java:411)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:535)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:40)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:529)
at java.lang.Thread.run(Thread.java:636)
Run
bin/jetty.sh check
You may find
-Djava.io.tmpdir=/tmp
Change it to some other folder since the OS will delete files in /tmp after a period of time.
Why is your index.jsp in WEB-INF? That folder is made for classes, JAR files, web server files, etc. Your JSP page should just not be there at all.
See JSP do not work in Embedded Jetty.
Review you web.xml and other configuration files.

How to prevent Jetty from showing context related information

I am using Jetty to deploy a production website. Let's assume my website is foo.com When I point my browser to a context which does not exist (say foo.com/notavailable), Jetty shows an error page with information of all the contexts which are deployed on it.
It looks something like this:
No context on this server matched or handled this request.
Contexts known to this server are:
/test ---> org.mortbay.jetty.webapp.WebAppContext#6910fe28{/test,/root/webserver/jetty-6.1.4/webapps/test}
I want to prevent Jetty from showing this message because it contains the full path to the context on the server.
Is there a way to do this?
When configuring Jetty XML you can set showContexts to false on the DefaultHandler.
If you are using older Jetty versions replace org.eclipse.jetty on my example with the old org.mortbay.jetty package structure.
<Configure id="Server" class="org.eclipse.jetty.server.Server">
<!-- =========================================================== -->
<!-- Set handler Collection Structure -->
<!-- =========================================================== -->
<Set name="handler">
<!-- the collection of handlers that will handle the request -->
<New id="Handlers" class="org.eclipse.jetty.server.handler.HandlerCollection">
<Set name="handlers">
<Array type="org.eclipse.jetty.server.Handler">
<!-- primarily handles the request and maps the request to a ContextHandler -->
<Item>
<New id="Contexts" class="org.eclipse.jetty.server.handler.ContextHandlerCollection"/>
</Item>
<!-- The default handler ... handles the request if not yet handled -->
<Item>
<New id="DefaultHandler" class="org.eclipse.jetty.server.handler.DefaultHandler"/>
</Item>
<!-- The handler for your request logs -->
<Item>
<New id="RequestLog" class="org.eclipse.jetty.server.handler.RequestLogHandler"/>
</Item>
</Array>
</Set>
</New>
</Set>
<!-- ===================== -->
<!-- DefaultHandler config -->
<!-- ===================== -->
<Ref id="DefaultHandler">
<Set name="showContexts">false</Set>
</Ref>
</Configure>
Maybe you'll also be wanting to prevent directory browsing configuring the DefaultServlet of your web.xml,
<servlet>
<servlet-name>default</servlet-name>
<servlet-class>org.eclipse.jetty.servlet.DefaultServlet</servlet-class>
<init-param>
<param-name>dirAllowed</param-name>
<param-value>false</param-value>
</init-param>
<load-on-startup>0</load-on-startup>
</servlet>
That page is provided by the Jetty "DefaultHandler"
http://svn.codehaus.org/jetty/jetty/branches/jetty-6.1/modules/jetty/src/main/java/org/mortbay/jetty/handler/DefaultHandler.java
To stop that page from displaying, you should remove that handler from your server (it's configured in your jetty.xml file)
You don't really need (or want) the default handler on a production (internet facing) server, so it's a good idea to remove it.
Note, that it also provides the regular 404 page, and the favicon.ico so if you're relying on those behaviours then you'll need to put in a replacement.
Jetty 9.X version has come up with showContexts property in org.eclipse.jetty.servlet.DefaultServlet class. Hence we can set the showContexts to flase, if you do not want to show the contexts list.
<Item>
<New id="DefaultHandler" class="org.eclipse.jetty.server.handler.DefaultHandler">
<Set name="showContexts">false</Set>
</New>
</Item>