Re: [OpenMap Users] BinaryFile and JNLPClassLoader issue

From: Tore Halset <halset_at_pvv.ntnu.no>
Date: Thu, 17 Jun 2010 13:22:06 +0200

Hello.

I am seeing this as well. Have you found a solution to this problem?

 - Tore.

On Jun 8, 2010, at 14:20 , Carsten Ø. Madsen wrote:

> Hello
>
> I have an issue using the BinaryFile class to load shape files in signed jar files under JNLP. Most of the time it works but sometimes I get a JNLP security warning about mixing signed and unsigned code (see [1]).
>
> The BinaryFile class does:
>
> url = Thread.currentThread()
> .getContextClassLoader()
> .getResource(name);
>
> and it then tries to decompose the url to read the contents. However [2] says that the correct way to access a resource under JNLP is to use getResourceAsStream:
>
> "Access the ClassLoader being used with:
> ClassLoader cl = Thread.getCurrent().getContextClassLoader();
>
>
> ClassLoader.getResource() returns a URL, but any code that assumes the URL is a JarURL to a FileURL, and then tries to decompose that FileURL to find the underlying file path will fail. The correct way to access resources is to use getResourceAsStream() which will return the correct content whatever type of ClassLoader is used to access the resource. If the resource is already cached, the contents of the resource will be returned from the cache directly, so there won't be extra network connections to the resource itself."
> So should BinaryFile have a check to see of the class loader is a JNLP loader and then use getResourceAsStream?
> I'm guessing that the BinaryFile fails (provokes security warning) when getResource returns something that is cached.
> [1] http://java.sun.com/javase/6/docs/technotes/guides/jweb/mixed_code.html
>
> [2] http://java.sun.com/javase/6/docs/technotes/guides/jweb/deployment_advice.html#ClassLoader_and_Resources
>
> BR
> Carsten
>
>
>

--
[To unsubscribe to this list send an email to "majdart_at_bbn.com"
with the following text in the BODY of the message "unsubscribe openmap-users"]
Received on Thu Jun 17 2010 - 07:22:32 EDT

This archive was generated by hypermail 2.3.0 : Tue Mar 28 2017 - 23:25:09 EDT