Issue Details (XML | Word | Printable)

Key: DERBY-540
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Daniel John Debrunner
Reporter: Daniel John Debrunner
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Derby

Loading databases from jars in the classpath is broken, databases cannot be found.

Created: 26/Aug/05 02:25 AM   Updated: 12/Jul/06 06:43 AM
Return to search
Component/s: Store
Affects Version/s: 10.1.1.0
Fix Version/s: 10.1.2.1, 10.2.1.6

Time Tracking:
Not Specified

Resolution Date: 26/Aug/05 03:13 AM


 Description  « Hide
In converting an old Cloudscape test to ensure changes made for DERBY-538 would not break loading from classes stored in the database when the database itself is in a jar, I discovered that a database cannot be found that is in a jar on the classpath.
Discovered the reason is the StoreFactory implementation for classpath always prepends a leading foward slash to the database name, but this is incorrect (e.g. db7 to /db7). This causes the database not to be found when the classloader is URLClassLoader as the correct path for the service.properties file is db7/services.properties, not /db7/services.properties.

Will add converted test (lang/dbjar.sql)

 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Repository Revision Date User Message
ASF #240111 Thu Aug 25 18:02:57 UTC 2005 djd DERBY-540 Do not prepend database name for classpath databases with leading slash.This causes
databases to be not found when in jar files on the database. Correct the lookup of resources
in the class path storage factory to not use the methods that prepend the current class name,
instead use methods from ClassLoader directly. The leading slash was incorrectly added to avoid
the automatic package prepending performed by Class.getResource.
Removed code that tried to optimise not using the thread context class loader, simply have a
fixed lookup for resources of thread context class loader followed by class loader for Derby/system classloader.
Add lang/dbjar.sql to test databases within a jar and within a jar on the classpath and class loading from such databases.
Files Changed
MODIFY /db/derby/code/trunk/java/engine/org/apache/derby/impl/io/CPStorageFactory.java
MODIFY /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/derbylang.runall
MODIFY /db/derby/code/trunk/java/engine/org/apache/derby/impl/io/CPFile.java
ADD /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/dbjarUtil.java
ADD /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/dbjar.jar
ADD /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/dbjar_app.properties
MODIFY /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/copyfiles.ant
ADD /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/dbjar.sql
ADD /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/dbjar.out

Daniel John Debrunner made changes - 26/Aug/05 02:25 AM
Field Original Value New Value
Assignee Daniel John Debrunner [ djd ]
Daniel John Debrunner added a comment - 26/Aug/05 03:13 AM
Committed revision.

U java\engine\org\apache\derby\impl\io\CPStorageFactory.java
U java\engine\org\apache\derby\impl\io\CPFile.java
A java\testing\org\apache\derbyTesting\functionTests\tests\lang\dbjar_app.properties
A java\testing\org\apache\derbyTesting\functionTests\tests\lang\dbjar.jar
A java\testing\org\apache\derbyTesting\functionTests\tests\lang\dbjar.sql
A java\testing\org\apache\derbyTesting\functionTests\tests\lang\dbjarUtil.java
U java\testing\org\apache\derbyTesting\functionTests\tests\lang\copyfiles.ant
A java\testing\org\apache\derbyTesting\functionTests\master\dbjar.out
U java\testing\org\apache\derbyTesting\functionTests\suites\derbylang.runall
Updated to revision 240111.

Daniel John Debrunner made changes - 26/Aug/05 03:13 AM
Fix Version/s 10.2.0.0 [ 11187 ]
Daniel John Debrunner made changes - 26/Aug/05 03:13 AM
Resolution Fixed [ 1 ]
Status Open [ 1 ] Resolved [ 5 ]
Repository Revision Date User Message
ASF #290301 Mon Sep 19 22:52:19 UTC 2005 djd DERBY-540 Do not prepend database name for classpath databases with leading slash.This causes
databases to be not found when in jar files on the database. Correct the lookup of resources
in the class path storage factory to not use the methods that prepend the current class name,
instead use methods from ClassLoader directly. The leading slash was incorrectly added to avoid
the automatic package prepending performed by Class.getResource.
Removed code that tried to optimise not using the thread context class loader, simply have a
fixed lookup for resources of thread context class loader followed by class loader for Derby/system classloader.
Add lang/dbjar.sql to test databases within a jar and within a jar on the classpath and class loading from such databases.

Merged from trunk revision 240111
Files Changed
ADD /db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/lang/dbjar.jar (from /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/dbjar.jar)
MODIFY /db/derby/code/branches/10.1/java/engine/org/apache/derby/impl/io/CPStorageFactory.java
MODIFY /db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/lang/copyfiles.ant
MODIFY /db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/suites/derbylang.runall
ADD /db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/lang/dbjar.sql (from /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/dbjar.sql)
MODIFY /db/derby/code/branches/10.1/java/engine/org/apache/derby/impl/io/CPFile.java
ADD /db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/lang/dbjarUtil.java (from /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/dbjarUtil.java)
ADD /db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/lang/dbjar_app.properties (from /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/dbjar_app.properties)
ADD /db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/dbjar.out (from /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/dbjar.out)

Daniel John Debrunner added a comment - 20/Sep/05 07:54 AM
Merged 240111 into trunk as revision 290301

Daniel John Debrunner made changes - 20/Sep/05 07:54 AM
Fix Version/s 10.1.2.0 [ 12310270 ]
Deepa Remesh made changes - 30/Sep/05 02:36 AM
Fix Version/s 10.1.1.1 [ 12310332 ]
Daniel John Debrunner made changes - 12/Jul/06 06:43 AM
Status Resolved [ 5 ] Closed [ 6 ]