> Hey Folks,
>
> this is a follow-up question to a post made by Kavi on 6/25 regarding
> running Tomcat on HP's Core Services Framework.
>
> We encountered a problem with a dual URLStreamHandlerFactory - Catalina
> installs its own, in order to provide the jndi: URL for e.g. reading
> WEB-INF/web.xml - alas Core Services Framework has also installed its own
> factory, in order provide similar capabilities. We have tried eliminating
> our own, in which case everything works as expected; if we extend the
> DirContextURLStreamHandler and place it in a package we understand, we can
> actually instantiate the DirContextURLStreamHandler (extension) and
startup
> etc. seems to be fine, except that the installation of the context- and
> session listeners fail... my guess is that because Catalina fails to
> install its factory (because we've already installed our own) it doesn't
> complete the initialization of the DirContext stuff.
No, the failure is silently caught and ignored. The CL is then failing
because it is using URLs based on that protocol.
> Is there a way to
> provide this service for Catalina or is it a requirement that it gets to
> install its own factory ?
In the newest builds, it's not a requirement anymore, but some URL
manipultation oprations will fail if it's not properly set. Something like :
new URL("jar:" + servletContext.getResource("/foo.jar").toString() + "!/")
If the factory you set returns a handler for protocol "jndi", it should
work, like the stream handler factory does :
/**
* Creates a new URLStreamHandler instance with the specified protocol.
* Will return null if the protocol is not <code>jndi</code>.
*
* @param protocol the protocol (must be "jndi" here)
* @return a URLStreamHandler for the jndi protocol, or null if the
* protocol is not JNDI
*/
public URLStreamHandler createURLStreamHandler(String protocol) {
if (protocol.equals("jndi")) {
return new DirContextURLStreamHandler();
} else {
return null;
}
}
> We realize that only one factory can be installed
> and since - in this scenario - we are the "host" or services provider it
> would be natural for us to provide this; we also realize that Catalina
> probably wasn't written with this in mind, but we'd be interested in
finding
> out whether or not this is doable.
>
> (We're currently working with Tomcat 4.0 beta 5).
You should upgrade to one of the latest builds, and work from there. The CL
was improved a lot, and should now be much more robust (and it doesn't rely
on URLs anymore).
I added a protocol Hanlder for the custom protocol Catalina is using. You
can now also try to set it using the java.protocol.handler.pkgs system
property, and add the "org.apache.naming.resources" package to it. I didn't
try using that yet, so I can't gurantee it would work.
Remy