Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] Jetty 8 to 9 connector confusion

Your inspired me to write up an example of custom connectors in ${jetty.base}

So here it is: https://github.com/jetty-project/example-jetty-base-custom-connectors

Notes:
  • The start.ini does not use the standard modules [http, https, http2, or ssl]
  • The contents of etc/app1-connectors.xml is almost identical to etc/app2-connectors.xml (just changed the references to 'app1' to 'app2')
  • The start.ini shows how to configure (with properties) the various knobs in the connectors using <Property> references.
  • There are 2 keystores in etc (keystore.app1, and keystore.app2) 
Go ahead and run the base, to see how it works ...

$ cd tmp
Cloning into 'example-jetty-base-custom-connectors'...
remote: Counting objects: 16, done.
remote: Compressing objects: 100% (12/12), done.
remote: Total 16 (delta 4), reused 11 (delta 2), pack-reused 0
Unpacking objects: 100% (16/16), done.
Checking connectivity... done.

$ cd example-jetty-base-custom-connectors/
$ java -jar ~/distros/jetty-distribution-9.3.0.v20150612/start.jar 
2015-06-26 12:17:25.683:INFO::main: Logging initialized @284ms
2015-06-26 12:17:25.832:INFO:oejs.Server:main: jetty-9.3.0.v20150612
2015-06-26 12:17:25.846:INFO:oejdp.ScanningAppProvider:main: Deployment monitor [file:///home/joakim/tmp/example-jetty-base-custom-connectors/webapps/] at interval 1
2015-06-26 12:17:25.858:INFO:oejs.ServerConnector:main: Started conn-app1@6e3c1e69{HTTP/1.1,[http/1.1]}{0.0.0.0:8080}
2015-06-26 12:17:25.875:INFO:oejus.SslContextFactory:main: x509={jetty.eclipse.org=jetty} wild={} alias=null for SslContextFactory@6adca536(file:///home/joakim/tmp/example-jetty-base-custom-connectors/etc/keystore.app1,file:///home/joakim/tmp/example-jetty-base-custom-connectors/etc/keystore.app1)
2015-06-26 12:17:26.084:INFO:oejs.ServerConnector:main: Started conn-app1@53f65459{SSL,[ssl, http/1.1]}{0.0.0.0:8443}
2015-06-26 12:17:26.084:INFO:oejs.ServerConnector:main: Started conn-app2@3b088d51{HTTP/1.1,[http/1.1]}{0.0.0.0:9600}
2015-06-26 12:17:26.089:INFO:oejus.SslContextFactory:main: x509={jetty.eclipse.org=jetty} wild={} alias=null for SslContextFactory@74650e52(file:///home/joakim/tmp/example-jetty-base-custom-connectors/etc/keystore.app2,file:///home/joakim/tmp/example-jetty-base-custom-connectors/etc/keystore.app2)
2015-06-26 12:17:26.096:INFO:oejs.ServerConnector:main: Started conn-app2@6acdbdf5{SSL,[ssl, http/1.1]}{0.0.0.0:9601}
2015-06-26 12:17:26.096:INFO:oejs.Server:main: Started @697ms

Good luck


--
Joakim Erdfelt <joakim@xxxxxxxxxxx>
Expert advice, services and support from from the Jetty & CometD experts

On Wed, Jun 24, 2015 at 12:58 PM, JD Fant <jd@xxxxxxxxxxxxx> wrote:
I am attempting to upgrade from Jetty 8 (8.1.17) to Jetty 9 (9.3) and have hit a wall in my progress. This is running on an AWS (Amazon Linux) instance, BTW.

After reading the "Configuring Jetty Connectors" page, there are many changes to digest. (http://www.eclipse.org/jetty/documentation/current/configuring-connectors.html)
My confusion is where to add the old (Jetty 8) connector configurations for Jetty 9.

It is my understanding that there is a move to try and consolidate all configurations in the start.ini file (that would be nice). However, I see many examples of editing various .xml files (ie, jetty.xml, jetty-ssl.xml, etc,.).

Here is the old (jetty 8) connector setup extracted from jetty.xml (passwords have been changed):
#===========================================================
<Set name="connectors">
      <Array type="org.eclipse.jetty.server.Connector">
        <Item>
          <New class="org.eclipse.jetty.server.ssl.SslSelectChannelConnector">
            <Arg>
              <New class="org.eclipse.jetty.http.ssl.SslContextFactory">
                <Set name="certAlias">password1</Set>
                <Set name="keyStore"><SystemProperty name="jetty.home" default="." />/etc/keystore</Set>
                <Set name="keyStorePassword">password1</Set>
                <Set name="keyManagerPassword">password1</Set>
                <Set name="excludeCipherSuites">
                  <Array type="java.lang.String">
                    <Item>.+RC4.+</Item>
                  </Array>
                </Set>
        <Set name="excludeProtocols">
          <Array type="java.lang.String">
            <Item>SSLv2</Item>
            <Item>SSLv3</Item>
          </Array>
        </Set>
              </New>
            </Arg>
            <Set name="port">443</Set>
            <Set name="maxIdleTime">300000</Set>
            <Set name="Acceptors">1</Set>
            <Set name="name">conn-app1</Set>
          </New>
        </Item>
        <Item>
          <New class="org.eclipse.jetty.server.ssl.SslSelectChannelConnector">
            <Arg>
              <New class="org.eclipse.jetty.http.ssl.SslContextFactory">
                <Set name="certAlias">password2</Set>
                <Set name="keyStore"><SystemProperty name="jetty.home" default="." />/etc/keystore.app2</Set>
                <Set name="keyStorePassword">password2</Set>
                <Set name="keyManagerPassword">password2</Set>
                <Set name="needClientAuth">true</Set>
                <Set name="IncludeCipherSuites">
                  <Array type="java.lang.String">
                    <Item>TLS_ECDHE_RSA_WITH_RC4_128_SHA</Item>
                    <Item>SSL_RSA_WITH_RC4_128_SHA</Item>
                  </Array>
                </Set>
                <Set name="excludeProtocols">
                  <Array type="java.lang.String">
                    <Item>SSLv2</Item>
                    <Item>SSLv3</Item>
                  </Array>
        </Set>
              </New>
            </Arg>
            <Set name="port">2600</Set>
            <Set name="maxIdleTime">300000</Set>
            <Set name="Acceptors">1</Set>
            <Set name="name">conn-app2</Set>
          </New>
        </Item>
        <Item>
          <New class="org.eclipse.jetty.server.nio.SelectChannelConnector">
            <Set name="port">2601</Set>
            <Set name="maxIdleTime">300000</Set>
            <Set name="Acceptors">1</Set>
            <Set name="name">conn-app2</Set>
          </New>
        </Item>
    <Item>
          <New class="org.eclipse.jetty.server.nio.SelectChannelConnector">
            <Set name="port">8080</Set>
            <Set name="maxIdleTime">300000</Set>
            <Set name="Acceptors">1</Set>
            <Set name="name">conn-app1</Set>
          </New>
        </Item>
      </Array>
    </Set>
#===========================================================
As you can see, I also have multiple keystore passwords to deal with, as well.

Attempting to add the above configuration into the (new) xml files created failures across the board.


I followed Joakim's steps on http://dev.eclipse.org/mhonarc/lists/jetty-users/msg03850.html and can see that many of the variables, in the old jetty.xml file, can be added to start.ini.

Just not sure where/how to add multiple connector port settings. Is it necessary to edit the etc/*.xml files or is it best (possible?) to keep it all in start.ini?

Below is what I have in the start.ini file (commented sections have been removed & passwords changed):
#===========================================================

# To disable the warning message, comment the following line
--module=home-base-warning

# ---------------------------------------
# Module: ext
--module=ext

# ---------------------------------------
# Module: resources
--module=resources

# ---------------------------------------
# Module: server
--module=server

# ---------------------------------------
# Module: http
--module=http

# ---------------------------------------
# Module: deploy
--module=deploy

# ---------------------------------------
# Module: jsp
--module=jsp

# ---------------------------------------
# Module: websocket
--module=websocket

# ---------------------------------------
# Module: jstl
--module=jstl

# ---------------------------------------
# Module: ssl
--module=ssl

### TLS(SSL) Connector Configuration

## Connector port to listen on
jetty.ssl.port=443

## Keystore file path (relative to $jetty.base)
jetty.sslContext.keyStorePath=etc/keystore

## Truststore file path (relative to $jetty.base)
jetty.sslContext.trustStorePath=etc/keystore

## Keystore password
jetty.sslContext.keyStorePassword=password1

## KeyManager password
jetty.sslContext.keyManagerPassword=password1

## Truststore password
jetty.sslContext.trustStorePassword=password1


Below is the ouput of 'java -jar start.jar --list-config' (my jetty.{home,base} are the same to test for now)
#===========================================================

Java Environment:
-----------------
 java.home = /usr/java/jdk1.8.0_11/jre
 java.vm.vendor = Oracle Corporation
 java.vm.version = 25.11-b03
 java.vm.name = Java HotSpot(TM) 64-Bit Server VM
 java.vm.info = mixed mode
 java.runtime.name = Java(TM) SE Runtime Environment
 java.runtime.version = 1.8.0_11-b12
 java.io.tmpdir = /tmp
 user.dir = /opt/jetty-distribution-9.3.0.v20150612
 user.language = en
 user.country = US

Jetty Environment:
-----------------
 jetty.version = 9.3.0.v20150612
 jetty.tag.version = master
 jetty.home = /opt/jetty-distribution-9.3.0.v20150612
 jetty.base = /opt/jetty-distribution-9.3.0.v20150612

Config Search Order:
--------------------
 <command-line>
 ${jetty.base} -> /opt/jetty-distribution-9.3.0.v20150612
 ${jetty.home} -> /opt/jetty-distribution-9.3.0.v20150612


JVM Arguments:
--------------
 (no jvm args specified)

System Properties:
------------------
 (no system properties specified)

Properties:
-----------
 jetty.ssl.port = 8443
 jetty.sslContext.keyManagerPassword = password1
 jetty.sslContext.keyStorePassword = password1
 jetty.sslContext.keyStorePath = etc/keystore
 jetty.sslContext.trustStorePassword = password1
 jetty.sslContext.trustStorePath = etc/keystore

Jetty Server Classpath:
-----------------------
Version Information on 34 entries in the classpath.
Note: order presented here is how they would appear on the classpath.
      changes to the --module=name command line options will be reflected here.
 0:          9.3.0.v20150612 | ${jetty.base}/lib/apache-jsp/org.eclipse.jetty.apache-jsp-9.3.0.v20150612.jar
 1:   3.8.2.v20130121-145325 | ${jetty.base}/lib/apache-jsp/org.eclipse.jetty.orbit.org.eclipse.jdt.core-3.8.2.v20130121.jar
 2:                   8.0.20 | ${jetty.base}/lib/apache-jsp/org.mortbay.jasper.apache-el-8.0.20.M0.jar
 3:                      2.3 | ${jetty.base}/lib/apache-jsp/org.mortbay.jasper.apache-jsp-8.0.20.M0.jar
 4:                    1.2.1 | ${jetty.base}/lib/apache-jstl/org.apache.taglibs.taglibs-standard-impl-1.2.1.jar
 5:                    1.2.1 | ${jetty.base}/lib/apache-jstl/org.apache.taglibs.taglibs-standard-spec-1.2.1.jar
 6:                    (dir) | ${jetty.base}/resources
 7:                    3.1.0 | ${jetty.base}/lib/servlet-api-3.1.jar
 8:                 3.1.0.M0 | ${jetty.base}/lib/jetty-schemas-3.1.jar
 9:          9.3.0.v20150612 | ${jetty.base}/lib/jetty-http-9.3.0.v20150612.jar
10:          9.3.0.v20150612 | ${jetty.base}/lib/jetty-server-9.3.0.v20150612.jar
11:          9.3.0.v20150612 | ${jetty.base}/lib/jetty-xml-9.3.0.v20150612.jar
12:          9.3.0.v20150612 | ${jetty.base}/lib/jetty-util-9.3.0.v20150612.jar
13:          9.3.0.v20150612 | ${jetty.base}/lib/jetty-io-9.3.0.v20150612.jar
14:          9.3.0.v20150612 | ${jetty.base}/lib/jetty-jndi-9.3.0.v20150612.jar
15:      1.4.1.v201005082020 | ${jetty.base}/lib/jndi/javax.mail.glassfish-1.4.1.v201005082020.jar
16:                      1.2 | ${jetty.base}/lib/jndi/javax.transaction-api-1.2.jar
17:          9.3.0.v20150612 | ${jetty.base}/lib/jetty-security-9.3.0.v20150612.jar
18:          9.3.0.v20150612 | ${jetty.base}/lib/jetty-servlet-9.3.0.v20150612.jar
19:          9.3.0.v20150612 | ${jetty.base}/lib/jetty-webapp-9.3.0.v20150612.jar
20:          9.3.0.v20150612 | ${jetty.base}/lib/jetty-deploy-9.3.0.v20150612.jar
21:          9.3.0.v20150612 | ${jetty.base}/lib/jetty-plus-9.3.0.v20150612.jar
22:          9.3.0.v20150612 | ${jetty.base}/lib/jetty-annotations-9.3.0.v20150612.jar
23:                    5.0.1 | ${jetty.base}/lib/annotations/asm-5.0.1.jar
24:                    5.0.1 | ${jetty.base}/lib/annotations/asm-commons-5.0.1.jar
25:                      1.2 | ${jetty.base}/lib/annotations/javax.annotation-api-1.2.jar
26:                      1.0 | ${jetty.base}/lib/websocket/javax.websocket-api-1.0.jar
27:          9.3.0.v20150612 | ${jetty.base}/lib/websocket/javax-websocket-client-impl-9.3.0.v20150612.jar
28:          9.3.0.v20150612 | ${jetty.base}/lib/websocket/javax-websocket-server-impl-9.3.0.v20150612.jar
29:          9.3.0.v20150612 | ${jetty.base}/lib/websocket/websocket-api-9.3.0.v20150612.jar
30:          9.3.0.v20150612 | ${jetty.base}/lib/websocket/websocket-client-9.3.0.v20150612.jar
31:          9.3.0.v20150612 | ${jetty.base}/lib/websocket/websocket-common-9.3.0.v20150612.jar
32:          9.3.0.v20150612 | ${jetty.base}/lib/websocket/websocket-server-9.3.0.v20150612.jar
33:          9.3.0.v20150612 | ${jetty.base}/lib/websocket/websocket-servlet-9.3.0.v20150612.jar

Jetty Active XMLs:
------------------
 ${jetty.base}/etc/jetty.xml
 ${jetty.base}/etc/jetty-http.xml
 ${jetty.base}/etc/jetty-ssl.xml
 ${jetty.base}/etc/jetty-ssl-context.xml
 ${jetty.base}/etc/jetty-deploy.xml
 ${jetty.base}/etc/jetty-plus.xml
 ${jetty.base}/etc/jetty-annotations.xml

#===========================================================


When using the above start.ini with all xml files at default, it starts to load the war files and seems to start working, then I run into this error:

2015-06-24 16:07:24.031:INFO:oejsh.ContextHandler:main: Started o.e.j.w.WebAppContext@4b7c4456{/app2,file:///tmp/jetty-0.0.0.0-8080-app2.war-_app2-any-7629879214902633666.dir/webapp/,AVAILABLE}{/app2.war}
2015-06-24 16:07:24.099:INFO:oejs.ServerConnector:main: Started ServerConnector@31ca701b{HTTP/1.1,[http/1.1]}{0.0.0.0:8080}
java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.eclipse.jetty.start.Main.invokeMain(Main.java:214)
    at org.eclipse.jetty.start.Main.start(Main.java:457)
    at org.eclipse.jetty.start.Main.main(Main.java:75)
Caused by: java.lang.NullPointerException
    at org.eclipse.jetty.util.StringUtil.asciiToLowerCase(StringUtil.java:119)
    at org.eclipse.jetty.server.AbstractConnector.getConnectionFactory(AbstractConnector.java:345)
    at org.eclipse.jetty.server.AbstractConnector.doStart(AbstractConnector.java:256)
    at org.eclipse.jetty.server.AbstractNetworkConnector.doStart(AbstractNetworkConnector.java:81)
    at org.eclipse.jetty.server.ServerConnector.doStart(ServerConnector.java:244)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at org.eclipse.jetty.server.Server.doStart(Server.java:384)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at org.eclipse.jetty.xml.XmlConfiguration$1.run(XmlConfiguration.java:1520)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.eclipse.jetty.xml.XmlConfiguration.main(XmlConfiguration.java:1445)
    ... 7 more

Not exactly sure what to check. I fell strongly that it is due to the connector configurations.

I have changed/added variables in the start.ini file with mixed results, all creating errors similar to the one above.

I do know that, in the old jetty.xml file, there are 4 network ports (8080, 443, 2600, and 2601) and 2 keystore files/passwords to consider.

I feel that I am close, but have been attempting to get Jetty 9 going a couple of days straight and cannot seem to get any further.


Thank you,
JD

_______________________________________________
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


Back to the top