You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by e e <da...@gmail.com> on 2013/01/15 18:50:52 UTC

URLStreamHandlerFactory

   - Am trying to understand why WebAppLoader does a
   URL.setURLStreamHandlerFactory().
   - 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.
   - What feature in tomcat will get affected if I set my factory before
   tomcat sets it. (Factory can be set only once).
   - What feature will I lose if I set my factory.

*Note*

   - I cannot change the webapp's code to use the overloaded java.net.URL()
   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)

Sriram.

Re: URLStreamHandlerFactory

Posted by Mark Thomas <ma...@apache.org>.
On 17/01/2013 14:02, e e wrote:
> Can anyone please provide me this information please..... Sorry for being
> persistent!!
> 
> I am still not clear why a URLStreamHandlerFactory is required for JNDI!!!

It isn't.

> I thought Context.lookup() is what the web-apps will do!

They do.

> Why would the web-apps want to use a new URL("jndi://...."); 

They don't.

> Where/why does tomcat have  to use jndi URLs to fetch resources??

Where? Everywhere Tomcat wants to access a web application resource.

Why? Because many years a decision was taken or provide an abstraction
based on the JNDI interface to access resources to support alternative
resource implementations to the standard WAR and directory ones provided
by Tomcat

> Can you please elaborate on "It is because Tomcat uses "jndi://..." for
> handling web application resources".

See above.

Mark


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


Re: URLStreamHandlerFactory

Posted by e e <da...@gmail.com>.
Can anyone please provide me this information please..... Sorry for being
persistent!!

I am still not clear why a URLStreamHandlerFactory is required for JNDI!!!
I thought Context.lookup() is what the web-apps will do! Why would the
web-apps want to use a new URL("jndi://...."); Where/why does tomcat have
to use jndi URLs to fetch resources??

Can you please elaborate on "It is because Tomcat uses "jndi://..." for
handling web application resources".

Sriram.



On Wed, Jan 16, 2013 at 1:50 PM, e e <da...@gmail.com> wrote:

>
> Thanks for the response. I will move to Tomcat-7.
> But, I am still not clear why a URLStreamHandlerFactory is required for
> JNDI!!!
> I thought Context.lookup() is what the web-apps will do! Why would the
> web-apps want to use a new URL("jndi://...."); Where/why does tomcat have
> to use jndi URLs to fetch resources??
>
> Can you please elaborate on "It is because Tomcat uses "jndi://..." for
> handling web application resources".
>
> Sriram.
>
>
>
>
> On Wed, Jan 16, 2013 at 1:18 AM, Mark Thomas <ma...@apache.org> wrote:
>
>> On 15/01/2013 19:09, Christopher Schultz wrote:
>> > Sriram,
>> >
>> > 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
>> > applications.
>>
>> No. It is because Tomcat uses "jndi://..." for handling web
>> application resources.
>>
>> >> 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.
>>
>> Wrong. See above.
>>
>> > 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.
>>
>> Irrelevant to this issue.
>>
>> >> 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[?]
>>
>> Pretty much everything.
>>
>> >> - I cannot change the webapp's code to use the overloaded
>> >> java.net.URL() 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)
>>
>> You need to use Tomcat 7.
>> See https://issues.apache.org/bugzilla/show_bug.cgi?id=26701
>>
>> Mark
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
>

Re: URLStreamHandlerFactory

Posted by e e <da...@gmail.com>.
Thanks for the response. I will move to Tomcat-7.
But, I am still not clear why a URLStreamHandlerFactory is required for
JNDI!!!
I thought Context.lookup() is what the web-apps will do! Why would the
web-apps want to use a new URL("jndi://...."); Where/why does tomcat have
to use jndi URLs to fetch resources??

Can you please elaborate on "It is because Tomcat uses "jndi://..." for
handling web application resources".

Sriram.



On Wed, Jan 16, 2013 at 1:18 AM, Mark Thomas <ma...@apache.org> wrote:

> On 15/01/2013 19:09, Christopher Schultz wrote:
> > Sriram,
> >
> > 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
> > applications.
>
> No. It is because Tomcat uses "jndi://..." for handling web
> application resources.
>
> >> 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.
>
> Wrong. See above.
>
> > 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.
>
> Irrelevant to this issue.
>
> >> 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[?]
>
> Pretty much everything.
>
> >> - I cannot change the webapp's code to use the overloaded
> >> java.net.URL() 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)
>
> You need to use Tomcat 7.
> See https://issues.apache.org/bugzilla/show_bug.cgi?id=26701
>
> Mark
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: URLStreamHandlerFactory

Posted by Mark Thomas <ma...@apache.org>.
On 15/01/2013 19:09, Christopher Schultz wrote:
> Sriram,
> 
> 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 
> applications.

No. It is because Tomcat uses "jndi://..." for handling web
application resources.

>> 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.

Wrong. See above.

> 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.

Irrelevant to this issue.

>> 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[?]

Pretty much everything.

>> - I cannot change the webapp's code to use the overloaded 
>> java.net.URL() 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)

You need to use Tomcat 7.
See https://issues.apache.org/bugzilla/show_bug.cgi?id=26701

Mark

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


Re: URLStreamHandlerFactory

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Sriram,

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
applications.

> 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
handler.

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 
> java.net.URL() 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
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with undefined - http://www.enigmail.net/

iEYEAREIAAYFAlD1qXgACgkQ9CaO5/Lv0PBsrgCcDmBLpydzbk+qmtQ6WvjwysUX
yaYAoJONxXebOMe9sg8cyTb1SqUyFkQN
=YWmA
-----END PGP SIGNATURE-----

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