Hi, I' ve a problem defining under Tomcat 4.0.x my own protocol handler setting the property "java.protocol.handler.pkgs"
(URL class cannot load URLStreamHandlers located in the "common/lib" directory). My protocol interacts with all my webapps allowing them to add their handlers at runtime ( for example: protocolname://handler1/ , protocolname://handler2/ ...). I' ve implemented this with a singletone object (queryied by my implementation of the URLStreamHandler Class) that holds the associations handler_name->component_instance. Under Tomcat 4 i had to put my protocol jar in the common/lib directory to access the same singletone object from all webapps. Then i've encountered some problems registering the protocol, before with "URL.setURLStreamHandlerFactory" because the factory was already defined by Tomcat, and after with the property "java.protocol.handler.pkgs". One month ago i solved the problem modifying Tomcat 4.0.1 to not register the factory if the package "org.apache.naming.resources" is specified in the property "java.protocol.handler.pkgs", then i sent the patch to tomcat-dev list but no reply Now, having the same problem with Tomcat 4.0.2 b1, i retried to declare my protocol setting the "java.protocol.handler.pkgs" property but it still doesn't work. Debugging the application, i found that the ClassLoader used by java.net.URL cannot find my URLStreamHandler implementation that is in the common/lib. This is the "java.net.URL" code that should instantiate the URLStreamHandler: (packagePrefix is the package found in the property "java.protocol.handler.pkgs" and protocol, the requested protocol name ) <code> try { String clsName = packagePrefix + "." + protocol + ".Handler"; Class cls = null; try { cls = Class.forName(clsName); } catch (ClassNotFoundException e) { ClassLoader cl = ClassLoader.getSystemClassLoader(); if (cl != null) { cls = cl.loadClass(clsName); } } if (cls != null) { handler = (URLStreamHandler)cls.newInstance(); } } catch (Exception e) { // any number of exceptions can get thrown here } </code> I think it could be a ClassLoader bug. Thanks for patience :-) Thanks in advance for any help. Ciao, Alberto. P.S. Here follows how i patched Tomcat 4.0.1 to not register the URLStreamHandlerFactory if the package "org.apache.naming.resources" is specified in the property "java.protocol.handler.pkgs". ------------------------------------------------------------------------- I' ve modified with success my tomcat 4.01 to allow webapps to register their protocol handler in this way: in WebappLoader.java and in StandardLoader.java before setting the factory i check if the property "java.protocol.handler.pkgs" contains the package "org.apache.naming.resources", in this case it' s not necessary to set the Factory because the URL class will use, for the jndi protocol, the class named: "org.apache.naming.resources" + ".jndi" + ".Handler"; if the proprty isn't set i register the Factory. Then, i' ve modified catalina.sh setting CATALINA_OPTS with value: "-Djava.protocol.handler.pkgs=org.apache.naming.resources" ------------------------------------------------------------------------- -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>