Pax Web Configuration Fails When Using SSLContextFactory in jetty.xml

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Pax Web Configuration Fails When Using SSLContextFactory in jetty.xml

carma.robot
My org.ops4j.pax.web.cfg configuration has:

org.ops4j.pax.web.config.file=./etc/jetty.xml

And in my jetty.xml configuration I have:

    <New id="sslContextFactory" class="org.eclipse.jetty.http.ssl.SslContextFactory">
       <Set name="keyStoreType">JCEKS</Set>
       <Set name="keyStore"><SystemProperty name="jetty.home" default="."/>/certs/keystore.jceks</Set>
       <Set name="keyStorePassword">7ru5phere</Set>
       <Set name="keyManagerPassword">7ru5phere</Set>
       <Set name="certAlias">sts_tls_cert</Set>
       <Set name="trustStoreType">JCEKS</Set>
       <Set name="trustStore"><SystemProperty name="jetty.home" default="."/>/certs/truststore.jceks</Set>
       <Set name="trustStorePassword">7ru5phere</Set>
    </New>

   <Call name="addConnector">
     <Arg>
       <New class="org.eclipse.jetty.server.ssl.SslSelectChannelConnector">
         <Arg><Ref id="sslContextFactory"/></Arg>
         <Set name="port"><Property name="jetty.port.ssl" default="9443"/></Set>
         <Set name="maxIdleTime">30000</Set>
       </New>
     </Arg>
   </Call>

Unfortunately, this fails with:

java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[:1.7.0_25]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)[:1.7.0_25]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[:1.7.0_25]
        at java.lang.reflect.Method.invoke(Method.java:606)[:1.7.0_25]
        at org.ops4j.pax.web.service.jetty.internal.JettyServerImpl.start(JettyServerImpl.java:108)[111:org.ops4j.pax.web.pax-web-jetty:1.1.14]
        at org.ops4j.pax.web.service.jetty.internal.ServerControllerImpl$Stopped.start(ServerControllerImpl.java:378)[111:org.ops4j.pax.web.pax-web-jetty:1.1.14]
        at org.ops4j.pax.web.service.jetty.internal.ServerControllerImpl.start(ServerControllerImpl.java:70)[111:org.ops4j.pax.web.pax-web-jetty:1.1.14]
        at org.ops4j.pax.web.service.jetty.internal.ServerControllerImpl$Unconfigured.configure(ServerControllerImpl.java:635)[111:org.ops4j.pax.web.pax-web-jetty:1.1.14]
        at org.ops4j.pax.web.service.jetty.internal.ServerControllerImpl.configure(ServerControllerImpl.java:87)[111:org.ops4j.pax.web.pax-web-jetty:1.1.14]
        at org.ops4j.pax.web.service.internal.Activator.updateController(Activator.java:245)[110:org.ops4j.pax.web.pax-web-runtime:1.1.14]
        at org.ops4j.pax.web.service.internal.Activator$DynamicsServiceTrackerCustomizer$1.run(Activator.java:376)[110:org.ops4j.pax.web.pax-web-runtime:1.1.14]
        at org.ops4j.pax.web.service.internal.Executor$Future.run(Executor.java:45)[110:org.ops4j.pax.web.pax-web-runtime:1.1.14]
        at org.ops4j.pax.web.service.internal.Executor$Worker.run(Executor.java:126)[110:org.ops4j.pax.web.pax-web-runtime:1.1.14]
Caused by: java.lang.ClassNotFoundException: org.eclipse.jetty.http.ssl.SslContextFactory not found by org.ops4j.pax.web.pax-web-jetty [111]
        at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1460)
        at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:72)
        at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1843)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)[:1.7.0_25]
        at org.eclipse.jetty.util.Loader.loadClass(Loader.java:101)
        at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.nodeClass(XmlConfiguration.java:361)
        at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.newObj(XmlConfiguration.java:761)
        at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.configure(XmlConfiguration.java:399)
        at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.configure(XmlConfiguration.java:332)
        at org.eclipse.jetty.xml.XmlConfiguration.configure(XmlConfiguration.java:288)
        ... 13 more

If I inspect the container it seems that the bundle throwing the exception, "OPS4J Pax Web - Jetty", bundle does not import the org.eclipse.jetty.http.ssl package. Which is probably why the exception occurs.

This is unfortunate because while I don't strictly need SslContextFactory to create an HTTPS connection for pax web. Using SslContextFactory is the way currently recommended by jetty (see https://wiki.eclipse.org/Jetty/Reference/SSL_Connectors for reference). I can still configure HTTPS using the pax properties or using only SslSelectChannelConnector with deprecated methods in jetty.xml however none of these is ideal.

I've tried looking for a way to post this to a pax web forum but there does not seem to be one.

I'm wondering if the Karaf team or users have run into this problem and what they have done to work around it.
Loading...