dev@glassfish.java.net

Re: Need some input MalformedURLException: Unknown protocol:, jndi

From: Jan Luehe <Jan.Luehe_at_Sun.COM>
Date: Fri, 05 Sep 2008 16:38:45 -0700

Hi Bhakti,

On 09/ 5/08 02:27 PM, Jan Luehe wrote:
> On 09/ 5/08 12:02 PM, Bhakti Mehta wrote:
>> Experts,
>> I am trying to get a simple jaxws deployed and run into the following
>> stacktrace
>> java.net.MalformedURLException: Unknown protocol:
>> jndi
>
> Looks like the "org.apache.naming.resources.jndi.Handler"
> URLStreamHandler
> is not getting registered.
>
> Investigating ...

Shing-Wai and I investigated this. Here is our finding:

The web container (Tomcat code) has always relied on being able to
register a
URLStreamHandlerFactory for the "jndi" protocol, by calling
URL.setURLStreamHandlerFactory(). This call is honored by the Java
runtime only when it is called for the first time. Any subsequent
attempt to register a URLStreamHandlerFactory results in a
java.lang.Error (with message "factory already defined") being thrown.

It so happened that in v2, the web container was the first (and only?)
caller of URL.setURLStreamHandlerFactory(). However, in v3, it is
being preempted by Felix, which is registering its own
URLStreamHandlerFactory.

This why URLs with a protocol of "jndi" are considered "malformed"
in v3 (because the required URLStreamHandlerFactory failed to be
registered).

In v3, we will have to leverage one of the alternative mechanisms
provided by the Java runtime to register a custom URL protocol:
Calling URL.setURLStreamHandlerFactory() is no longer an option.

Thanks for reporting this issue!


Jan