db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ilkka Priha <impr...@surfeu.fi>
Subject OJB.properties may lock web app jars
Date Fri, 04 Mar 2005 07:32:47 GMT

Currently, OJB loads the OJB.properties file by getting an input stream from the 
corresponding URL. However, if the properties file is embedded in a jar archive, 
this method locks the corresponding jar and prevents it from being removed 
during undeployment of a web application (at least in Sun jdk under Windows). 
Some web containers (e.g. Tomcat) have non-standard configuration options to 
handle jar resources in a specific way to prevent locking, but a more general 
solution is to disable caching in the URL connection before opening the input 
stream. The corresponding patch is attached below.

Another solution would be to apply the ClassLoader.getResourceAsStream() method 
instead of the ClassLoader.getResource() method currently provided by 
ClassHelper. This would allow the class loader to provide a non-locking stream.

LoggingConfiguration applies the latter by getting the class loader from 
ClassHelper and calling directly its getResourceAsStream() method.

-- Ilkka

RCS file: 
retrieving revision 1.15
diff -u -r1.15 ConfigurationAbstractImpl.java
--- ConfigurationAbstractImpl.java	16 Jun 2004 20:34:22 -0000	1.15
+++ ConfigurationAbstractImpl.java	4 Mar 2005 07:16:45 -0000
@@ -25,6 +25,7 @@
  import java.io.FileNotFoundException;
  import java.io.InputStream;
  import java.net.URL;
+import java.net.URLConnection;
  import java.util.Properties;
  import java.util.StringTokenizer;

@@ -426,7 +427,10 @@

              logger.info("Loading OJB's properties from file " + url);

-            InputStream strIn = url.openStream();
+            URLConnection conn = url.openConnection();
+            conn.setUseCaches(false);
+            conn.connect();
+            InputStream strIn = conn.getInputStream();


To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org

View raw message