So in UpdateLoader.java there is:
private static final String[] RESTRICTED_PACKAGES = {
// While loading java. classes is blocked by the standard
// class loading mechanism, javax. ones are not. However
// allowing database applications to override jvm classes
// seems a bad idea.
"javax.",
// Allowing an application to possible override the engine's
// own classes also seems dangerous.
"org.apache.derby.",
};
Will this prevent any user functions or procedures such as a table function
from accessing "org.apache.derby.vti.RestrictedVTI"? This seems to prevent
Restricted Table functions from being loaded jar files stored in the database.
________________________________________
From: Bergquist, Brett
Sent: Monday, July 25, 2011 12:44 PM
To: Bergquist, Brett; [email protected]
Subject: Code loaded through SQL.INSTALL_JAR does not have access to derby API
code. Is this expected?
I found some information. I found that if I include my JAR file containing my
Restricted Table code in the classpath before starting the network server, then
the code can load correctly and it has access to the
"org.apache.derby.vti.RestrictedVTI" class and others. If however the code is
loaded through the SQLJ.INSTALL_JAR procedure, then the code does not have
access to the "org.apache.derby.vti.RestrticedVTI" class or others.
Is this expected? I really would like to be able to install my table function
code to be in the database and not have to manipulate the classpath. No where
in the documentation does it say that this cannot be done, but it does not work.
Should I write up an issue in JIRA?
________________________________________
From: Bergquist, Brett
Sent: Monday, July 25, 2011 9:23 AM
To: Bergquist, Brett; [email protected]
Subject: Re: Problem in trying to get a Restricted Table Function loaded
In case this got missed as I could really use the help. Just need to know what
I need to do to get the VYI classes to be accessible to my table function. As
a straight table function it registers and works fine but as soon as I
reference something like VTITemplate it fails saying it could not find the
class.
Brett Bergquist
Principal Software Engineer
Phone: 203 888 7914 Ext 204
Email: [email protected]
----- Reply message -----
From: "Bergquist, Brett" <[email protected]>
Date: Sun, Jul 24, 2011 11:19 am
Subject: Problem in trying to get a Restricted Table Function loaded
To: "[email protected]" <[email protected]>
My class looks like:
public class NpaResultsTableFunction extends VTITemplate implements
RestrictedVTI {
public static NpaResultsTableFunction read() throws SQLException {
return new NpaResultsTableFunction();
}
public NpaResultsTableFunction() throws SQLException {
conn = DriverManager.getConnection("jdbc:default:connection");
}
...
}
I have defined the function using the following where "csem-pcs-derby-jar" is
the location of the JAR file containing this table function:
CALL SQLJ.INSTALL_JAR('${csem-pcs-derby-jar}',
'PCS_V1.pcsderby', 0);
SET SCHEMA PCS_V1;
CREATE FUNCTION NPARESULTS_TABLE () RETURNS TABLE
(org.apache.derby.vti.RestrictedVTI
ID BIGINT,
REPORTKEY CHAR(56),
MASTERIP CHAR(4) FOR BIT DATA,
BOOTCOUNT INTEGER,
TESTRESULTID BIGINT,
PROFILEREFID INTEGER,
ADDRESSREFID INTEGER,
STARTDATETIME TIMESTAMP,
ACCURACYLEVEL SMALLINT,
RESULTFLAG SMALLINT,
PACKETSSENT INTEGER,
ROUNDTRIPPACKETS INTEGER,
DROPPEDPACKETS INTEGER,
OUTOFORDERPACKETS INTEGER,
MINROUNDTRIPLATENCY INTEGER,
MAXROUNDTRIPLATENCY INTEGER,
TOTALROUNDTRIPLATENCY BIGINT,
AVGROUNDTRIPLATENCY INTEGER,
LATENCYBUCKETVALUE1 INTEGER,
LATENCYBUCKETVALUE2 INTEGER,
LATENCYBUCKETVALUE3 INTEGER,
LATENCYBUCKETVALUE4 INTEGER,
LATENCYBUCKETVALUE5 INTEGER,
LATENCYBUCKETVALUE6 INTEGER,
LATENCYBUCKETVALUE7 INTEGER,
LATENCYBUCKETVALUE8 INTEGER,
LATENCYBUCKETVALUE9 INTEGER,
LATENCYBUCKETVALUE10 INTEGER,
JITTERMEASUREMENT INTEGER,
MINLOCALREMOTEJITTER INTEGER,
MAXLOCALREMOTEJITTER INTEGER,
TOTALLOCALREMOTEJITTER BIGINT,
AVGLOCALREMOTEJITTER INTEGER,
LOCALREMOTEJITTERBUCKETVALUE1 INTEGER,
LOCALREMOTEJITTERBUCKETVALUE2 INTEGER,
LOCALREMOTEJITTERBUCKETVALUE3 INTEGER,
LOCALREMOTEJITTERBUCKETVALUE4 INTEGER,
LOCALREMOTEJITTERBUCKETVALUE5 INTEGER,
LOCALREMOTEJITTERBUCKETVALUE6 INTEGER,
LOCALREMOTEJITTERBUCKETVALUE7 INTEGER,
LOCALREMOTEJITTERBUCKETVALUE8 INTEGER,
LOCALREMOTEJITTERBUCKETVALUE9 INTEGER,
MINREMOTELOCALJITTER INTEGER,
MAXREMOTELOCALJITTER INTEGER,
TOTALREMOTELOCALJITTER BIGINT,
AVGREMOTELOCALJITTER INTEGER,
REMOTELOCALJITTERBUCKETVALUE1 INTEGER,
REMOTELOCALJITTERBUCKETVALUE2 INTEGER,
REMOTELOCALJITTERBUCKETVALUE3 INTEGER,
REMOTELOCALJITTERBUCKETVALUE4 INTEGER,
REMOTELOCALJITTERBUCKETVALUE5 INTEGER,
REMOTELOCALJITTERBUCKETVALUE6 INTEGER,
REMOTELOCALJITTERBUCKETVALUE7 INTEGER,
REMOTELOCALJITTERBUCKETVALUE8 INTEGER,
REMOTELOCALJITTERBUCKETVALUE9 INTEGER,
CIRCUIT1REFID INTEGER,
CIRCUIT2REFID INTEGER
)
LANGUAGE JAVA
PARAMETER STYLE DERBY_JDBC_RESULT_SET
READS SQL DATA
EXTERNAL NAME
'com.canoga.derby.fcn.NpaResultsTableFunction.read';
CALL
SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY('derby.database.classpath','CSEM.csemderby:PCS_V1.pcsderby');
All of this is okay and before I tried to make this a restricted table
function, worked correctly. All the above loads into the database correct
right now, but when I execute:
select * from table (PCS_V1.NPARESULTS_TABLE()) s
I get:
Error: The class 'com.canoga.derby.fcn.NpaResultsTableFunction' does not exist
or is inaccessible. This can happen if the class is not public.
SQLState: 42X51
ErrorCode: -1
Error: Java exception: 'com.canoga.derby.fcn.NpaResultsTableFunction :
org/apache/derby/vti/RestrictedVTI: java.lang.ClassNotFoundException'.
SQLState: XJ001
ErrorCode: 99999
It appears that the class "org.apache.derby.vti.RestrictedVTI" cannot be found.
Derby is 10.8.1.2 and is started using the startNetworkControlServer script.
Do I need to andy anything else via the "derby.database.classpath" for it to
find "org.apache.derby.vti.RestrictedVTI"?
Any help will be greatly appreciated.
Brett