|
View:
New views
11 Messages
—
Rating Filter:
Alert me
|
|
|
ERROR 42X51 class not foundi,
I am trying to recreate data base objects (/ triggers) using java functions on a Linux server after having them tested successfully by executing the DDL against the derby network server running on localhost. The development is done using the Apache Nature in the Eclipse IDE and with a network server started on the same machine refered to as 'localhost' on the connect statement. The java code is stored on the filesystem of that same machine. I could create my data base objects as intended and the triggers are working fine. Now I wanted to deploy the solution onto my Linux server and am running into - most probably classpath - problems. The java code I have copied to the java home and also to the derby home folder on the server. the functions are defined as public. Here is what the sysinfo utility reports on my development machine (network server run on localhost which is a windows machine): ------------------ Java Information ------------------ Java Version: 1.6.0_15 Java Vendor: Sun Microsystems Inc. Java home: C:\Programme\Java\jre6 Java classpath: C:\Daten\eclipse ganymede\derby; C:\Programme\eclipse-ganymede-SR1\eclipse\plugins\ org.apache.derby.core_10.5.1\derby.jar; C:\Programme\eclipse-ganymede-SR1\eclipse\plugins\ org.apache.derby.core_10.5.1\derbyclient.jar; C:\Programme\eclipse-ganymede-SR1\eclipse\plugins\ org.apache.derby.core_10.5.1\derbynet.jar; C:\Programme\eclipse-ganymede-SR1\eclipse\plugins\ org.apache.derby.core_10.5.1\derbytools.jar OS name: Windows XP OS architecture: x86 OS version: 5.1 Java user name: Thomas Java user home: C:\Dokumente und Einstellungen\Thomas Java user dir: C:\Daten\eclipse ganymede\derby java.specification.name: Java Platform API Specification java.specification.version: 1.6 --------- Derby Information -------- JRE - JDBC: Java SE 6 - JDBC 4.0 [C:\Programme\eclipse-ganymede-SR1\eclipse\plugins\ org.apache.derby.core_10.5.1\derby.jar] 10.5.1.1 - (764942) [C:\Programme\eclipse-ganymede-SR1\eclipse\plugins\ org.apache.derby.core_10.5.1\derbytools.jar] 10.5.1.1 - (764942) [C:\Programme\eclipse-ganymede-SR1\eclipse\plugins\ org.apache.derby.core_10.5.1\derbynet.jar] 10.5.1.1 - (764942) [C:\Programme\eclipse-ganymede-SR1\eclipse\plugins\ org.apache.derby.core_10.5.1\derbyclient.jar] 10.5.1.1 - (764942) ------------------------------------------------------ ----------------- Locale Information ----------------- ------------------------------------------------------ Here is what sysinfo reports on the Linux server: ------------------ Java Information ------------------ Java Version: 1.6.0_12 Java Vendor: Sun Microsystems Inc. Java home: /usr/lib/jvm/java-6-sun-1.6.0.12/jre Java classpath: /var/lib/derby/db-derby-10.5.3.0-bin/lib/derby.jar: /var/lib/derby/db-derby-10.5.3.0-bin/lib/derbynet.jar: /var/lib/derby/db-derby-10.5.3.0-bin/lib/derbytools.jar: /var/lib/derby/db-derby-10.5.3.0-bin/lib/derbyclient.jar OS name: Linux OS architecture: i386 OS version: 2.6.26-2-686 Java user name: root Java user home: /root Java user dir: /root java.specification.name: Java Platform API Specification java.specification.version: 1.6 --------- Derby Information -------- JRE - JDBC: Java SE 6 - JDBC 4.0 [/var/lib/derby/db-derby-10.5.3.0-bin/lib/derby.jar] 10.5.3.0 - (802917) [/var/lib/derby/db-derby-10.5.3.0-bin/lib/derbytools.jar] 10.5.3.0 - (802917) [/var/lib/derby/db-derby-10.5.3.0-bin/lib/derbynet.jar] 10.5.3.0 - (802917) [/var/lib/derby/db-derby-10.5.3.0-bin/lib/derbyclient.jar] 10.5.3.0 - (802917) ------------------------------------------------------ ----------------- Locale Information ----------------- Current Locale : [English/United States [en_US]] Found support for locale: [cs] version: 10.5.3.0 - (802917) Found support for locale: [de_DE] version: 10.5.3.0 - (802917) Found support for locale: [es] version: 10.5.3.0 - (802917) Found support for locale: [fr] version: 10.5.3.0 - (802917) Found support for locale: [hu] version: 10.5.3.0 - (802917) Found support for locale: [it] version: 10.5.3.0 - (802917) Found support for locale: [ja_JP] version: 10.5.3.0 - (802917) Found support for locale: [ko_KR] version: 10.5.3.0 - (802917) Found support for locale: [pl] version: 10.5.3.0 - (802917) Found support for locale: [pt_BR] version: 10.5.3.0 - (802917) Found support for locale: [ru] version: 10.5.3.0 - (802917) Found support for locale: [zh_CN] version: 10.5.3.0 - (802917) Found support for locale: [zh_TW] version: 10.5.3.0 - (802917) ------------------------------------------------------ miniserver:~ Here is the output IJ reports showing the DDL executed properly on localhost: ij version 10.5 ij> CONNECT 'jdbc:derby://localhost:1527/test; create=true; user=derby'; ij> -- DROP TABLE "Clients"; CREATE TABLE "Clients" ( "ClientID" varchar(16) NOT NULL, "ClientName" varchar(64) NOT NULL, "RowID" integer NOT NULL generated always as identity, "CreatedBy" varchar(64) NOT NULL DEFAULT CURRENT_USER, "CreatedOn" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, "LastUpdatedBy" varchar(64) NOT NULL DEFAULT CURRENT_USER, "LastUpdatedOn" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, "DeletedBy" varchar(64), "DeletedOn" timestamp, CONSTRAINT "PK_Clients" PRIMARY KEY ("ClientID") ); 0 rows inserted/updated/deleted ij> CREATE UNIQUE INDEX "UI_Clients_RowID" ON "Clients"("RowID"); 0 rows inserted/updated/deleted ij> -- DROP TRIGGER "TR_Clients_AI1"; CREATE TRIGGER "TR_Clients_AI1" AFTER INSERT ON "Clients" REFERENCING NEW AS NEW FOR EACH ROW UPDATE rte."Clients" SET "CreatedBy" = CURRENT_USER, "CreatedOn" = CURRENT_TIMESTAMP, "LastUpdatedBy" = CURRENT_USER, "LastUpdatedOn" = CURRENT_TIMESTAMP, "DeletedBy" = NULL, "DeletedOn" = NULL WHERE "RowID" = NEW."RowID"; ERROR 42Y07: Schema 'RTE' does not exist ij> --DROP PROCEDURE "TF_Clients_AI2"; CREATE PROCEDURE "TF_Clients_AI2"(IN iRowID integer, IN vcClientID varchar(16), IN vcClientName varchar(64)) LANGUAGE JAVA PARAMETER STYLE JAVA MODIFIES SQL DATA EXTERNAL NAME 'derbyPk.Functions.TF_Clients_AI2(java.lang.Integer, java.lang.String, java.lang.String)'; 0 rows inserted/updated/deleted ij> -- DROP TRIGGER "TR_Clients_AI2"; CREATE TRIGGER "TR_Clients_AI2" AFTER INSERT ON "Clients" REFERENCING NEW AS NEW FOR EACH ROW CALL DERBY."TF_Clients_AI2"(NEW."RowID", NEW."ClientID", NEW."ClientName"); 0 rows inserted/updated/deleted ij> DISCONNECT; ij> EXIT; and here is the ij output when trying to do the same on my Linux machine ij version 10.5 ij> CONNECT 'jdbc:derby://192.168.178.10:1527/test; create=true; user=derby'; ij> -- DROP TABLE "Clients"; CREATE TABLE "Clients" ( "ClientID" varchar(16) NOT NULL, "ClientName" varchar(64) NOT NULL, "RowID" integer NOT NULL generated always as identity, "CreatedBy" varchar(64) NOT NULL DEFAULT CURRENT_USER, "CreatedOn" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, "LastUpdatedBy" varchar(64) NOT NULL DEFAULT CURRENT_USER, "LastUpdatedOn" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, "DeletedBy" varchar(64), "DeletedOn" timestamp, CONSTRAINT "PK_Clients" PRIMARY KEY ("ClientID") ); 0 rows inserted/updated/deleted ij> CREATE UNIQUE INDEX "UI_Clients_RowID" ON "Clients"("RowID"); 0 rows inserted/updated/deleted ij> -- DROP TRIGGER "TR_Clients_AI1"; CREATE TRIGGER "TR_Clients_AI1" AFTER INSERT ON "Clients" REFERENCING NEW AS NEW FOR EACH ROW UPDATE rte."Clients" SET "CreatedBy" = CURRENT_USER, "CreatedOn" = CURRENT_TIMESTAMP, "LastUpdatedBy" = CURRENT_USER, "LastUpdatedOn" = CURRENT_TIMESTAMP, "DeletedBy" = NULL, "DeletedOn" = NULL WHERE "RowID" = NEW."RowID"; ERROR 42Y07: Das Schema 'RTE' ist nicht vorhanden. ij> --DROP PROCEDURE "TF_Clients_AI2"; CREATE PROCEDURE "TF_Clients_AI2"(IN iRowID integer, IN vcClientID varchar(16), IN vcClientName varchar(64)) LANGUAGE JAVA PARAMETER STYLE JAVA MODIFIES SQL DATA EXTERNAL NAME 'derbyPk.Functions.TF_Clients_AI2(java.lang.Integer, java.lang.String, java.lang.String)'; 0 rows inserted/updated/deleted ij> -- DROP TRIGGER "TR_Clients_AI2"; CREATE TRIGGER "TR_Clients_AI2" AFTER INSERT ON "Clients" REFERENCING NEW AS NEW FOR EACH ROW CALL DERBY."TF_Clients_AI2"(NEW."RowID", NEW."ClientID", NEW."ClientName"); ERROR 42X51: Die Klasse 'derbyPk.Functions' ist nicht vorhanden oder es kann nicht auf die Klasse zugegriffen werden. Diese Situation kann eintreten, wenn die Klasse nicht öffentlich ist. ERROR XJ001: Java-Ausnahme: 'derbyPk.Functions: java.lang.ClassNotFoundException'. ij> DISCONNECT; ij> EXIT; Any help would be appreciated. Thanks Thomas |
|
|
Re: ERROR 42X51 class not found> Here is what the sysinfo utility reports on my development machine (network
> server run on localhost which is a windows machine): > Java classpath: C:\Daten\eclipse ganymede\derby; > > Here is what sysinfo reports on the Linux server: > Java classpath: /var/lib/derby/db-derby-10.5.3.0-bin/lib/derby.jar: It looks like your development environment has your eclipse project home directory in your classpath, but your Linux deployment environment does not. I think you need to double-check the setup of the Linux server environment so that the class files for the procedures you have written are in that classpath. thanks, bryan |
|
|
Re: ERROR 42X51 class not foundHi,
what I have done now is 1) opened up a root terminal session on the server 2) checked CLASSPATH with echo $CLASSPATH command -> emtpy 3) defined the CLASSPATH=/var/lib/derby/db-derby-10.5.3.0-bin/lib/ 4) exported the CLASSPATH 5) checked CLASSPATH setting again and now the path was returned 6) ran sysinfo again and saw the path was added at the end, as you can see here in the new sysinfo output (see last entry) Java classpath: /var/lib/derby/db-derby-10.5.3.0-bin/lib/derby.jar :/var/lib/derby/db-derby-10.5.3.0-bin/lib/derbynet.jar :/var/lib/derby/db-derby-10.5.3.0-bin/lib/derbytools.jar :/var/lib/derby/db-derby-10.5.3.0-bin/lib/derbyclient.jar :/var/lib/derby/db-derby-10.5.3.0-bin/lib/ 7) opened a second root terminal session and copied my folder derbyPk and the all files included from my windows machine to the server as :/var/lib/derby/db-derby-10.5.3.0-bin/lib/derbyPk 8) switched back to my first root terminal session (in which classpath variable was defined and then 8) started the network server in the same terminal session 9) tried to execute the DDL again against the server => unfortunately with the same result - still getting error 42X51 |
|
|
Re: ERROR 42X51 class not found> 7) opened a second root terminal session and copied my folder derbyPk and the
> all files included from my windows machine to the server as > :/var/lib/derby/db-derby-10.5.3.0-bin/lib/derbyPk > 8) switched back to my first root terminal session (in which classpath variable If, in this terminal window (with CLASSPATH set to /var/lib/derby/db-derby-10.5.3.0-bin/lib) you run this command: java derbyPk.Functions.TF_Clients_AI2 what happens? thanks, bryan |
|
|
Re: ERROR 42X51 class not foundI am getting this error:
miniserver:/var/lib/derby/db-derby-10.5.3.0-bin/lib# java derbyPk.Functions.TF_Clients_AI2 Exception in thread "main" java.lang.NoClassDefFoundError: derbyPk/Functions/TF_Clients_AI2 Caused by: java.lang.ClassNotFoundException: derbyPk.Functions.TF_Clients_AI2 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:307) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) at java.lang.ClassLoader.loadClass(ClassLoader.java:252) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320) Could not find the main class: derbyPk.Functions.TF_Clients_AI2. Program will exit. here the proof that classpath is set: miniserver:/var/lib/derby/db-derby-10.5.3.0-bin/lib# echo $CLASSPATH /var/lib/derby/db-derby-10.5.3.0-bin/lib/ and yes folder /var/lib/derby/db-derby-10.5.3.0-bin/lib/ does contain a folder derbyPk and yes there is a file Functions.class and yes in Functions.java there is a function TF_Clients_AI2 which is defined as public. Thanks for your help Thomas |
|
|
Re: ERROR 42X51 class not foundThomas Hill wrote:
> I am getting this error: > > miniserver:/var/lib/derby/db-derby-10.5.3.0-bin/lib# java > derbyPk.Functions.TF_Clients_AI2 > Exception in thread "main" java.lang.NoClassDefFoundError: > derbyPk/Functions/TF_Clients_AI2 > Caused by: java.lang.ClassNotFoundException: derbyPk.Functions.TF_Clients_AI2 > 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:307) > at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) > at java.lang.ClassLoader.loadClass(ClassLoader.java:252) > at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320) > Could not find the main class: derbyPk.Functions.TF_Clients_AI2. > Program will exit. > > here the proof that classpath is set: > miniserver:/var/lib/derby/db-derby-10.5.3.0-bin/lib# echo $CLASSPATH > /var/lib/derby/db-derby-10.5.3.0-bin/lib/ > > and yes folder /var/lib/derby/db-derby-10.5.3.0-bin/lib/ does contain a folder > derbyPk and yes there is a file Functions.class and yes in Functions.java there > is a function TF_Clients_AI2 which is defined as public. Is TF_Clients_AI2 a class or a method? Doing java derbyPk.Functions.TF_Clients_AI2 will attempt to load a *class* named derbyPk.Functions.TF_Clients_AI2. From your description it seems that the class is derbyPk.Functions and it has a method called TF_Clients_AI2 inside it. Dan. |
|
|
Re: ERROR 42X51 class not foundderby.Functions is a class and TF_Clients_AI2 a method.
the java code reads: package derbyPk; public class Functions { public static void TF_Clients_AI2(int iRowID, String vcClientID, String vcClientName) throws SQLException { ... } } As said all of this worked fine when running the derby Networkserver on localhost and with the java code stored in the filesystem on localhost. Thanks |
|
|
Re: ERROR 42X51 class not foundHi,
I noticed that you run all your manual tests as root on your unix box (prompt sh#). Will the Derby server run under that identity too? That lets me suspect perhaps a problem with the permissions on your files/folders. That's a little bit doubtful, since usually /var/lib is readable and traversable by everyone. Anyway, as we are in an impasse here, worth trying to check those permissions (ls -l - look for rx on directories and r on files). Then try to run the following command on a shell, with CLASSPATH correctly set, and /under the identity used by Derby/: derby$ java derbyPk.Functions ^^^^^^^^ (/class/ name here!) If you get "NoSuchMethod: main" the files are readable. So this is definitively a Derby problem. On the other hand, if you still get ClassNotFound exception, check again the permissions. If you packaged your files as a JAR, search for a problem with it on your server (something wrong while building/copying the JAR?). "jar tvf" could give more informations. On that matters, (should I have put that first ;)? ), I noticed that your class path is: /var/lib/derby/db-derby-10.5.3.0-bin/lib/ But if you packaged your files as a JAR on your server, shouldn't it be: /var/lib/derby/db-derby-10.5.3.0-bin/lib/myjar.jar ^^^^^^^^^ Nothing really convincing here. I agree. But it should help narrowing the problem. Somehow... Sylvain. Thomas Hill a écrit : > derby.Functions is a class and TF_Clients_AI2 a method. > > the java code reads: > > package derbyPk; > > public class Functions { > public static void TF_Clients_AI2(int iRowID, String vcClientID, String > vcClientName) throws SQLException > { > ... > } > } > > As said all of this worked fine when running the derby Networkserver on > localhost and with the java code stored in the filesystem on localhost. > > Thanks > > > -- Website: http://www.chicoree.fr |
|
|
Re: ERROR 42X51 class not foundOk, Thomas:
> 7) opened a second root terminal session and copied my folder derbyPk and the > all files included from my windows machine to the server as > :/var/lib/derby/db-derby-10.5.3.0-bin/lib/derbyPk I missed that. Sorry. So you are not using a JAR. But still worth trying: >> derby$ java derbyPk.Functions And check permissions. Just to be sure this is a Derby configuration problem. ---- Otherwise, is the problem specific to Derby network server, or did you have the same behaviour while trying to create your function in standalone mode: ij> CONNECT 'jdbc:derby:/tmp/test; create=true'; ij> CREATE PROCEDURE "TF_Clients_AI2"(IN iRowID integer, IN vcClientID varchar(16), IN vcClientName varchar(64)) LANGUAGE JAVA PARAMETER STYLE JAVA MODIFIES SQL DATA EXTERNAL NAME 'derbyPk.Functions.TF_Clients_AI2(java.lang.Integer, java.lang.String, java.lang.String)'; ij> CALL "TF_Clients_AI2"(.....); ^^ What happens here? Sylvain. -- Website: http://www.chicoree.fr |
|
|
Re: ERROR 42X51 class not foundSylvain,
when I executed 'java derbyPk.Functions' from the command line I received an error 'No such method: main' (not class not found). Then I inserted a method main just to see what happens and all main did was to print a 'Hello World' to the console. After recompiling and executing 'java derbyPk.Functions' now with a method main again I received Hello World as answer. I checked my file permissions and they are all the same with root as owner and others having read-permission. I do not think this a file permission problem. I then invoked ij and connected to the database as user=root (no longer as user=derby) [how do I know which user derby is running under, I thought root as I did not specify anything when starting the server?] Here are the results I received in ij: a) when I still had a methode main: 'CALL "TF_Clients_AI2"(1,'000','xxx');' ==> "TF_CLients_AI2" is not a recognised function or procedure 'CALL derby."TF_Clients_AI2"(1,'000', 'xxx');' ==> no answer, system seemed to hang and I exited out using Ctrl+C b) so I removed the method main again and recompiled: 'CALL derby."TF_Clients_AI2"(1,'000','xxx');' ==> good old ERROR 42X51, derbkyPk.Functions does not exist or is inaccessible followed by ERROR XJ001 java.lang.ClassNotFoundException 'CALL derby."TF_Clients_AI2"(1,1,1);' ==> when passing wrong data types I received 'VARCHAR' can not hold types 'INTEGER' 'CALL derby."TF_Clients_AI2"();' ==> derby."TF_Clients_AI2" is not a recognised function or procedure. Still confusing and I wonder what the problem will have been once it was solved (if it ever will). Thomas |
|
|
ONE solution found: ERROR 42X51 class not foundI have now found a solution.
When packaging everything into a JAR file and installing the jar in the database my DDL executed successfully and the trigger using java code do what they are supposed to do. Still a miracle to me why it didn't work when storing the java code on the filesystem. Regards Thomas |
| Free embeddable forum powered by Nabble | Forum Help |