You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hivemind.apache.org by Jimr <ji...@codesilver.ca> on 2006/12/01 00:28:17 UTC
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-19516.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").openConnection().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---XMLResourceProcessor-tf2735127.html#a7630408
Sent from the Hivemind - User mailing list archive at Nabble.com.
Re: HiveMind 1.1.1 / jar locking / XMLResourceProcessor
Posted by Jimr <ji...@codesilver.ca>.
I like this approach, using "setUseCaches" on each URLConnection, because it
limits the setting to the URL object in question, and that way HiveMind will
not go changing a vm-wide property that may affect other applications.
I chose "setDefaultUseCaches" myself because that way I can avoid modifying
HiveMind, and it works for all the other 20 or so jars I am using! :-)
It would probably be a good idea to profile this change in order to test for
any performance hit the change may cause.
Jim
Achim Hügen wrote:
>
> I would suggest to fix it in all places where urls are used for opening
> a stream. That wouldn't limit the patch to web applications.
>
> As far as I understand we must modify the code
> in XMLResourceProcessor, MessageFinderImpl, and URLResource.
> Before:
>
> URL url = resource.getResourceURL();
> return new InputSource(url.getInputStream());
>
> After:
> URL url = resource.getResourceURL();
> URLConnection conn = url.openConnection();
> conn.setUseCaches(false);
> return new InputSource(conn.getInputStream());
>
> Achim
>
--
View this message in context: http://www.nabble.com/HiveMind-1.1.1---jar-locking---XMLResourceProcessor-tf2735127.html#a7648169
Sent from the Hivemind - User mailing list archive at Nabble.com.
Re: HiveMind 1.1.1 / jar locking / XMLResourceProcessor
Posted by Achim Hügen <ac...@gmx.de>.
I would suggest to fix it in all places where urls are used for opening
a stream. That wouldn't limit the patch to web applications.
As far as I understand we must modify the code
in XMLResourceProcessor, MessageFinderImpl, and URLResource.
Before:
URL url = resource.getResourceURL();
return new InputSource(url.getInputStream());
After:
URL url = resource.getResourceURL();
URLConnection conn = url.openConnection();
conn.setUseCaches(false);
return new InputSource(conn.getInputStream());
Achim
Am Fri, 01 Dec 2006 10:59:33 +0100 schrieb Knut Wannheden
<kn...@gmail.com>:
> Hi Jim,
>
> Thanks for the detailed problem description. I suppose we could add
> this piece of code to the HiveMindFilter class. Other opinions?
>
> --knut
>
> On 12/1/06, Jimr <ji...@codesilver.ca> wrote:
>>
>> 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-19516.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").openConnection().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---XMLResourceProcessor-tf2735127.html#a7630408
>> Sent from the Hivemind - User mailing list archive at Nabble.com.
>>
>>
Re: HiveMind 1.1.1 / jar locking / XMLResourceProcessor
Posted by Knut Wannheden <kn...@gmail.com>.
Hi Jim,
Thanks for the detailed problem description. I suppose we could add
this piece of code to the HiveMindFilter class. Other opinions?
--knut
On 12/1/06, Jimr <ji...@codesilver.ca> wrote:
>
> 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-19516.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").openConnection().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---XMLResourceProcessor-tf2735127.html#a7630408
> Sent from the Hivemind - User mailing list archive at Nabble.com.
>
>
RE: HiveMind 1.1.1 / jar locking / XMLResourceProcessor
Posted by Ma...@bmw.ch.
Thanks Jim!
I'd really like to see this in HiveMind!
Marcus
> -----Original Message-----
> From: Jimr [mailto:jim-nabble@codesilver.ca]
> 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.
>
>