db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Krzysztof N <yaz...@gmail.com>
Subject Re: Unable to use Table function due to java.lang.ClassNotFoundException while class is clearly reachable..
Date Wed, 25 Mar 2009 11:03:55 GMT

Hello Rick,
Thank you for the response, below is the log for values  and then select
calls:

009-03-25 10:41:58.336 GMT Thread[SQL Execution Thread 1,6,main] (XID =
1819), (SESSIONID = 0), (DATABASE =data/surveys/db), (DRDAID = null), Begin
compiling pre
pared statement: values getTSValuesEmpty() :End prepared statement
2009-03-25 10:41:58.340 GMT Thread[SQL Execution Thread 1,6,main] (XID =
1819), (SESSIONID = 0), (DATABASE = data/surveys/db), (DRDAID = null), End
compiling prepa
red statement: values getTSValuesEmpty() :End prepared statement
2009-03-25 10:41:58.342 GMT Thread[SQL Execution Thread 1,6,main] (XID =
1819), (SESSIONID = 0), (DATABASE = data/surveys/db), (DRDAID = null),
Executing prepared 
statement: values getTSValuesEmpty() :End prepared statement
2009-03-25 10:41:58.344 GMT Thread[SQL Execution Thread 1,6,main] (XID =
1819), (SESSIONID = 0), values getTSValuesEmpty() ******* Row ResultSet:
Number of opens = 1
Rows returned = 1
        constructor time (milliseconds) = 0
        open time (milliseconds) = 0
        next time (milliseconds) = 0
        close time (milliseconds) = 0
        optimizer estimated row count:            1.00
        optimizer estimated cost:            0.00


And 
select * from table ( getTSValuesEmpty() ) t;
<log>
2009-03-25 10:43:57.568 GMT Thread[SQL Execution Thread 1,6,main] (XID =
1819), (SESSIONID = 0), (DATABASE = data/surveys/db), (DRDAID = null), Error
compiling prepared statement: select * from 
table ( getTSValuesEmpty() ) t :End prepared statement
2009-03-25 10:43:57.568 GMT Thread[SQL Execution Thread 1,6,main] (XID =
1819), (SESSIONID = 0), (DATABASE = data/surveys/db), (DRDAID = null),
Cleanup action starting
2009-03-25 10:43:57.568 GMT Thread[SQL Execution Thread 1,6,main] (XID =
1819), (SESSIONID = 0), (DATABASE = data/surveys/db), (DRDAID = null),
Failed Statement is: select * from table ( getTSValuesEmpty() ) t
ERROR 38000: The exception 'java.lang.ClassNotFoundException:
gaia.cu7.dal.DerbyBlobTableFunction' was thrown while evaluating an
expression.
        at
org.apache.derby.iapi.error.StandardException.newException(Unknown Source)
        at
org.apache.derby.iapi.error.StandardException.unexpectedUserException(Unknown
Source)
        at
org.apache.derby.impl.sql.compile.FromVTI.implementsDerbyStyleVTICosting(Unknown
Source)
        at org.apache.derby.impl.sql.compile.FromVTI.bindVTITables(Unknown
Source)
        at org.apache.derby.impl.sql.compile.FromList.bindTables(Unknown
Source)
        at
org.apache.derby.impl.sql.compile.SelectNode.bindNonVTITables(Unknown
Source)
        at
org.apache.derby.impl.sql.compile.DMLStatementNode.bindTables(Unknown
Source)
        at org.apache.derby.impl.sql.compile.DMLStatementNode.bind(Unknown
Source)
        at
org.apache.derby.impl.sql.compile.CursorNode.bindStatement(Unknown Source)
        at org.apache.derby.impl.sql.GenericStatement.prepMinion(Unknown
Source)
        at org.apache.derby.impl.sql.GenericStatement.prepare(Unknown
Source)
        at
org.apache.derby.impl.sql.conn.GenericLanguageConnectionContext.prepareInternalStatement(Unknown
Source)
        at org.apache.derby.impl.jdbc.EmbedStatement.execute(Unknown Source)
        at org.apache.derby.impl.jdbc.EmbedStatement.executeQuery(Unknown
Source)
...
Caused by: java.lang.ClassNotFoundException:
gaia.cu7.dal.DerbyBlobTableFunction
        at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:316)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:374)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:169)
        ... 17 more
============= begin nested exception, level (1) ===========
java.lang.ClassNotFoundException: gaia.cu7.dal.DerbyBlobTableFunction
        at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:316)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:374)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:169)
        at
org.apache.derby.impl.sql.compile.FromVTI.implementsDerbyStyleVTICosting(Unknown
Source)
        at org.apache.derby.impl.sql.compile.FromVTI.bindVTITables(Unknown
Source)
        at org.apache.derby.impl.sql.compile.FromList.bindTables(Unknown
Source)
        at
org.apache.derby.impl.sql.compile.SelectNode.bindNonVTITables(Unknown
Source)
        at
org.apache.derby.impl.sql.compile.DMLStatementNode.bindTables(Unknown
Source)
        at org.apache.derby.impl.sql.compile.DMLStatementNode.bind(Unknown
Source)
        at
