| <html><head> |
| <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> |
| <title>Configuring WebAppContexts</title><link rel="stylesheet" type="text/css" href="css/docbook.css"><meta name="generator" content="DocBook XSL-NS Stylesheets V1.76.1"><meta name="keywords" content="jetty, servlet-api, cometd, http, spdy, eclipse, maven, java, software"><link rel="home" href="index.html" title="Jetty : The Definitive Reference"><link rel="up" href="configuring-contexts.html" title="Chapter 5. Configuring Contexts"><link rel="prev" href="configuring-virtual-hosts.html" title="Configuring Virtual Hosts"><link rel="next" href="serving-webapp-from-particular-port.html" title="Serving a WebApp from a Particular Port/Connector"><link xmlns:jfetch="java:org.eclipse.jetty.xslt.tools.JavaSourceFetchExtension" xmlns:fetch="java:org.eclipse.jetty.xslt.tools.SourceFetchExtension" xmlns:d="http://docbook.org/ns/docbook" xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0" xmlns:xslthl="http://xslthl.sf.net" xmlns:gcse="http://www.google.com" xmlns:date="http://exslt.org/dates-and-times" rel="shortcut icon" href="images/favicon.ico"><script type="text/javascript" src="js/shCore.js"></script><script type="text/javascript" src="js/shBrushJava.js"></script><script type="text/javascript" src="js/shBrushXml.js"></script><script type="text/javascript" src="js/shBrushBash.js"></script><script type="text/javascript" src="js/shBrushJScript.js"></script><script type="text/javascript" src="js/shBrushSql.js"></script><script type="text/javascript" src="js/shBrushProperties.js"></script><script type="text/javascript" src="js/shBrushPlain.js"></script><link type="text/css" rel="stylesheet" href="css/shCore.css"><link type="text/css" rel="stylesheet" href="css/shThemeEclipse.css"><link type="text/css" rel="stylesheet" href="css/font-awesome.min.css"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><table xmlns:jfetch="java:org.eclipse.jetty.xslt.tools.JavaSourceFetchExtension" xmlns:fetch="java:org.eclipse.jetty.xslt.tools.SourceFetchExtension" xmlns:d="http://docbook.org/ns/docbook" xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0" xmlns:xslthl="http://xslthl.sf.net" xmlns:gcse="http://www.google.com" xmlns:date="http://exslt.org/dates-and-times"><tr><td style="width: 25%"><a href="http://www.eclipse.org/jetty"><img src="images/jetty-header-logo.png" alt="Jetty Logo"></a><br><span style="font-size: small"> |
| Version: 9.0.6.v20130930</span></td><td style="width: 50%"><script type="text/javascript"> (function() { |
| var cx = '016459005284625897022:obd4lsai2ds'; |
| var gcse = document.createElement('script'); |
| gcse.type = 'text/javascript'; |
| gcse.async = true; |
| gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + |
| '//www.google.com/cse/cse.js?cx=' + cx; |
| var s = document.getElementsByTagName('script')[0]; |
| s.parentNode.insertBefore(gcse, s); |
| })(); |
| </script><gcse:search></gcse:search></td></tr></table><div xmlns:jfetch="java:org.eclipse.jetty.xslt.tools.JavaSourceFetchExtension" xmlns:fetch="java:org.eclipse.jetty.xslt.tools.SourceFetchExtension" xmlns:d="http://docbook.org/ns/docbook" xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0" xmlns:xslthl="http://xslthl.sf.net" xmlns:gcse="http://www.google.com" xmlns:date="http://exslt.org/dates-and-times" class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Configuring WebAppContexts</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="configuring-virtual-hosts.html"><i class="icon-chevron-left"></i> Previous</a> </td><th width="60%" align="center">Chapter 5. Configuring Contexts<br><a accesskey="p" href="index.html"><i class="icon-home"></i> Home</a></th><td width="20%" align="right"> <a accesskey="n" href="serving-webapp-from-particular-port.html">Next <i class="icon-chevron-right"></i></a></td></tr></table><hr></div><div xmlns:jfetch="java:org.eclipse.jetty.xslt.tools.JavaSourceFetchExtension" xmlns:fetch="java:org.eclipse.jetty.xslt.tools.SourceFetchExtension" xmlns:d="http://docbook.org/ns/docbook" xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0" xmlns:xslthl="http://xslthl.sf.net" xmlns:gcse="http://www.google.com" xmlns:date="http://exslt.org/dates-and-times" class="jetty-callout"><h5 class="callout"><a href="http://www.webtide.com/support.jsp">Contact the core Jetty developers at |
| <span class="website">www.webtide.com</span></a></h5><p> |
| private support for your internal/customer projects ... custom extensions and distributions ... versioned snapshots for indefinite support ... |
| scalability guidance for your apps and Ajax/Comet projects ... development services from 1 day to full product delivery |
| </p></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="configuring-webapps"></a>Configuring WebAppContexts</h2></div></div></div><div class="toc"><dl><dt><span class="section"><a href="configuring-webapps.html#webapp-configurations">Configuration Classes</a></span></dt><dt><span class="section"><a href="configuring-webapps.html#webapp-context-attributes">Other Configuration</a></span></dt></dl></div><p>Web applications require a certain amount of processing before they |
| can be deployed: they may need to be unpacked, a special classloader created |
| for their jars, web.xml and web-fragment.xml descriptors processed, and |
| classes scanned for annotations amongst many other things. As web |
| applications have become more complex, we have added ways to help you |
| customize by either broadening or lessening the amount of processing that is |
| done at deployment time. The two principal means for doing this are<a class="link" href="http://download.eclipse.org/jetty/stable-9/apidocs/org/eclipse/jetty/webapp/Configuration.html" target="_top"> |
| org.eclipse.jetty.webapp.Configuration</a> classes and some context |
| attributes.</p><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="webapp-configurations"></a>Configuration Classes</h3></div></div></div><p>As a webapp is being deployed, a series of <a class="link" href="http://download.eclipse.org/jetty/stable-9/apidocs/org/eclipse/jetty/webapp/Configuration.html" target="_top">org.eclipse.jetty.webapp.Configuration</a> |
| classes are applied to it, each one performing a specific function. The |
| ordering of these Configurations is significant as subsequent |
| Configurations tend to build on information extracted or setup in |
| foregoing Configurations. These are the default list, in order, of |
| Configurations that are applied to each <a class="link" href="http://download.eclipse.org/jetty/stable-9/apidocs/org/eclipse/jetty/webapp/WebAppContext.html" target="_top">org.eclipse.jetty.webapp.WebAppContex</a>t:</p><div class="table"><a name="d0e3216"></a><p class="title"><b>Table 5.1. Default Configuration classes</b></p><div class="table-contents"><table summary="Default Configuration classes" border="1"><colgroup><col><col></colgroup><tbody><tr><td><a class="link" href="http://download.eclipse.org/jetty/stable-9/apidocs/org/eclipse/jetty/webapp/WebInfConfiguration.html" target="_top">org.eclipse.jetty.webapp.WebInfConfiguration</a></td><td>Extracts war, orders jars and defines classpath</td></tr><tr><td><a class="link" href="http://download.eclipse.org/jetty/stable-9/apidocs/org/eclipse/jetty/webapp/WebXmlConfiguration.html" target="_top">org.eclipse.jetty.webapp.WebXmlConfiguration</a></td><td>Processes a WEB-INF/web.xml file</td></tr><tr><td><a class="link" href="http://download.eclipse.org/jetty/stable-9/apidocs/org/eclipse/jetty/webapp/MetaInfConfiguration.html" target="_top">org.eclipse.jetty.webapp.MetaInfConfiguration</a></td><td>Looks in container and webapp jars for META-INF/resources |
| and META-INF/web-fragment.xml</td></tr><tr><td><a class="link" href="http://download.eclipse.org/jetty/stable-9/apidocs/org/eclipse/jetty/webapp/FragmentConfiguration.html" target="_top">org.eclipse.jetty.webapp.FragmentConfiguration</a></td><td>Processes all discovered META-INF/web-fragment.xml |
| files</td></tr><tr><td><a class="link" href="http://download.eclipse.org/jetty/stable-9/apidocs/org/eclipse/jetty/webapp/JettyWebXmlConfiguration.html" target="_top">org.eclipse.jetty.webapp.JettyWebXmlConfiguration</a></td><td>Processes a WEB-INF/jetty-web.xml file</td></tr></tbody></table></div></div><br class="table-break"><p></p><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="d0e3252"></a>Anatomy of a Configuration Class</h4></div></div></div><p>A Configuration class is called 5 times in different phases of the |
| WebAppContext's lifecycle:</p><div class="variablelist"><dl><dt><span class="term">preConfigure</span></dt><dd><p>As the WebAppContext is starting up this phase is executed. |
| The Configuration should discover any of the resources it will |
| need during the subsequent phases.</p></dd><dt><span class="term">configure</span></dt><dd><p>This phase is where the work of the class is done, usually |
| using the resources discovered during the preConfigure |
| phase.</p></dd><dt><span class="term">postConfigure</span></dt><dd><p>This phase allows the Configuration to clear down any |
| resources that may have been created during the previous 2 phases |
| that are not needed for the lifetime of the WebAppContext.</p></dd><dt><span class="term">deconfigure</span></dt><dd><p>This phase occurs whenever a WebAppContext is being stopped |
| and allows the Configuration to undo any resources/metadata that |
| it created. A WebAppContext should be able to be cleanly |
| start/stopped multiple times without resources being held.</p></dd><dt><span class="term">destroy</span></dt><dd><p>This phase is called when a WebAppContext is actually |
| removed from service. For example, the war file associated with it |
| is deleted from the $JETTY_HOME/webapps directory.</p></dd></dl></div><p>Each phase is called on each Configuration class in the order in |
| which the Configuration class is listed. So for example, using our |
| default Configuration classes as an example, preConfigure() will be |
| called on WebInfConfiguration, WebXmlConfiguration, |
| MetaInfConfiguration, FragmentConfiguration and then |
| JettyWebXmlConfiguration. The cycle begins again for the configure() |
| phase and again for the postConfigure() phases. The cycle is repeated |
| <span class="emphasis"><em>in reverse order</em></span> for the deconfigure() and |
| eventually the destroy() phases.</p></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="d0e3293"></a>Extending Container Support by Creating Extra |
| Configurations</h4></div></div></div><p>As we have seen, there is a default set of Configurations that |
| support basic deployment of a webapp. You will notice that we have not |
| mentioned JavaEE features such as JNDI, nor advanced servlet spec |
| features such as annotations. That is because Jetty's philosophy is to |
| allow the user to tailor the container exactly to his needs. If you do |
| not need these kind of features, then you do not pay the price of them - |
| an important consideration because features such as annotations require |
| extensive and time-consuming scanning of WEB-INF/lib jars. As modern |
| webapps may have scores of these jars, it can be a source of significant |
| deployment delay. We will see in the section <a class="link" href="configuring-webapps.html#webapp-context-attributes" title="Other Configuration">Other Configuration</a> another |
| helpful webapp facility that Jetty provides for cutting down the time |
| spent analysing jars.</p><p>Jetty makes use of the flexibility of Configurations to make JNDI |
| and annotation support pluggable.</p><p>Firstly, lets look at how Configurations help enable JNDI.</p><div class="section"><div class="titlepage"><div><div><h5 class="title"><a name="d0e3305"></a>Example: JNDI Configurations</h5></div></div></div><p>JNDI lookups within web applications require the container to |
| hookup resources defined in the container's environment to that of the |
| web application. To acheive that, we use 2 extra |
| Configurations:</p><div class="table"><a name="d0e3310"></a><p class="title"><b>Table 5.2. JNDI Configuration classes</b></p><div class="table-contents"><table summary="JNDI Configuration classes" border="1"><colgroup><col><col></colgroup><tbody><tr><td><a class="link" href="http://download.eclipse.org/jetty/stable-9/apidocs/org/eclipse/jetty/plus/webapp/EnvConfiguration.html" target="_top">org.eclipse.jetty.plus.webapp.EnvConfiguration</a></td><td>Creates java:comp/env for the webapp, applies a |
| WEB-INF/jetty-env.xml file</td></tr><tr><td><a class="link" href="http://download.eclipse.org/jetty/stable-9/apidocs/org/eclipse/jetty/plus/webapp/PlusConfiguration.html" target="_top">org.eclipse.jetty.plus.webapp.PlusConfiguration</a></td><td>Processes JNDI related aspects of WEB-INF/web.xml and |
| hooks up naming entries</td></tr></tbody></table></div></div><br class="table-break"><p>These configurations must be added in |
| <span class="emphasis"><em>exactly</em></span> the order shown above and should be |
| inserted <span class="emphasis"><em>immediately before</em></span> the <a class="link" href="http://download.eclipse.org/jetty/stable-9/apidocs/org/eclipse/jetty/webapp/JettyWebXmlConfiguration.html" target="_top">org.eclipse.jetty.webapp.JettyWebXmlConfiguration</a> |
| class in the list of configurations. To fully support JNDI, you need |
| to do a couple of other things, full details of which you can find |
| <a class="link" href="jndi.html" title="Chapter 12. Configuring JNDI">here</a>.</p></div><div class="section"><div class="titlepage"><div><div><h5 class="title"><a name="d0e3341"></a>Example: Annotation Configurations</h5></div></div></div><p>We need just one extra Configuration class to help provide |
| servlet annotation scanning:</p><div class="table"><a name="d0e3346"></a><p class="title"><b>Table 5.3. Annotation Configuration classes</b></p><div class="table-contents"><table summary="Annotation Configuration classes" border="1"><colgroup><col><col></colgroup><tbody><tr><td><a class="link" href="http://download.eclipse.org/jetty/stable-9/apidocs/org/eclipse/jetty/annotations.AnnotationConfiguration.html" target="_top">org.eclipse.jetty.annotations.AnnotationConfiguration</a></td><td>Scan container and web app jars looking for |
| @WebServlet, @WebFilter, @WebListener etc</td></tr></tbody></table></div></div><br class="table-break"><p>The above configuration class must be <span class="emphasis"><em>inserted |
| immediately before</em></span> the <a class="link" href="http://download.eclipse.org/jetty/stable-9/apidocs/org/eclipse/jetty/webapp/JettWebXmlConfiguration.html" target="_top">org.eclipse.jetty.webapp.JettyWebXmlConfiguration</a> |
| class in the list of configurations. To fully support annotations, you |
| need to do a couple of other things, details of which can be found |
| here.</p></div></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="d0e3365"></a>How to Set the List of Configurations</h4></div></div></div><p>You have a number of options for how to make Jetty use a different |
| list of Configurations.</p><div class="section"><div class="titlepage"><div><div><h5 class="title"><a name="d0e3370"></a>Setting the list directly on the WebAppContext</h5></div></div></div><p>If you have only one webapp that you wish to affect, this may be |
| the easiest option. You will, however, either need to have a context |
| xml file that represents your web app, or you need to call the |
| equivalent in code. Let's see an example of how we would add in the |
| Configurations for both JNDI <span class="emphasis"><em>and</em></span> |
| annotations:</p><script type="syntaxhighlighter" class="brush: xml;toolbar: false"> |
| <![CDATA[<?xml version="1.0"?> |
| <!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/my-cool-webapp</Set> |
| |
| <Set name="configurationClasses"> |
| <Array type="java.lang.String"> |
| <Item>org.eclipse.jetty.webapp.WebInfConfiguration</Item> |
| <Item>org.eclipse.jetty.webapp.WebXmlConfiguration</Item> |
| <Item>org.eclipse.jetty.webapp.MetaInfConfiguration</Item> |
| <Item>org.eclipse.jetty.webapp.FragmentConfiguration</Item> |
| <Item>org.eclipse.jetty.plus.webapp.EnvConfiguration</Item> |
| <Item>org.eclipse.jetty.plus.webapp.PlusConfiguration</Item> |
| <Item>org.eclipse.jetty.annotations.AnnotationConfiguration</Item> |
| <Item>org.eclipse.jetty.webapp.JettyWebXmlConfiguration</Item> |
| </Array> |
| </Set> |
| |
| </Configure>]]> |
| </script><p>Of course, you can also use this method to reduce the |
| Configurations applied to a specific WebAppContext.</p></div><div class="section"><div class="titlepage"><div><div><h5 class="title"><a name="d0e3382"></a>Setting the list for all webapps via the Deployer</h5></div></div></div><p>If you use the <a class="link" href="deployment-architecture.html" title="Deployment Architecture">deployer</a>, you can set up the |
| list of Configuration classes on the <a class="link" href="deployment-architecture.html#default-web-app-provider" title="Understanding the Default WebAppProvider">WebAppProvider</a>. They will |
| then be applied to each WebAppContext deployed by the deployer:</p><script type="syntaxhighlighter" class="brush: xml;toolbar: false"> |
| <![CDATA[<?xml version="1.0"?> |
| <!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd"> |
| |
| <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 refid="Contexts" /> |
| </Set> |
| <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="configurationClasses"> |
| <Array type="java.lang.String"> |
| <Item>org.eclipse.jetty.webapp.WebInfConfiguration</Item> |
| <Item>org.eclipse.jetty.webapp.WebXmlConfiguration</Item> |
| <Item>org.eclipse.jetty.webapp.MetaInfConfiguration</Item> |
| <Item>org.eclipse.jetty.webapp.FragmentConfiguration</Item> |
| <Item>org.eclipse.jetty.plus.webapp.EnvConfiguration</Item> |
| <Item>org.eclipse.jetty.plus.webapp.PlusConfiguration</Item> |
| <Item>org.eclipse.jetty.annotations.AnnotationConfiguration</Item> |
| <Item>org.eclipse.jetty.webapp.JettyWebXmlConfiguration</Item> |
| </Array> |
| </Set> |
| </New> |
| </Arg> |
| </Call> |
| </New> |
| </Arg> |
| </Call> |
| </Configure> ]]> |
| </script></div><div class="section"><div class="titlepage"><div><div><h5 class="title"><a name="d0e3395"></a>Adding or inserting to an existing list</h5></div></div></div><p>Instead of having to enumerate the list in its entirety, you can |
| simply nominate classes that you want to add, and indicate whereabouts |
| in the list you want them inserted. Let's look at an example of using |
| this method to add in Configuration support for JNDI - as usual you |
| can either do this in an xml file, or via equivalent code. This |
| example uses an xml file, in fact it is the |
| $JETTY_HOME/etc/jetty-plus.xml file from the Jetty |
| distribution:</p><script type="syntaxhighlighter" class="brush: xml;toolbar: false"> |
| <![CDATA[<?xml version="1.0"?> |
| <!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd"> |
| |
| <Configure id="Server" class="org.eclipse.jetty.server.Server"> |
| |
| <!-- =========================================================== --> |
| <!-- Add plus Configuring classes to all webapps for this Server --> |
| <!-- =========================================================== --> |
| <Call class="org.eclipse.jetty.webapp.Configuration$ClassList" name="setServerDefault"> |
| <Arg><Ref refid="Server" /></Arg> |
| <Call name="addAfter"> |
| <Arg name="afterClass">org.eclipse.jetty.webapp.FragmentConfiguration</Arg> |
| <Arg> |
| <Array type="String"> |
| <Item>org.eclipse.jetty.plus.webapp.EnvConfiguration</Item> |
| <Item>org.eclipse.jetty.plus.webapp.PlusConfiguration</Item> |
| </Array> |
| </Arg> |
| </Call> |
| </Call> |
| |
| </Configure> |
| ]]> |
| </script><p>The <a class="link" href="http://download.eclipse.org/jetty/stable-9/apidocs/org/eclipse/jetty/webapp/Configuration.html" target="_top">org.eclipse.jetty.webapp.Configuration.ClassList</a> |
| class provides these methods for insertion:</p><div class="variablelist"><dl><dt><span class="term">addAfter</span></dt><dd><p>inserts the supplied list of Configuration class names |
| after the given Configuration class name</p></dd><dt><span class="term">addBefore</span></dt><dd><p>inserts the supplied list of Configuration class names |
| before the given Configuration class name</p></dd></dl></div></div></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="webapp-context-attributes"></a>Other Configuration</h3></div></div></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="container-include-jar-pattern"></a>org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern</h4></div></div></div><p>This is a context attribute that can be set on<a class="link" href="http://download.eclipse.org/jetty/stable-9/apidocs/org/eclipse/jetty/webapp/WebAppContext.html" target="_top"> an |
| org.eclipse.jetty.webapp.WebAppContext</a> to control which parts of |
| the <span class="emphasis"><em>container's</em></span> classpath should be processed for |
| things like annotations, META-INF/resources, META-INF/web-fragment.xml |
| etc.</p><p>Normally, nothing from the container classpath will be included |
| for processing. However, sometimes you will need to include some. For |
| example, you may have some libraries that are shared amongst your |
| webapps and thus you have put them into a $JETTY_HOME/lib directory. The |
| libraries contain annotations and therefore must be scanned.</p><p>The value of this attribute is a regexp that defines |
| which<span class="emphasis"><em> jars</em></span> and <span class="emphasis"><em>class |
| directories</em></span> from the container's classpath should be |
| examined.</p><p>Here's an example from a context xml file (although as always, you |
| could have accomplished the same in code), which would match any jar |
| whose name starts with "foo-" or "bar-", or a directory named |
| "classes":</p><script type="syntaxhighlighter" class="brush: xml;toolbar: false"> |
| <![CDATA[<?xml version="1.0"?> |
| <!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd"> |
| |
| <Configure class="org.eclipse.jetty.webapp.WebAppContext"> |
| |
| <Call name="setContextAttribute"> |
| <Arg>org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern</Arg> |
| <Arg>.*/foo-[^/]*\.jar$|.*/bar-[^/]*\.jar$|.*/classes/.*</Arg> |
| </Call> |
| |
| </Configure>]]> |
| </script><p>Note that the order of the patterns defines the ordering of the |
| scanning of the jars or class directories.</p></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a name="web-inf-include-jar-pattern"></a>org.eclipse.jetty.server.webapp.WebInfIncludeJarPattern</h4></div></div></div><p>Similarly to the previous context attribute, this attribute |
| controls which jars are processed for things like annotations and |
| META-INF resources. However, this attribute controls which jars from the |
| <span class="emphasis"><em>webapp's</em></span> classpath (usually WEB-INF/lib) are |
| processed. This can be particularly useful when you have dozens of jars |
| in WEB-INF/lib, but you know that only a few need to be scanned.</p><p>Here's an example (in an xml file, but you can do the same in |
| code) of a pattern that matches any jar that starts with |
| "spring-":</p><script type="syntaxhighlighter" class="brush: xml;toolbar: false"> |
| <![CDATA[<?xml version="1.0"?> |
| <!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd"> |
| |
| <Configure class="org.eclipse.jetty.webapp.WebAppContext"> |
| |
| <Call name="setContextAttribute"> |
| <Arg>org.eclipse.jetty.server.webapp.WebInfIncludeJarPattern</Arg> |
| <Arg>.*/spring-[^/]*\.jar$</Arg> |
| </Call> |
| |
| </Configure>]]> |
| </script><p>Note that the order of the patterns defines the ordering of the |
| scanning of the jars.</p></div></div></div><script type="text/javascript"> |
| SyntaxHighlighter.all() |
| </script><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="configuring-virtual-hosts.html"><i class="icon-chevron-left"></i> Previous</a> </td><td width="20%" align="center"><a accesskey="u" href="configuring-contexts.html"><i class="icon-chevron-up"></i> Top</a></td><td width="40%" align="right"> <a accesskey="n" href="serving-webapp-from-particular-port.html">Next <i class="icon-chevron-right"></i></a></td></tr><tr><td width="40%" align="left" valign="top">Configuring Virtual Hosts </td><td width="20%" align="center"><a accesskey="h" href="index.html"><i class="icon-home"></i> Home</a></td><td width="40%" align="right" valign="top"> Serving a WebApp from a Particular Port/Connector</td></tr></table></div><p xmlns:jfetch="java:org.eclipse.jetty.xslt.tools.JavaSourceFetchExtension" xmlns:fetch="java:org.eclipse.jetty.xslt.tools.SourceFetchExtension" xmlns:d="http://docbook.org/ns/docbook" xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0" xmlns:xslthl="http://xslthl.sf.net" xmlns:gcse="http://www.google.com" xmlns:date="http://exslt.org/dates-and-times"><div class="jetty-callout"> |
| See an error or something missing? |
| <span class="callout"><a href="http://github.com/jetty-project/jetty-documentation">Contribute to this documentation at |
| <span class="website"><i class="icon-github"></i> Github!</span></a></span><span style="float: right"><i>(Generated: 2013-10-30T13:20:20-05:00)</i></span></div></p><script xmlns:jfetch="java:org.eclipse.jetty.xslt.tools.JavaSourceFetchExtension" xmlns:fetch="java:org.eclipse.jetty.xslt.tools.SourceFetchExtension" xmlns:d="http://docbook.org/ns/docbook" xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0" xmlns:xslthl="http://xslthl.sf.net" xmlns:gcse="http://www.google.com" xmlns:date="http://exslt.org/dates-and-times" type="text/javascript"> |
| var _gaq = _gaq || []; |
| _gaq.push(['_setAccount', 'UA-1149868-7']); |
| _gaq.push(['_trackPageview']); |
| |
| (function() { |
| var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; |
| ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; |
| var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); |
| })(); |
| </script></body></html> |