blob: c6149bfabd2c60b8568d68e0c03b4981b13b03b3 [file] [log] [blame]
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<html>
<head>
<link type="text/css" rel="stylesheet" href="/resources/site.css">
<script src='/resources/space.js'></script>
<meta http-equiv="Content-type" content="text/html;charset=UTF-8">
<meta name="keywords" content="business integration, EAI, SOA, Service Oriented Architecture, web services, SOAP, JBI, JMS, WSDL, XML, EDI, Electronic Data Interchange, standards support, integration standards, application integration, middleware, software, solutions, services, CXF, open source">
<meta name="description" content="Apache CXF, Services Framework - Jetty Configuration">
<link type="text/css" rel="stylesheet" href="/resources/highlighter/styles/shCoreCXF.css">
<link type="text/css" rel="stylesheet" href="/resources/highlighter/styles/shThemeCXF.css">
<script src='/resources/highlighter/scripts/shCore.js'></script>
<script src='/resources/highlighter/scripts/shBrushXml.js'></script>
<script src='/resources/highlighter/scripts/shBrushJava.js'></script>
<script>
SyntaxHighlighter.defaults['toolbar'] = false;
SyntaxHighlighter.all();
</script>
<title>
Apache CXF -- Jetty Configuration
</title>
</head>
<body onload="init()">
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td id="cell-0-0" colspan="2">&nbsp;</td>
<td id="cell-0-1">&nbsp;</td>
<td id="cell-0-2" colspan="2">&nbsp;</td>
</tr>
<tr>
<td id="cell-1-0">&nbsp;</td>
<td id="cell-1-1">&nbsp;</td>
<td id="cell-1-2">
<!-- Banner -->
<div class="banner" id="banner"><div><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td align="left" colspan="1" nowrap>
<a shape="rect" href="http://cxf.apache.org/" title="Apache CXF"><span style="font-weight: bold; font-size: 170%; color: white">Apache CXF</span></a>
</td><td align="right" colspan="1" nowrap>
<a shape="rect" href="http://www.apache.org/" title="The Apache Sofware Foundation"><img border="0" alt="ASF Logo" src="http://cxf.apache.org/images/asf-logo.png"></a>
</td></tr></table></div></div>
<!-- Banner -->
<div id="top-menu">
<table border="0" cellpadding="1" cellspacing="0" width="100%">
<tr>
<td>
<div align="left">
<!-- Breadcrumbs -->
<a href="index.html">Index</a>&nbsp;&gt;&nbsp;<a href="transports.html">Transports</a>&nbsp;&gt;&nbsp;<a href="http-transport.html">HTTP Transport</a>&nbsp;&gt;&nbsp;<a href="jetty-configuration.html">Jetty Configuration</a>
<!-- Breadcrumbs -->
</div>
</td>
<td>
<div align="right">
<!-- Quicklinks -->
<div id="quicklinks"><p><a shape="rect" href="http://cxf.apache.org/download.html">Download</a> | <a shape="rect" href="http://cxf.apache.org/docs/index.html">Documentation</a></p></div>
<!-- Quicklinks -->
</div>
</td>
</tr>
</table>
</div>
</td>
<td id="cell-1-3">&nbsp;</td>
<td id="cell-1-4">&nbsp;</td>
</tr>
<tr>
<td id="cell-2-0" colspan="2">&nbsp;</td>
<td id="cell-2-1">
<table>
<tr valign="top">
<td height="100%">
<div id="wrapper-menu-page-right">
<div id="wrapper-menu-page-top">
<div id="wrapper-menu-page-bottom">
<div id="menu-page">
<!-- NavigationBar -->
<div id="navigation"><ul class="alternate"><li><a shape="rect" href="overview.html">Overview</a></li><li><a shape="rect" href="how-tos.html">How-Tos</a></li><li><a shape="rect" href="frontends.html">Frontends</a></li><li><a shape="rect" href="databindings.html">DataBindings</a></li><li><a shape="rect" href="transports.html">Transports</a></li><li><a shape="rect" href="configuration.html">Configuration</a></li><li><a shape="rect" href="debugging-and-logging.html">Debugging and Logging</a></li><li><a shape="rect" href="tools.html">Tools</a></li><li><a shape="rect" href="restful-services.html">RESTful Services</a></li><li><a shape="rect" href="wsdl-bindings.html">WSDL Bindings</a></li><li><a shape="rect" href="service-routing.html">Service Routing</a></li><li><a shape="rect" href="dynamic-languages.html">Dynamic Languages</a></li><li><a shape="rect" href="ws-support.html">WS-* Support</a></li><li><a shape="rect" href="advanced-integration.html">Advanced Integration</a></li><li><a shape="rect" href="deployment.html">Deployment</a></li><li><a shape="rect" href="schemas-and-namespaces.html">Use of Schemas and Namespaces</a></li></ul><hr><ul class="alternate"><li><p>Search</p></li></ul><form enctype="application/x-www-form-urlencoded" method="get" id="cse-search-box" action="http://www.google.com/cse">
<div>
<input type="hidden" name="cx" value="002890367768291051730:o99qiwa09y4">
<input type="hidden" name="ie" value="UTF-8">
<input type="text" name="q" size="21">
<input type="submit" name="sa" value="Search">
</div>
</form>
<script type="text/javascript" src="http://www.google.com/cse/brand?form=cse-search-box&amp;lang=en"></script><hr><ul class="alternate"><li><a shape="rect" href="http://cxf.apache.org/javadoc/latest/">API 3.2.x (Javadoc)</a></li><li><a shape="rect" href="http://cxf.apache.org/javadoc/latest-3.1.x/">API 3.1.x (Javadoc)</a></li><li><a shape="rect" href="http://cxf.apache.org/">CXF Website</a></li></ul><p>&#160;</p><p><a shape="rect" class="external-link" href="http://www.apache.org/events/current-event.html"><span class="confluence-embedded-file-wrapper"><img class="confluence-embedded-image confluence-external-resource" src="http://www.apache.org/events/current-event-125x125.png" data-image-src="http://www.apache.org/events/current-event-125x125.png"></span></a></p></div>
<!-- NavigationBar -->
</div>
</div>
</div>
</div>
</td>
<td height="100%">
<!-- Content -->
<div class="wiki-content">
<div id="ConfluenceContent"><p><style type="text/css">/*<![CDATA[*/
div.rbtoc1636141765068 {padding: 0px;}
div.rbtoc1636141765068 ul {list-style: disc;margin-left: 0px;}
div.rbtoc1636141765068 li {margin-left: 0px;padding-left: 0px;}
/*]]>*/</style></p><div class="toc-macro rbtoc1636141765068">
<ul class="toc-indentation"><li><a shape="rect" href="#JettyConfiguration-ConfiguringtheJettyRuntime">Configuring the Jetty Runtime</a>
<ul class="toc-indentation"><li><a shape="rect" href="#JettyConfiguration-Overview">Overview</a></li><li><a shape="rect" href="#JettyConfiguration-Namespace">Namespace</a></li><li><a shape="rect" href="#JettyConfiguration-Theengine-factoryelement">The engine-factory element</a></li><li><a shape="rect" href="#JettyConfiguration-Theengineelement">The engine element</a></li><li><a shape="rect" href="#JettyConfiguration-Configuringthethreadpool">Configuring the thread pool</a></li><li><a shape="rect" href="#JettyConfiguration-jetty_http2HTTP/2support">HTTP/2 support</a></li><li><a shape="rect" href="#JettyConfiguration-Example">Example</a></li></ul>
</li></ul>
</div><h1 id="JettyConfiguration-ConfiguringtheJettyRuntime">Configuring the Jetty Runtime</h1><h3 id="JettyConfiguration-Overview">Overview</h3><p>This section is for configuring the Jetty runtime used for the CXF standalone model. The Jetty runtime is used by HTTP servers and HTTP clients using a decoupled endpoint. The Jetty runtime's thread pool, connector and handlers can be configured. You can also set a number of the security settings for an HTTP service provider through the Jetty runtime.</p><h3 id="JettyConfiguration-Namespace">Namespace</h3><p>The elements used to configure the Jetty runtime are defined in the namespace <code><a shape="rect" href="http://cxf.apache.org/transports/http-jetty/configuration">http://cxf.apache.org/transports/http-jetty/configuration</a></code>. It is commonly referred to using the prefix <code>httpj</code>. In order to use the Jetty configuration elements you will need to add the lines shown below to the <code>beans</code> element of your endpoint's configuration file. In addition, you will need to add the configuration elements' namespace to the <code>xsi:schemaLocation</code> attribute.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<pre class="brush: java; gutter: false; theme: Default">
&lt;beans ...
xmlns:httpj="http://cxf.apache.org/transports/http-jetty/configuration
...
xsi:schemaLocation="...
http://cxf.apache.org/transports/http-jetty/configuration
http://cxf.apache.org/schemas/configuration/http-jetty.xsd
...&gt;
</pre>
</div></div><h3 id="JettyConfiguration-Theengine-factoryelement">The <code>engine-factory</code> element</h3><p>The <code>httpj:engine-factory</code> element is the root element used to configure the Jetty runtime used by an application. It has a single required attribute, bus, whose value is the name of the Bus that manages the Jetty instances being configured.</p><div class="confluence-information-macro confluence-information-macro-tip"><span class="aui-icon aui-icon-small aui-iconfont-approve confluence-information-macro-icon"></span><div class="confluence-information-macro-body"><p>The value is typically cxf which is the name of the default Bus instance.</p></div></div><p>The <code>httpj:engine-factory</code> element has three children that contain the information used to configure the HTTP ports instantiated by the Jetty runtime factory. The children are described below.</p><div class="table-wrap"><table class="wrapped confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh"><p>Element</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Description</p></th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>httpj:engine</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Specifies the configuration for a particular Jetty runtime instance.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>httpj:identifiedTLSServerParameters</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Specifies a reusable set of properties for securing an HTTP server. It has a single attribute, <code>id</code>, that specifies a unique identifier by which the property set can be referred.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>httpj:identifiedThreadingParameters</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Specifies a reusable set of properties for controlling a Jetty instance's thread pool. It has a single attribute, <code>id</code>, that specifies a unique identifier by which the property set can be referred.</p></td></tr></tbody></table></div><h3 id="JettyConfiguration-Theengineelement">The <code>engine</code> element</h3><p>The <code>httpj:engine</code> element is used to configure specific instances of the Jetty runtime. It has a single attribute, <code>port</code>, that specifies the number of the port being managed by the Jetty instance.</p><div class="confluence-information-macro confluence-information-macro-tip"><span class="aui-icon aui-icon-small aui-iconfont-approve confluence-information-macro-icon"></span><div class="confluence-information-macro-body"><p>You can specify a value of 0 for the port attribute. Any threading properties specified in an <code>httpj:engine</code> element with its port attribute set to 0 are used as the configuration for all Jetty listeners that are not explicitly configured.</p></div></div><p>Each <code>httpj:engine</code> element can have two children: one for configuring security properties and one for configuring the Jetty instance's thread pool. For each type of configuration you can either directly provide the configuration information or provide a reference to a set of configuration properties defined in the parent <code>httpj:engine-factory</code> element.</p><p>The child elements used to provide the configuration properties are described below.</p><div class="table-wrap"><table class="wrapped confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh"><p>Element</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Description</p></th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>httpj:tlsServerParameters</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Specifies a set of properties for configuring the security used for the specific Jetty instance. See the <a shape="rect" href="https://cwiki.apache.org/confluence/display/CXF20DOC/TLS+Configuration">TLS Configuration</a> page for more information.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>httpj:tlsServerParametersRef</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Refers to a set of security properties defined by a <code>identifiedTLSServerParameters</code> element. The <code>id</code> attribute provides the id of the referred <code>identifiedTLSServerParameters</code> element.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>httpj:threadingParameters</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Specifies the size of the thread pool used by the specific Jetty instance.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>httpj:threadingParametersRef</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Refers to a set of properties defined by a <code>identifiedThreadingParameters</code> element. The <code>id</code> attribute provides the id of the referred <code>identifiedThreadingParameters</code> element.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>httpj:connector</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>You can use spring beans syntax to instantiate a connector and set the connector's properties , this connector will be set to the Jetty server engine</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>httpj:handlers</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>You can use spring beans syntax to instantiate a Jetty handler list and set these handlers' properties , the jetty handlers will be set to the Jetty server engine</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>httpj:sessionSupport</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>If the value is true , the Jetty Engine will set up a session manager for the Jetty server engine to maintain the sessions. The default value of it is false.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>httpj:reuseAddress</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>The the value is true, the Jetty Engine connector's socket will enable the SO_REUSEADDR flage. The default value of it is true. (This feature is available in CXF 2.0.3)</p></td></tr></tbody></table></div><h3 id="JettyConfiguration-Configuringthethreadpool">Configuring the thread pool</h3><p>You can configure the size of a Jetty instance's thread pool by either:</p><ul><li>Specifying the size of thread pool using a <code>identifiedThreadingParameters</code> element in the <code>engine-factory</code> element. You then refer to the element using a <code>threadingParametersRef</code> element.</li><li><p class="auto-cursor-target">Specify the size of the of thread pool directly using a <code>threadingParameters</code> element.<br clear="none">The <code>threadingParameters</code> has two attributes to specify the size of a thread pool. The attributes are described below.</p><div class="confluence-information-macro confluence-information-macro-note"><span class="aui-icon aui-icon-small aui-iconfont-warning confluence-information-macro-icon"></span><div class="confluence-information-macro-body"><p>The <code>httpj:identifiedThreadingParameters</code> element has a single child <code>threadingParameters</code> element.</p></div></div></li></ul><div class="table-wrap"><table class="wrapped confluenceTable"><colgroup span="1"><col span="1"><col span="1"></colgroup><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh"><p>Attribute</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Description</p></th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>minThreads</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Specifies the minimum number of threads available to the Jetty instance for processing requests.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>maxThreads</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Specifies the maximum number of threads available to the Jetty instance for processing requests.</p></td></tr></tbody></table></div><h3 id="JettyConfiguration-jetty_http2HTTP/2support"><span class="confluence-anchor-link" id="JettyConfiguration-jetty_http2"></span>HTTP/2 support</h3><p>If <strong>HttpServerEngineSupport#ENABLE_HTTP2</strong>&#160; bus property is set, Jetty engine will enable the HTTP/2 support as well: HTTP/2 over cleartext (h2c) if TLS is not configured, regular HTTP/2 otherwise. It requires additional dependencies to be bundled by the application.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<pre class="brush: java; gutter: false; theme: Default">&lt;dependency&gt;
&lt;groupId&gt;org.eclipse.jetty.http2&lt;/groupId&gt;
&lt;artifactId&gt;http2-server&lt;/artifactId&gt;
&lt;version&gt;${jetty.version}&lt;/version&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
&lt;groupId&gt;org.eclipse.jetty&lt;/groupId&gt;
&lt;artifactId&gt;jetty-alpn-server&lt;/artifactId&gt;
&lt;version&gt;${jetty.version}&lt;/version&gt;
&lt;/dependency&gt;</pre>
</div></div><p>Additionally, for JDK8 you would need to include:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<pre class="brush: java; gutter: false; theme: Default">&lt;dependency&gt;
&lt;groupId&gt;org.eclipse.jetty&lt;/groupId&gt;
&lt;artifactId&gt;jetty-alpn-openjdk8-server&lt;/artifactId&gt;
&lt;version&gt;${jetty.version}&lt;/version&gt;
&lt;/dependency&gt;</pre>
</div></div><p>If you are using JDK9 and above, please use the following dependency instead:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<pre class="brush: java; gutter: false; theme: Default">&lt;dependency&gt;
&lt;groupId&gt;org.eclipse.jetty&lt;/groupId&gt;
&lt;artifactId&gt;jetty-alpn-java-server&lt;/artifactId&gt;
&lt;version&gt;${jetty.version}&lt;/version&gt;
&lt;/dependency&gt;</pre>
</div></div><p>Example: <a shape="rect" class="external-link" href="https://github.com/apache/cxf/tree/master/distribution/src/main/release/samples/jax_rs/basic_http2_jetty" rel="nofollow">https://github.com/apache/cxf/tree/master/distribution/src/main/release/samples/jax_rs/basic_http2_jetty</a></p><h3 id="JettyConfiguration-Example">Example</h3><p>The example below shows a configuration fragment that configures a Jetty instance on port number 9001.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<pre class="brush: java; gutter: false; theme: Default">
&lt;beans xmlns="http://www.springframework.org/schema/beans"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:sec="http://cxf.apache.org/configuration/security"
xmlns:http="http://cxf.apache.org/transports/http/configuration"
xmlns:httpj="http://cxf.apache.org/transports/http-jetty/configuration"
xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"
xsi:schemaLocation="http://cxf.apache.org/configuration/security
http://cxf.apache.org/schemas/configuration/security.xsd
http://cxf.apache.org/transports/http/configuration
http://cxf.apache.org/schemas/configuration/http-conf.xsd
http://cxf.apache.org/transports/http-jetty/configuration
http://cxf.apache.org/schemas/configuration/http-jetty.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"&gt;
...
&lt;httpj:engine-factory bus="cxf"&gt;
&lt;httpj:identifiedTLSServerParameters id="secure"&gt;
&lt;httpj:tlsServerParameters&gt;
&lt;sec:keyManagers keyPassword="password"&gt;
&lt;sec:keyStore type="JKS" password="password"
file="certs/cherry.jks"/&gt;
&lt;/sec:keyManagers&gt;
&lt;/httpj:tlsServerParameters&gt;
&lt;/httpj:identifiedTLSServerParameters&gt;
&lt;httpj:engine port="9001"&gt;
&lt;httpj:tlsServerParametersRef id="secure" /&gt;
&lt;httpj:threadingParameters minThreads="5"
maxThreads="15" /&gt;
&lt;httpj:connector&gt;
&lt;beans:bean class="org.eclipse.jetty.server.bio.SocketConnector"&gt;
&lt;beans:property name = "port" value="9001" /&gt;
&lt;/beans:bean&gt;
&lt;/httpj:connector&gt;
&lt;httpj:handlers&gt;
&lt;beans:bean class="org.eclipse.jetty.server.handler.DefaultHandler"/&gt;
&lt;/httpj:handlers&gt;
&lt;httpj:sessionSupport&gt;true&lt;/httpj:sessionSupport&gt;
&lt;/httpj:engine&gt;
&lt;/httpj:engine-factory&gt;
&lt;/beans&gt;
</pre>
</div></div></div>
</div>
<!-- Content -->
</td>
</tr>
</table>
</td>
<td id="cell-2-2" colspan="2">&nbsp;</td>
</tr>
<tr>
<td id="cell-3-0">&nbsp;</td>
<td id="cell-3-1">&nbsp;</td>
<td id="cell-3-2">
<div id="footer">
<!-- Footer -->
<div id="site-footer">
<a href="http://cxf.apache.org/privacy-policy.html">Privacy Policy</a> -
(<a href="https://cwiki.apache.org/confluence/pages/editpage.action?pageId=60564">edit page</a>)
(<a href="https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=60564&amp;showComments=true&amp;showCommentArea=true#addcomment">add comment</a>)<br>
Apache CXF, CXF, Apache, the Apache feather logo are trademarks of The Apache Software Foundation.<br>
All other marks mentioned may be trademarks or registered trademarks of their respective owners.
</div>
<!-- Footer -->
</div>
</td>
<td id="cell-3-3">&nbsp;</td>
<td id="cell-3-4">&nbsp;</td>
</tr>
<tr>
<td id="cell-4-0" colspan="2">&nbsp;</td>
<td id="cell-4-1">&nbsp;</td>
<td id="cell-4-2" colspan="2">&nbsp;</td>
</tr>
</table>
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-4458903-1");
pageTracker._trackPageview();
} catch(err) {}</script>
</body>
</html>