Bind certain Web-Applications to specific HttpConnectors

Starting with Pax-Web 2.1 it’s possible to bind web applications to a specific http-connector. For this to work you need to configure an additional http connector through jetty.xml. The jetty.xml for pax-web uses a slightly different way of configuring connectors. Instead of setting a new Connector the jetty.xml is interpreted after the Jetty Server has already been configured. Therefore you need to add a connector, not create a new one.

    <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="8282"/></Set>
            <Set name="maxIdleTime">300000</Set>
            <Set name="Acceptors">2</Set>
            <Set name="statsOn">false</Set>
            <Set name="confidentialPort">8443</Set>
            <Set name="name">jettyConn1</Set>
	    <Set name="lowResourcesConnections">20000</Set>
	    <Set name="lowResourcesMaxIdleTime">5000</Set>
          </New>
      </Arg>
    </Call>

Make sure you have a name configured for this connector. The sample uses jettyConn1 as name.

The Manifest of this Web-Application Bundle needs two additional entries. Web-Connectors and Web-VirtualHosts.

Web-Connectors: jettyConn1
Web-VirtualHosts: localhost

Another alternative way of binding your Web-Application to a certain Web-Connector or Virtual host is to add it to the installation URL.

webbundle:mvn:groupId/artifactId/version/war?Web-ContextPath=test&Web-Connectors=jettyConn1&Web-VirtualHosts=localhost

The Pax-Web itests do contain two working examples for more details check the two links below:
JettyConfigurationExtendedIntegrationTest
JettyConfigurationExtendedTwoIntegrationTest


Beitrag veröffentlicht

in

, ,

von

Schlagwörter:

Kommentare

5 Antworten zu „Bind certain Web-Applications to specific HttpConnectors“

  1. […] Post navigation ← Previous Next → […]

  2. Avatar von Srikanth Hugar
    Srikanth Hugar

    Hi, I am trying to do similar setup for jar files not war files. Is it possible to achieve the same with jar? My jar has jaxrs:server configuration. where the changes should be done?

    1. Avatar von anierbeck
      anierbeck

      As long as you make sure it is a WAB, it will work. The key of success is a WebContext-Path header in the Manifest. This will transform any JAR into a WAB. That in combination with the other Manifest entries will bind your jaxrs WAB/JAR to the desired Connector.
      Beware: With Pax Web 4.0 this will change a bit, but I’m gonna document and blog about it.

  3. Avatar von Jens Kleemann

    I used this succesfully in karaf 3.0.3 to bind certain APIs / Administration Vaadin war to different endpoints inside karaf.

    Web-Connectors: webadmin

    But after the switch to karaf 4.0.1 (with pax-web 4.2.0) this no longer works – all servlets/wars now bind to the “default” connector – which makes my vaadin unusable.

    Are there any examples (i didn’t found any) for this mechanism on karaf 4.0.x ?

    1. Avatar von anierbeck
      anierbeck

      Please open an issue for this at ops4j

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert

*

Diese Website verwendet Akismet, um Spam zu reduzieren. Erfahre mehr darüber, wie deine Kommentardaten verarbeitet werden.