[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] JSP using Java 1.7?

On 11/07/2012 15:16, Joakim Erdfelt wrote:
Look at the example contexts in the distribution.
You'll need to have the following set in your WebAppContext.
<Set name="defaultsDescriptor"><SystemProperty name="jetty.home" default="."/>/etc/webdefault.xml</Set>

Thanks, but I'm still not having much luck here. I didn't have a contexts directory (I only have a single context). I tried creating one, moving my webapp to "/demo", and putting the above in a "demo.xml" file:

  <Configure class="org.eclipse.jetty.webapp.WebAppContext">
    <Set name="contextPath">/demo</Set>
    <Set name="defaultsDescriptor"><SystemProperty
      name="jetty.home" default="."/>/etc/webdefault.xml</Set>

I also tried putting it in jetty-env.xml and jetty-web.xml in the
WEB-INF directory, but that didn't work (picked up too late I
presume?). I seem to be just thrashing around here simply in order
that webdefault.xml will be used as per the documentation. Sorry
if I'm being a bit dumb. I have a configuration that I set up a couple
of years ago by trial and error, and it worked fine until I decided
to try moving to JDK 1.7, and now I find I don't really know how it
all works!

The error message I get is not terribly useful: "use -source 7 or
higher to enable try-with-resources"; I can't find anything about
"-source 7" anywhere in any documentation! And I have no idea how
to find out which XML files are being read or in what order when I
start the server.

My setup is minimal (I don't want to use the whole of the distro,
as most of it I don't need) -- I'm just trying to create a basic
JSP service for a specific app. My lib directory just contains
the jars I seem to need:


My jetty.xml looks like this:

<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd";>

<Configure id="HttpServer" class="org.eclipse.jetty.server.Server">
  <Set name="GracefulShutdown">1000</Set>
  <Set name="StopAtShutdown">true</Set>

<New id="ServerLog" class="java.io.PrintStream">
<New class="org.eclipse.jetty.util.RolloverFileOutputStream">
<Arg><Property name="jetty.logs" default="./logs"/>/yyyy_mm_dd.jetty.log</Arg>
<Arg type="boolean">true</Arg>
<Arg type="int">90</Arg>
<Arg><Call class="java.util.TimeZone" name="getTimeZone"><Arg>GMT</Arg></Call></Arg>
<Get id="ServerLogName" name="datedFilename"/>

<Call class="java.lang.System" name="setErr"><Arg><Ref id="ServerLog"/></Arg></Call>

  <Call name="addConnector">
      <New class="org.eclipse.jetty.server.nio.SelectChannelConnector">
        <Set name="Port">8888</Set>
        <Set name="MaxIdleTime">30000</Set>
        <Set name="Acceptors">2</Set>
        <Set name="AcceptQueueSize">100</Set>

<Call name="setHandler">
<New class="org.eclipse.jetty.webapp.WebAppContext">
<Set name="Descriptor"><Property name="jetty.home" default="." />/webapps/demo/WEB-INF/web.xml</Set>
<Set name="ResourceBase"><Property name="jetty.home" default="." />/webapps/demo</Set>
<Set name="ContextPath">/</Set>
<Set name="Handler">
<New class="org.eclipse.jetty.server.handler.RequestLogHandler">
<Set name="requestLog">
<New class="org.eclipse.jetty.server.NCSARequestLog">
<Set name="filename"><Property name="jetty.logs" default="./logs"/>/yyyy_mm_dd.request.log</Set>
<Set name="filenameDateFormat">yyyy_MM_dd</Set>
<Set name="retainDays">90</Set>
<Set name="append">true</Set>
<Set name="extended">false</Set>
<Set name="logCookies">false</Set>
<Set name="LogTimeZone">GMT</Set>

John English