Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] Can't control classpath scanning with jetty-maven-plugin

Hi Paul,

You can specify the 'webInfIncludeJarPattern' configuration parameter to the jetty-maven-plugin to control which jars from the webapp are scanned for annotations. See https://www.eclipse.org/jetty/documentation/9.3.x/jetty-maven-plugin.html#configuring-your-webapp

Jan

On 24 March 2017 at 07:55, Paul Houle <paul.houle@xxxxxxxxxxxxx> wrote:
I am working on an app that I am running with the jetty-maven-plugin.
The app would start up OK before I added the dependency

    <dependency>
      <groupId>org.mapdb</groupId>
      <artifactId>mapdb</artifactId>
      <version>3.0.3</version>
    </dependency>

but when I add that,  loading fails with the following message:

[INFO] jetty-9.3.11.v20160721
[INFO] Scanning elapsed time=62414ms
[WARNING] Failed startup of context
o.e.j.m.p.JettyWebAppContext@21d1b321{/,file:///C:/Users/paul_000/Documents/GitHub/d
efinancialization/wikidata-schema-browser/src/main/webapp/,UNAVAILABLE{file:///C:/Users/paul_000/Documents/GitHub/definancialization/wikidata-schema-browser/src/main/webapp/}
java.lang.Exception: Timeout scanning annotations
        at
        org.eclipse.jetty.annotations.AnnotationConfiguration.scanForAnnotations(AnnotationConfiguration.java:578)

I have spent some time looking at the docs and trying a few different
things,  but I have not been able to get it to work.  Any idea of how I
can fix this?  Following find the (1) plugin configuration in the POM,
and (2) the associated jetty.xml file:

      <plugin>
        <groupId>org.eclipse.jetty</groupId>
        <artifactId>jetty-maven-plugin</artifactId>
        <version>9.3.11.v20160721</version>
        <configuration>
          <jettyXml>src/main/etc/jetty.xml</jettyXml>
          <webApp>
            <contextPath>/</contextPath>
            <defaultsDescriptor>src/main/etc/webdefault.xml</defaultsDescriptor>
          </webApp>
          <stopKey>come-and-get-it</stopKey>
          <stopPort>27891</stopPort>
          <jettyXml>src/main/etc/jetty.xml</jettyXml>
        </configuration>
        <dependencies>
          <dependency>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-deploy</artifactId>
            <version>9.3.11.v20160721</version>
          </dependency>
        </dependencies>
      </plugin>

------------------------------------------------------------------------------------------

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

<!-- =============================================================== -->
<!-- Documentation of this file format can be found at:              -->
<!-- http://wiki.eclipse.org/Jetty/Reference/jetty.xml_syntax        -->
<!--                                                                 -->
<!-- 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">

  <!-- =========================================================== -->
  <!-- Configure the Server Thread Pool.                           -->
  <!-- The server holds a common thread pool which is used by      -->
  <!-- default as the executor used by all connectors and servlet  -->
  <!-- dispatches.                                                 -->
  <!--                                                             -->
  <!-- Configuring a fixed thread pool is vital to controlling the -->
  <!-- maximal memory footprint of the server and is a key tuning  -->
  <!-- parameter for tuning.  In an application that rarely blocks -->
  <!-- then maximal threads may be close to the number of 5*CPUs.  -->
  <!-- In an application that frequently blocks, then maximal      -->
  <!-- threads should be set as high as possible given the memory  -->
  <!-- available.                                                  -->
  <!--                                                             -->
  <!-- Consult the javadoc of o.e.j.util.thread.QueuedThreadPool   -->
  <!-- for all configuration that may be set here.                 -->
  <!-- =========================================================== -->
  <!-- uncomment to change type of threadpool
  <Arg name="threadpool"><New id="threadpool"
  class="org.eclipse.jetty.util.thread.QueuedThreadPool"/></Arg>
  -->
  <Get name="ThreadPool">
    <Set name="minThreads" type="int">
      <Property name="threads.min" default="10"/>
    </Set>
    <Set name="maxThreads" type="int">
      <Property name="threads.max" default="200"/>
    </Set>
    <Set name="idleTimeout" type="int">
      <Property name="threads.timeout" default="60000"/>
    </Set>
    <Set name="detailedDump">false</Set>
  </Get>

  <!-- =========================================================== -->
  <!-- Add shared Scheduler instance                               -->
  <!-- =========================================================== -->
  <Call name="addBean">
    <Arg>
      <New
      class="org.eclipse.jetty.util.thread.ScheduledExecutorScheduler"/>
    </Arg>
  </Call>

  <!-- =========================================================== -->
  <!-- Http Configuration.                                         -->
  <!-- This is a common configuration instance used by all         -->
  <!-- connectors that can carry HTTP semantics (HTTP, HTTPS, SPDY)-->
  <!-- It configures the non wire protocol aspects of the HTTP     -->
  <!-- semantic.                                                   -->
  <!--                                                             -->
  <!-- This configuration is only defined here and is used by      -->
  <!-- reference from the jetty-http.xml, jetty-https.xml and      -->
  <!-- jetty-spdy.xml 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">https</Set>
    <Set name="securePort">
      <Property name="jetty.secure.port" default="8443"/>
    </Set>
    <Set name="outputBufferSize">
      <Property name="jetty.output.buffer.size" default="32768"/>
    </Set>
    <Set name="requestHeaderSize">
      <Property name="jetty.request.header.size" default="8192"/>
    </Set>
    <Set name="responseHeaderSize">
      <Property name="jetty.response.header.size" default="8192"/>
    </Set>
    <Set name="sendServerVersion">
      <Property name="jetty.send.server.version" default="true"/>
    </Set>
    <Set name="sendDateHeader">
      <Property name="jetty.send.date.header" default="false"/>
    </Set>
    <Set name="headerCacheSize">512</Set>
    <!-- Uncomment to enable handling of X-Forwarded- style headers
    <Call name="addCustomizer">
      <Arg><New
      class="org.eclipse.jetty.server.ForwardedRequestCustomizer"/></Arg>
    </Call>
    -->
  </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">true</Set>
  <Set name="stopTimeout">5000</Set>
  <Set name="dumpAfterStart">
    <Property name="jetty.dump.start" default="false"/>
  </Set>
  <Set name="dumpBeforeStop">
    <Property name="jetty.dump.stop" default="false"/>
  </Set>
  <Call name="addBean">
    <Arg>
      <New id="DeploymentManager"
      class="org.eclipse.jetty.deploy.DeploymentManager">
        <Set name="contexts">
          <Ref refid="Contexts"/>
        </Set>
        <Call name="setContextAttribute">
          <Arg>org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern</Arg>
          <Arg>
            .*/[^/]*servlet-api-[^/]*\.jar$|.*/javax.servlet.jsp.jstl-.*\.jar$|.*/org.apache.taglibs.taglibs-standard-impl-.*\.jar$
          </Arg>
        </Call>
        <Call name="setContextAttribute">
          <Arg>org.eclipse.jetty.server.webapp.WebInfIncludeJarPattern</Arg>
          <Arg>.*/spring-security[^/]*\.jar$|.*/spring-web[^/]*\.jar$|.*/classes/.*</Arg>
        </Call>
        <Call id="webappprovider" name="addAppProvider">
          <Arg>
            <New
            class="org.eclipse.jetty.deploy.providers.WebAppProvider">
              <Set name="monitoredDirName"><Property name="jetty.base"
              default="."/>/<Property
              name="jetty.deploy.monitoredDirName" 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>
              <Set name="configurationManager">
                <New
                class="org.eclipse.jetty.deploy.PropertiesConfigurationManager">
                </New>
              </Set>
            </New>
          </Arg>
        </Call>
      </New>
    </Arg>
  </Call>
</Configure>


--
  Paul Houle
  paul.houle@xxxxxxxxxxxxx
_______________________________________________
jetty-users mailing list
jetty-users@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users



--
Jan Bartel <janb@xxxxxxxxxxx>
www.webtide.com
Expert assistance from the creators of Jetty and CometD


Back to the top