Forum: Installation

Post: java error when trying tutorial application

java error when trying tutorial application
AndrashTM
Feb 24, 2012
Hello,
Could someone help me with the following error? I did the VoltDB tutorial and this came up, when trying to run the jar file:


Exception in thread "main" java.lang.NoClassDefFoundError: org/voltdb/VoltDB
Caused by: java.lang.ClassNotFoundException: org.voltdb.VoltDB
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Could not find the main class: org.voltdb.VoltDB. Program will exit.



Also, when running, run.sh I got this:

Successfully created helloworld.jar
Includes schema: helloworld.sql
[SP][RW] HELLOWORLD.delete
DELETE FROM HELLOWORLD WHERE (DIALECT = ?);
[SP][RW] HELLOWORLD.insert
INSERT INTO HELLOWORLD VALUES (?, ?, ?);
[SP][RO] HELLOWORLD.select
SELECT * FROM HELLOWORLD WHERE (DIALECT = ?);
[SP][RW] HELLOWORLD.update
UPDATE HELLOWORLD SET HELLO = ?, WORLD = ?, DIALECT = ? WHERE (DIALECT = ?);
[SP][RW] Insert
INSERT INTO HELLOWORLD VALUES ('test', 'test', 'test');
[SP][RO] Select
SELECT HELLO, WORLD FROM HELLOWORLD WHERE DIALECT = 'test';


Thank you,
Andras
Hi Adras, If you get
aweisberg
Feb 24, 2012
Hi Adras,

If you get NoClassDefFoundError then the VoltDB.jar isn't in the classpath.

Can you post the java command you invoked?

-Ariel
So, as I have mentioned, I
AndrashTM
Feb 27, 2012
So, as I have mentioned, I mode the tutorial with Hello World, and i just typed $ ./run.sh in the console, when I got this:


log4j:WARN No appenders could be found for logger (COMPILER).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more in fo.
------------------------------------------
Successfully created helloworld.jar
Includes schema: helloworld.sql

[SP][RW] HELLOWORLD.delete
DELETE FROM HELLOWORLD WHERE (DIALECT = ?);

[SP][RW] HELLOWORLD.insert
INSERT INTO HELLOWORLD VALUES (?, ?, ?);

[SP][RO] HELLOWORLD.select
SELECT * FROM HELLOWORLD WHERE (DIALECT = ?);

[SP][RW] HELLOWORLD.update
UPDATE HELLOWORLD SET HELLO = ?, WORLD = ?, DIALECT = ? WHERE (DIALECT = ?);

[SP][RW] Insert
INSERT INTO HELLOWORLD VALUES ('test', 'test', 'test');

[SP][RO] Select
SELECT HELLO, WORLD FROM HELLOWORLD WHERE DIALECT = 'test';


When I typed the following in the console:


java -Djava.library.path=/opt/db/voltdb/voltdb \
org.voltdb.VoltDB \
catalog helloworld.jar \
deployment deployment.xml \
leader localhost \
license /opt/db/voltdb/voltdb/license.xml



This came up:

Exception in thread "main" java.lang.NoClassDefFoundError: org/voltdb/VoltDB
Caused by: java.lang.ClassNotFoundException: org.voltdb.VoltDB
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Could not find the main class: org.voltdb.VoltDB. Program will exit.



Could you also please tell me what is the command for setting VoltDB in the CLASSPATH? because when I echo $CLASSPATH I get nothing...



Fixed it, it works :)
AndrashTM
Feb 27, 2012
Fixed it, it works :)
Hi, Glad to hear you got
aweisberg
Feb 27, 2012
Hi,
Glad to hear you got it working. For observers, the classpath needs to contain the full path of each jar file. Java won't pick up jar files from a directory that is in the classpath.


The README for helloworld has the correct instructions although it doesn't supply a log4j configuration. I created https://issues.voltdb.com/browse/ENG-2528 for this.


-Ariel
Thanks, Ariel! Still I cannot
AndrashTM
Feb 28, 2012
Thanks Ariel!


Still I cannot dump errors into a file. Because I need to know what and where is wrong.. maybe the Java? Maybe the DDL? If so... on what line, what is an error or not supported by Volt?

I am trying to load an existing Oracle database into VoltDB. And I need these 'dumps' in order to fix the DDL and maybe the code.
Hi Andrash, Sorry for the
aweisberg
Mar 6, 2012
Hi Andrash,
Sorry for the late response. Things have been busy.
Does this post http://community.voltdb.com/node/676#comment-1391 give you enough information to get logging configured?
The scripts that come in the distribution take care of a lot of this boilerplate.
-Ariel