Thanks Jim!
I'd really like to see this in HiveMind!
Marcus

> -----Original Message-----
> From: Jimr [mailto:[EMAIL PROTECTED] 
> Sent: Friday, December 01, 2006 12:28 AM
> To: user@hivemind.apache.org
> Subject: HiveMind 1.1.1 / jar locking / XMLResourceProcessor
> 
> 
> I am writing this to document a resolution to a problem I 
> have found while running HiveMind within a servlet container 
> on Windows and the way that HiveMind searches for xml files 
> within jars on the classpath (hivemodule.xml, etc)
> 
> This is specific to windows, and its file locking behaviour.
> 
> Environment: Windows XP SP2, JDK 1.5.0_05, HiveMind 1.1.1, 
> Tomcat 5.5.12
> 
> Problem: When undeploying a webapp that uses HiveMind, the 
> Hivemind-1.1.1.jar, Hivemind-lib-1.1.1.jar (and any other 
> jars that contain Hivemind module descriptors) within the 
> webapp are locked and cannot be deleted. This results in a 
> failure to undeploy the webapp. If the servlet container 
> (Tomcat) is shut down, the lock is released and the jars can 
> be deleted.
> 
> XMLResourceProcessor involvement: This class appears to be 
> involved in searching for module descriptors on the classpath 
> using a url. However it does not set caching to false before 
> doing the url.openStream() call. This means that all the jars 
> that it opens get locked by windows.
> 
> Root cause: Jar access using a URL with caching enabled. See:
> [url]http://forum.springframework.org/archive/index.php/t-1951
6.html[/url]
> [url]http://tomcat.apache.org/faq/windows.html#lock[/url]
> 
> Resolution:
> Make sure the following code is ran before instantiating 
> HiveMind (can use ServletContextListener for example):
> [code]
>     try
>    {
>       if(System.getProperty("os.name").contains("Windows"))
>          new
> URL("http://This-is-just-to-get-the-URLConnection";).openConnec
tion().setDefaultUseCaches(false);
>    }
>    catch (IOException e)
>    {
>       e.printStackTrace();
>    }
> [/code]
> 
> This is a vm-wide setting so it will affect all url 
> connections. Why isn't this code cleaner? See:
> [url]http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4851466[/url]
> [url]http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4405789[/url]
> 
> I hope this helps anyone else in the same situation!
> Maybe the code could also be in HiveMind itself? I'll leave 
> that to the dev team.
> There are three files in total that contain this type of code:
> XMLResourceProcessor.java, MessageFinderImpl.java, and 
> URLResource.java
> 
> Jim
> --
> View this message in context: 
> http://www.nabble.com/HiveMind-1.1.1---jar-locking---XMLResour
ceProcessor-tf2735127.html#a7630408
> Sent from the Hivemind - User mailing list archive at Nabble.com.
> 
> 

Reply via email to