org.apache.derby.impl.sql.compile.CursorNode.bindStatement(Unknown Source)
        at org.apache.derby.impl.sql.GenericStatement.prepMinion(Unknown
Source)
        at org.apache.derby.impl.sql.GenericStatement.prepare(Unknown
Source)
        at
org.apache.derby.impl.sql.conn.GenericLanguageConnectionContext.prepareInternalStatement(Unknown
Source)
        at org.apache.derby.impl.jdbc.EmbedStatement.execute(Unknown Source)
        at org.apache.derby.impl.jdbc.EmbedStatement.executeQuery(Unknown
Source)
...
============= end nested exception, level (1) ===========
Cleanup action completed
</log>


plus in the log there are two lines when calling 'values' indicating both
missing classes are recognized:

Loaded gaia.cu7.dal.DerbyBlobTableFunction from database jar
"APP"."VariFramework"
...
Loaded gaia.cu7.dal.Cu7ResultSetTemplate from database jar
"APP"."VariFramework"
...

I attached my dummy implementation of ResultSet, dependencies are really
basic.

http://www.nabble.com/file/p22699329/Cu7ResultSetTemplate.java
Cu7ResultSetTemplate.java 

Best regards,
Krzysztof





Rick Hillegas-2 wrote:
> 
> Hi Krzysztof,
> 
> Is there a full stack trace in derby.log which you could include? The 
> SQL state 38000 appears when Derby wraps an exception originally thrown 
> by user-written code. Is it possible that the execution logic of your 
> ResultSet references a class which is not present in the jar file you 
> loaded?
> 
> I have verified your final experiment: Derby lets you invoke a table 
> function as a scalar function via the values clause. In this situation, 
> Derby just returns the ResultSet produced by the table function. This 
> looks odd to me. I don't think that you should be allowed to invoke a 
> table function as a scalar function. I will log a bug against this.
> 
> Thanks,
> -Rick
> 
> Krzysztof wrote:
>> Hello,
>> I'm trying to get basic table function running without much success.
>> Either error is misleading or I missed some basic point, could you
>> please advise?
>>
>> public class DerbyBlobTableFunction {
>>
>>  //this works
>>   public static int returnSth()
>>     {
>>         return 1;
>>     }
>>
>> //does not work, see error below
>>  public static ResultSet getTSValuesEmpty()  throws SQLException
>>     {
>>          List<double[]> results = new ArrayList<double[]>();
>>         results.add(new double[]{1.0,2.0,3.0});
>>          ResultSet rs = new ResultSetTemplate(results);
>> --//ResultSetTemplate implements ResultSet but same error with Derby
>> impl of ResultSet
>>         return rs;
>>     }
>>
>> }
>>
>>
>> then
>>
>>
>> CALL SQLJ.install_jar
>> ('/pathto/kn.jar', 'APP.kn', 0); -- OK
>>
>> CALL SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY
>> ('derby.database.classpath', 'APP.kn'); --OK
>>
>>
>> CREATE FUNCTION MYFUNC() returns int PARAMETER STYLE JAVA reads
>> sql data language JAVA EXTERNAL NAME
>> ''gaia.cu7.dal.DerbyBlobTableFunction.returnSth'; --OK
>>
>> values MYFUNC() ; --OK
>> returns:
>>
>> 1
>>
>>
>> CREATE FUNCTION getTSValuesEmpty()
>> RETURNS TABLE	
>> (	
>>   obs      double,
>>   val      double,	
>>   valError double
>> )
>> LANGUAGE JAVA
>> PARAMETER STYLE DERBY_JDBC_RESULT_SET
>> reads SQL data --  switching to no sql does not change
>> EXTERNAL NAME ''gaia.cu7.dal.DerbyBlobTableFunction.getTSValuesEmpty'
>> --OK
>>
>> then:
>>
>> select * from table ( getTSValuesEmpty() ) t;
>>
>> gives:
>>
>> An error occurred when executing the SQL command:
>> select * from table ( getTSValuesEmpty() ) t
>> The exception 'java.lang.ClassNotFoundException:
>> gaia.cu7.dal.DerbyBlobTableFunction' was thrown while evaluating an
>> expression. [SQL State=38000, DB Errorcode=20000]
>> Next: Java exception: 'gaia.cu7.dal.DerbyBlobTableFunction:
>> java.lang.ClassNotFoundException'. [SQL State=XJ001]
>>
>> Execution time: 0.04s
>>
>> 1 statement(s) failed.
>>
>>
>> _but_
>>
>> values getTSValuesEmpty();
>>
>> gives:
>> 1
>> gaia.cu7.dal.ResultSetTemplate@10fa2e17
>>
>>
>> MacOS,  Derby 10.4.2.0, embedded mode.
>>
>>
>> Could you please enlighten me what could be wrong? Seems error message
>> is plain wrong as 'values' returns the reference to resultset, and
>> regular function from the same class works as well as values call..
>>
>> Best regards,
>> Krzysztof
>>   
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Uinable-to-use-Table-function-due-to-java.lang.ClassNotFoundException--while-class-is-clearly-reachable..-tp22478383p22699329.html
Sent from the Apache Derby Users mailing list archive at Nabble.com.


Mime
View raw message