Hello,

The locked jar problem with OJB.properties can also be caused by repository descriptors embedded in jar archives. The problem is caused by RepositoryPersistor passing a URL path to InputSource without disabling caching in the corresponding URL connection. The patch is attached below.

-- Ilkka

PS. The public DTD address "http://db.apache.org/ojb/dtds/1.0/repository.dtd"; mentioned in repository.xml comments doesn't seem to work, but "http://db.apache.org/ojb/repository.dtd"; is currently accessible.


Index: RepositoryPersistor.java
===================================================================
RCS file: /home/cvspublic/db-ojb/src/java/org/apache/ojb/broker/metadata/RepositoryPersistor.java,v
retrieving revision 1.24.2.1
diff -u -r1.24.2.1 RepositoryPersistor.java
--- RepositoryPersistor.java 11 Nov 2004 13:57:42 -0000 1.24.2.1
+++ RepositoryPersistor.java 4 Mar 2005 09:09:34 -0000
@@ -27,6 +27,7 @@
import java.io.PrintWriter;
import java.net.MalformedURLException;
import java.net.URL;
+import java.net.URLConnection;
import java.util.Date;


 import org.apache.commons.lang.SerializationUtils;
@@ -258,13 +259,33 @@
         arminw:
         strange, when using 'url.openStream()' argument repository
         could not be parsed
+        ipriha:
+        parser needs a base url to find referenced entities.
         */
         // InputSource source = new InputSource(url.openStream());

-        String pathName = url.toString();
+        String pathName = url.toExternalForm();
         log.info("Building repository from :" + pathName);
         InputSource source = new InputSource(pathName);
-        return readMetadataFromXML(source, targetRepository);
+        URLConnection conn = url.openConnection();
+        conn.setUseCaches(false);
+        conn.connect();
+        InputStream in = conn.getInputStream();
+        source.setByteStream(in);
+        try
+               {
+               return readMetadataFromXML(source, targetRepository);
+               }
+        finally
+               {
+               try
+                       {
+                       in.close();
+                       }
+               catch (IOException x)
+                       {
+                       }
+               }
     }

     /**


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to