tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Thomas <ma...@apache.org>
Subject Re: java.protocol.handler.pkgs does not work with Tomcat 7
Date Tue, 18 Nov 2014 08:29:39 GMT
On 17/11/2014 22:47, Ignacio Ocampo wrote:
> Hi all,
> 
> I'm using a third part library for NTLM authentication, one of their
> requeriments is to set: System.setProperty("java.protocol.handler.pkgs",
> "jespa");
> 
> But, it does not take any effect, I see Tomcat 7 source code here:
> 
> https://github.com/apache/tomcat70/blob/051a1dfd4c2943a8e8001c6be88d208cac72faff/java/org/apache/catalina/loader/WebappLoader.java#L561
> 
>         // Register a stream handler factory for the JNDI protocol
>         URLStreamHandlerFactory streamHandlerFactory =
>                 DirContextURLStreamHandlerFactory.getInstance();
>         if (first) {
>             first = false;
>             try {
> *                URL.setURLStreamHandlerFactory(streamHandlerFactory);*
>             } catch (Exception e) {
>                 // Log and continue anyway, this is not critical
>                 log.error("Error registering jndi stream handler", e);
>             } catch (Throwable t) {
>                 ExceptionUtils.handleThrowable(t);
>                 // This is likely a dual registration
>                 log.info("Dual registration of jndi stream handler: "
>                          + t.getMessage());
>             }
>         }
> 
> And I see *URL.setURLStreamHandlerFactory *documentation at:
> https://docs.oracle.com/javase/7/docs/api/java/net/URL.html#setURLStreamHandlerFactory(java.net.URLStreamHandlerFactory)
> 
> public static void setURLStreamHandlerFactory(URLStreamHandlerFactory
> <https://docs.oracle.com/javase/7/docs/api/java/net/URLStreamHandlerFactory.html>
> fac)
> 
> Sets an application's URLStreamHandlerFactory. This method can be called at
> most once in a given Java Virtual Machine.
> 
> The URLStreamHandlerFactory instance is used to construct a stream protocol
> handler from a protocol name.
> I tried set -Djava.protocol.handler.pkgs=jespa in catalina.sh and put my
> jars in jdk/lib, jdk/jre/lib, tomcat/lib, tomcat/webapps/ROOT/WEB-INF/lib,
> but nothing.
> 
> I hope your comments.

Yes, this is a problem that isn't addressed in Tomcat 7.

It is addressed in Tomcat 8 (and 9) where we add a Tomcat specific
factory. This factory avoids the problem of only being able to call
setURLStreamHandlerFactory() once by adding the Tomcat specific factory
which allows additional handler factories to be added.

Mark

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message