Fortunately, you can specify a URLStreamHandlerFactory for the 
entire system, which can parse the java.protocol.handler.pkgs itself and 
load things from the context class loader...  Or worst case, just pass in 
the URLStreamHandler when you create the URL...

Aaron

On Wed, 9 Oct 2002, David Blevins wrote:
> Hey Guys,
> 
> I'm stepping through the whole process.  I also get the
> java.net.MalformedURLException: unknown protocol: resource
> 
> This is extremely, *extremely*, strange as the
> java.protocol.handler.pkgs is definitely set.  And as I write this very
> sentence, something occurs to me...
> 
>       THIS IS A STUPID CLASSPATH PROBLEM
> 
> Darn it. Ok, let me go check for sure.... Ok, yep, there it is.  If you
> happen to have the JDK 1.3.1 source handy, open up java.net.URL and go
> to line 923, you'll see this:
> 
>       cls = Class.forName(clsName);
> 
> The java.net.URL class expects all protocol handlers to be in the system
> level classpath, but Tomcat doesn't put anything there it uses a "child"
> classloader that the VM can't see.  This explains another problem
> someone was having making an OpenEJB Avalon block, Avalon also uses
> their own classloader to load libraries.
> 
> The question that immediately comes to my mind is "Why doesn't the same
> problem occur when the JVM tries to create the JNDI
> InitialContectFactory?"  Those are also factory-type class names
> specified as properties that must be loaded by the JVM and instantiated.
> Let me take a look and see why it works there.... Ok, there it is.  So,
> very inconsistent!  Look at this, this is how they (Sun) load JNDI
> factories:
> 
>       ClassLoader cl = Thread.currentThread().getContextClassLoader();
>       return Class.forName(className, true, cl);
> 
> This is in com.sun.naming.internal.VersionHelper12 in the JNDI source
> code -- you have to download the J2EE 1.3 source code to get that file.
> So, here they (Sun) are not using the system classpath to load the
> factory but using whatever classloader the application may be using.
> Obviously this is much smarter.  
> 
> So to sum up:
>  -- When loading URLStreamHandler implementations, Sun looks for the
> class in the system classpath.  Tomcat doesn't load anything in the
> system classpath, so the URLStreamHandler can't be found and you get a
> misleading exceptions saying that the protocol is unknown.
> 
> My second point:
>  -- IMO, this is a VM bug.  Sun should be loading
> java.net.URLStreamHandler implementations using the classloader
> associated with the thread.  This is exactly what they do for loading
> JNDI InitialContextFactory implementations and (now that I think of it)
> is also what they do in the java.io package for object serialization. 
> 
> Action:
>  -- I'm definitely going to file a VM bug report.  I know of an easy
> workaround for this and will put that in right away.  That will ship
> with OpenEJB 0.8.4.  Looks like that release might come out a little
> sooner that expected.
> 
> In the meantime, you can either:
>  1. Hack Tomcat's setclasspath.sh or setclasspath.bat to include the
> openejb-0.8.3.jar in the classpath.  This jar holds the class Sun
> expects to be in the system classpath. 
>  2. Or use Resin
> 
> 
> Well, that was interesting.  You learn something new everyday.
> 
> Good night all,
> David Blevins
> 
> 
> 
> 
> > -----Original Message-----
> > From: [EMAIL PROTECTED] 
> > [mailto:[EMAIL PROTECTED]] On Behalf 
> > Of Gopal Mukkamala
> > Sent: Tuesday, October 08, 2002 7:32 PM
> > To: [EMAIL PROTECTED]
> > Subject: [OpenEJB-user] Tomcat :EJB
> > 
> > 
> > Root cause: java.net.MalformedURLException: unknown
> > protocol: resource
> > 
> > Since the last attempt I copied all jar files
> > on to WEB-INF/lib
> > directory that seems to have suppressed all 
> > Class not found errors.
> > 
> http://desistar.no-ip.org:8080/examples/callejb.txt
> 
> It is basically giving MalformedURL ?
> 
> Any thoughts will be quiet helpful.
> 
> Regards
> Gopal
> 
> 
> 
> 
> __________________________________________________
> Do you Yahoo!?
> Faith Hill - Exclusive Performances, Videos & More
> http://faith.yahoo.com
> 
> 
> -------------------------------------------------------
> This sf.net email is sponsored by:ThinkGeek
> Welcome to geek heaven.
> http://thinkgeek.com/sf _______________________________________________
> http://OpenEJB.sf.net
> OpenEJB-user mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/openejb-user
> 
> 
> 
> -------------------------------------------------------
> This sf.net email is sponsored by:ThinkGeek
> Welcome to geek heaven.
> http://thinkgeek.com/sf
> _______________________________________________
> http://OpenEJB.sf.net
> OpenEJB-user mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/openejb-user
> 



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
http://OpenEJB.sf.net
OpenEJB-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/openejb-user

Reply via email to