Issue Details (XML | Word | Printable)

Key: DERBY-4126
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Rick Hillegas
Reporter: Rick Hillegas
Votes: 0
Watchers: 0
Operations

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

You can't invoke a table function which is stored in a jar file inside the database

Created: 27/Mar/09 01:56 PM   Updated: 13/Apr/09 11:05 PM
Component/s: SQL
Affects Version/s: 10.4.1.3, 10.4.2.0, 10.5.1.1, 10.6.0.0
Fix Version/s: 10.4.2.1, 10.5.1.1, 10.6.0.0

Time Tracking:
Not Specified

File Attachments:
  Size
File Licensed for inclusion in ASF works derby-4126-01-aa-useSessionClassloader.diff 2009-03-27 03:19 PM Rick Hillegas 6 kB
File Licensed for inclusion in ASF works derby-4126-01-ab-useSessionClassloader.diff 2009-03-27 07:02 PM Rick Hillegas 6 kB
Issue Links:
Reference

Resolution Date: 31/Mar/09 04:49 PM


 Description  « Hide
You get a ClassNotFoundException when you try to invoke a table function which lives in a jar file stored inside the database. This is because FromVTI.implementsDerbyStyleVTICosting() looks up the class using Class.forName() rather than using the session classloader. A similar bug is in FromVTI.getVTICosting(). This bug was reported by Krzysztof N in the following user list thread: http://www.nabble.com/Uinable-to-use-Table-function-due-to-java.lang.ClassNotFoundException--while-class-is-clearly-reachable..-td22478383.html#a22699492

 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Rick Hillegas added a comment - 27/Mar/09 03:19 PM
Attaching derby-4126-01-aa-useSessionClassloader.diff. This patch causes Derby to lookup VTI optimizer overrides using the session's classloader. This fixes the bug. I will run regression tests now.

Touches the following files:

M java/engine/org/apache/derby/impl/sql/compile/FromVTI.java

Use the session class loader when looking for optimizer overrides.


A java/testing/org/apache/derbyTesting/functionTests/tests/lang/dummy_vti.jar
M java/testing/org/apache/derbyTesting/functionTests/tests/lang/DatabaseClassLoadingTest.java

New test to verify that this fixes the problem.

Rick Hillegas added a comment - 27/Mar/09 07:02 PM
Attaching second rev of the patch. The regression tests turned up a follow-on problem: in order to determine if the VTI class implements VTICosting, we need to get the VTICosting class from the same classloader as the table function class. Running tests again...

Rick Hillegas added a comment - 27/Mar/09 09:42 PM
Tests ran cleanly for me except for the heisenbug in the stress-multi tests. Committed second rev of the patch at subversion revision 759360.

Rick Hillegas added a comment - 27/Mar/09 09:49 PM
Ported 759360 from main to 10.5 branch at subversion revision 759363.

Rick Hillegas added a comment - 30/Mar/09 02:17 PM
Ported 759360 from main to 10.4 branch at subversion revision 759978.

Rick Hillegas added a comment - 31/Mar/09 04:49 PM
Krzysztof, who reported this bug, says that the fix works for him. Closing this bug.