tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <>
Subject Re: URLStreamHandlerFactory
Date Tue, 15 Jan 2013 19:09:44 GMT
Hash: SHA256


On 1/15/13 12:50 PM, e e wrote:
> [I a]m trying to understand why WebAppLoader does a 
> URL.setURLStreamHandlerFactory().

Presumably, it's important to handle URLs in a custom way for web

> I see that a protocol handler is being set for "jndi://" protocol. 
> Our apps' do NOT use JNDI urls. I believe tomcat 6 has NOT used
> the jndi url anywhere in its codebase.

Tomcat includes a lightweight JNDI that can be used for things like JDBC
DataSources. So, if you configure a DataSource, your webapp will be able
to fetch it using JNDI.

> What [features] in tomcat will get affected if I set my factory 
> before tomcat sets it[?] ([note:] Factory can be set only once). -
> What [features] will I lose if I set my factory[?]

Presumably, you won't be able to access Tomcat's JNDI stuff. If you
don't use it, you are probably safe to register your own URL stream

The code that calls URl.setURLStreamHandlerFactory does tolerate
failure, and is documented to be "not critical".

> *Note*
> - I cannot change the webapp's code to use the overloaded 
> which takes a URLStreamHandler as an argument.
> (Will require code changes across 50 applications) - I cannot set
> the "*java.protocol.handler.pkgs*" as these classes must be present
> in the system classpath. (Classloader hierarchy of our app-server
> makes it difficult) (We run tomcat as one of the components in our
> server) (Similar to any j2ee server)

I believe the WebappLoader only runs the
URL.setURLStreamHandlerFactory call a single time when it starts up.
At that point, your webapp's code will not be available to any
ClassLoader. So, if you need to load your own code for a
URLStreamHandlerFactory, you're going to need to move it out of your
webapp, anyway. Consider packaging your factory separately and
including it in CATALINA_HOME/endorsed directory which should end up
being a part of the boot classpath.

- -chris
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools -
Comment: Using GnuPG with undefined -


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message