Skip to main content

java.protocol.handler.pkgs Strikes Back

Posted by garysweaver on August 6, 2008 at 1:17 PM PDT

In last last couple of months working with a custom portlet that uses Apache CXF (2.1.1) in uPortal, I was getting a wierd issue:
Caused by: java.lang.ClassCastException:
        at org.apache.cxf.transport.https.HttpsURLConnectionFactory.createConnection(
        at org.apache.cxf.transport.http.HTTPConduit.prepare(
        at org.apache.cxf.interceptor.MessageSenderInterceptor.handleMessage(
        at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(
        at org.apache.cxf.endpoint.ClientImpl.invoke(
        at org.apache.cxf.endpoint.ClientImpl.invoke(
        at org.apache.cxf.frontend.ClientProxy.invokeSync(
        at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(
        ... 36 more

This occurred with Apache CXF v2.1.1 where it was doing:

        HttpsURLConnection connection =
            (HttpsURLConnection) (proxy != null
                                   ? url.openConnection(proxy)
                                   : url.openConnection());

It turns out that in uPortal, there is a configuration file "uPortal/WEB-INF/classes/properties/" that contained the following:

  # Protocol handler for https connections.  Set by default to the one provided with
  # Sun's JSSE - change to use your local JSSE implementation

This in turn is used by the following code in a static block in org.jasig.portal.utils.ResourceLoader:

  static {
    f = DocumentBuilderFactory.newInstance();
      String handler = PropertiesManager.getProperty("org.jasig.portal.utils.ResourceLoader.HttpsHandler");
      if ((System.getProperty("java.protocol.handler.pkgs") != null) &&
        handler = handler+"|"+System.getProperty("java.protocol.handler.pkgs");
    catch(Exception e){
      log.error("Unable to set HTTPS Protocol handler", e);

As you can see it puts what I think is the old wrong package (at least for Java 1.4+) "" at the first of the list of handlers. Doing this is not only unnecessary but can cause problems in Java 1.4+ from what I've read and have now experienced.

While you can try removing the System property "java.protocol.handler.pkgs" in your code, that is a bad idea for obvious reasons (you're affecting the whole JVM, you don't know when that property will be read necessarily, etc.) and it isn't guaranteed to work. The best thing to do is to find the offending code or config and axe it so that it doesn't set old sun protocol handlers in newer code.

So in short, the right way to fix this was to change uPortal/WEB-INF/classes/properties/ to have:


and then restart.

Unfortunately it looks like this property is being set also in the latest uPortal distribution (v3.1) also. If uPortal v3 (and latest version of v2 for that matter) aren't meant to support Java versions under v1.3, should the default properties list the property value of this as (blank) by default? I emailed the uPortal guys, so I guess we'll find out.

Related Topics >>