You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Peter Crowther <Pe...@melandra.com> on 2005/02/11 14:58:50 UTC

URL protocol handler issues

Environment: Tomcat 5.0.28, built from source.

I'm trying to persuade Tomcat to allow me to use a custom URL scheme
('bod3vfs'), both in webapps and in some of the behind-the-scenes setup
- for example, I have a custom HostConfig that examines a virtual file
system.  I've tried the following approaches to getting this integrated;
none of them appear to work.  Ideas welcome!

1) Create the handler in org.bodington.core.protocol.bod3vfs.Handler.
Package that into bodington3.jar; place in server/lib.  Call a static
routine just after startup to amend java.protocol.handler.pkgs to
include org.bodington.core.protocol.  Result: MalformedURLException when
asking for bod3vfs:*.

2) As per 1, but add
-Djava.protocol.handler.pkgs=org.bodington.core.protocol.  Result as 1.

3) Amend DirContextURLStreamHandlerFactory to include the following:

    public URLStreamHandler createURLStreamHandler(String protocol) {
        if (protocol.equals("jndi")) {
            return new DirContextURLStreamHandler();
        } else if (protocol.equals("bod3vfs")) {
            return new org.bodington.core.protocol.bod3vfs.Handler();
        } else {
            return null;
        }
    }

... and ensure that the factory replaces the standard factory before
it's required, in my custom HostConfig (which is successfully loaded
from bodington3.jar).  Result:
java.lang.reflect.InvocationTargetException caused by
java.lang.NoClassDefFoundError:
org/bodington/core/protocol/bod3vfs/Handler at the point that the
runtime attempts to load DirContextURLStreamHandlerFactory.  Note that
the compilation was successful, and that the invoking class has been
loaded successfully from the same jar that contains the handler.  If I
replace the return statement with 'return null',
DirContextURLStreamHandlerFactory loads and runs successfully.

4) Copy the Handler class into catalina.jar and repeat 3.  Same result.

Remy, the original code for DirContextURLStreamHandlerFactory is yours,
I think.  Any particular reason you replaced the factory rather than
setting the packages?

		- Peter

--
Peter Crowther, Director, Melandra Limited
John Dalton House, 121 Deansgate, Manchester M3 2AB
t: +44 (0)161 828 8736  f: +44 (0)161 832 5683

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