Java - NoClassDefFoundError on starting up local version of DynamoDB - java

I'm trying to start local version of DynamoDB on the command line (OSX) using the following command as specified in the documentation:
java –Djava.library.path=. -jar DynamoDBLocal.jar
But getting the following errors:
Exception in thread "main" java.lang.NoClassDefFoundError: �Djava/library/path=/
Caused by: java.lang.ClassNotFoundException: �Djava.library.path=.
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)
Any ideas on how to resolve this issue?

The � shows that it may be a character, which looks like hyphen '-' . Please inspect this.
Also, whenever you are using -D option, its best practice to use a complete jar name (rather than wild card). This will make sure that you are missing nothing.

Related

Jdbc no suitable driver found. Postgresql [duplicate]

Note
I'm running windows, the path just looks like it's linus because I typed it manually and thats how I think of paths.
I'm trying to run a java class That I have built to diagnose my connection to a databse, it references the oracle jdbc adaptor.
When I just run it without a class path:
%> java DBDiagnostics <connectionString>
I get an exception when it reaches the following line of code:
Class.forName("oracle.jdbc.pool.OracleDataSource").newInstance();
with the following exception:
java.lang.ClassNotFoundException: oracle.jdbc.pool.OracleDataSource
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)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at DBDiagnostics.GetConnection(DBDiagnostics.java:43)
at DBDiagnostics.runDiagnostic(DBDiagnostics.java:29)
at DBDiagnostics.main(DBDiagnostics.java:18)
Creating connection.
java.sql.SQLException: No suitable driver found for lskd
at java.sql.DriverManager.getConnection(DriverManager.java:602)
at java.sql.DriverManager.getConnection(DriverManager.java:207)
at DBDiagnostics.GetConnection(DBDiagnostics.java:55)
at DBDiagnostics.runDiagnostic(DBDiagnostics.java:29)
at DBDiagnostics.main(DBDiagnostics.java:18)
Veryfying connectivity to Database
Exception in thread "main" java.lang.NullPointerException
at DBDiagnostics.verifyTable(DBDiagnostics.java:86)
at DBDiagnostics.verifyTable(DBDiagnostics.java:76)
at DBDiagnostics.verifyDatabseConnectivity(DBDiagnostics.java:68)
at DBDiagnostics.runDiagnostic(DBDiagnostics.java:36)
at DBDiagnostics.main(DBDiagnostics.java:18)
I assume that this is because I need to include it in the classpath.
So, I tried adding it to the classpath like this:
%> java -classpath .:ojdbc6.jar DBDiagnostics <connectionString>
The VM just says it cant find the class:
Exception in thread "main" java.lang.NoClassDefFoundError: DBDiagnostics
Caused by: java.lang.ClassNotFoundException: DBDiagnostics
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: DBDiagnostics. Program will exit.
I know this is a question I should just know the answer to, but what am I doing wrong?
Replace the colon with a semicolon:
java -classpath .;ojdbc6.jar DBDiagnostics <connectionString>
is there a typo:
%> java -classpath .:ojdbc6.jar DBDiagnostics <connectionString>
maybe it would work if you type this:
%> java -classpath ./ojdbc6.jar DBDiagnostics <connectionString>
Does the DBDiagnostics.class file appear in the directory from which you're launching Java? If not, the class loader won't find it.
Does the DBDiagnostics class have a package? If it does, you have to refer to the fully resolved class name, and the root of the package hierarchy has to appear in the directory from which you launch Java.
Mike Sickler's answer looks right for a Windows platform. The path separator for Windows is ";", but ":" for Unix and Linux, so make sure you always use the right one!
Long shot, but is this Unix or Windows? If on Windows the class path separator should be a semi colon:-
%> java -classpath .;ojdbc6.jar DBDiagnostics <connectionString>
And of course you need to have the ojdbc6.jar file in the current directory if you don't specify any path to it. (And possibly it's dependencies as well...)

Java NoClassDefFoundError for commons-io?

I have the following directory structure:
somedir/
lib/
myapp.jar
commons-io-2.1.jar
...lots of otherjars
From inside somedir, I try to run the following command:
java -cp lib/* net.myapp.Driver /home/myUser.blah.text
And I am getting the following exception:
Exception in thread "main" java.lang.NoClassDefFoundError: lib/commons-io-2/1/jar
Caused by: java.lang.ClassNotFoundException: lib.commons-io-2.1.jar
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: lib/commons-io-2.1.jar. Program will exit.
Why is it telling me that it can't find a "main" in Apache Commons IO? I might be able to understand if it couldn't find my Driver class (maybe I misconfigured something), but this is just throwing me way off. Ideas? Thanks in advance!
From the stack trace it appears as if java is taking the commons-io Jar for a class which leads me to a wild guess: Could it be a whitespace problem? Is it possible that lib contains a jar with a space in it? Have you tried enclosing the cp option in quotes (i.e. use -cp "lib/*")?
Use quotes.
java -cp "lib/*" net.myapp.Driver /home/myUser.blah.text
Well explained here.
you could also try java -cp /lib/* net.myapp.Driver /home/myUser.blah.text

java.lang.NoClassDefFoundError:oracle/j2ee/ws/common/jaxws/ServiceDelegateImpl

I am using BPM API to retrieve a list of task assigned to a particular user. But, While running the class file I am getting following error:--
Exception in thread "main" java.lang.NoClassDefFoundError: oracle/j2ee/ws/common/jaxws/ServiceDelegateImpl
at oracle.bpm.client.BPMServiceClientFactory.<init>(BPMServiceClientFactory.java:102)
at oracle.bpm.client.BPMServiceClientFactory.getInstance(BPMServiceClientFactory.java:144)
at project3.Fixture.getBPMServiceClientFactory(Fixture.java:33)
at project3.Fixture.getBPMServiceClient(Fixture.java:49)
at project3.GetProcessInstances.testGetProcessInstances(GetProcessInstances.java:29)
at project3.GetProcessInstances.main(GetProcessInstances.java:24)
Caused by: java.lang.ClassNotFoundException: oracle.j2ee.ws.common.jaxws.ServiceDelegateImpl
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:305)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:246)
... 6 more
I have already added the following Jar file to my project:--
Oracle.bpm.runtime.jar
Oracle.bpm.client.jar
Bpm-services.jar
Wsclient.jar
But still the issue is not resolved..
Any Suggestion??????
Aside from the reason it is not working you should be using the TaskQueryService provided by Oracle out of the box.

Compiling Simple MongoDB + Java Example

I seem to be unable to compile a simple MongoDB + Java Example:
I have this file
https://github.com/mongodb/mongo-java-driver/blob/master/examples/QuickTour.java
In my command line I compile by doing
$ javac -cp mongo-2.10.1.jar QuickTour.java
$ java -cp mongo-2.10.1.jar QuickTour
However it gives me the error
Exception in thread "main" java.lang.NoClassDefFoundError: QuickTour
Caused by: java.lang.ClassNotFoundException: QuickTour
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)
What is going on and how can I fix this? Is it something to do with my compilation arguments?
Thanks...
It's not the compile time error. It's the error you got when you try to run your class. And the error simply says that it cannot find the class that you are trying to run. That error almost always means that you messed up with the classpath.
The problem is, you forgot to include the current directory in your argument to classpath. Add a dot(.) in addition to your mongo.jar file as the argument to -cp:
java -cp .;mongo-2.10.1.jar QuickTour
This assuming that you are executing your QuickTour class from the same directory where you have placed it.

running python using jython

I want to run a python function using jython..
Taking the example from this site.
http://sundaycomputing.blogspot.com/2011/01/python-udfs-from-pig-scripts.html
Now when i run the script (pig -f myscript.pig
It returns me this error
Pig Stack Trace
---------------
ERROR 2998: Unhandled internal error. org/python/core/PyException
java.lang.NoClassDefFoundError: org/python/core/PyException
at org.apache.pig.scripting.jython.JythonScriptEngine.registerFunctions(JythonScriptEngine.java:127)
at org.apache.pig.PigServer.registerCode(PigServer.java:567)
at org.apache.pig.tools.grunt.GruntParser.processRegister(GruntParser.java:421)
at org.apache.pig.tools.pigscript.parser.PigScriptParser.parse(PigScriptParser.java:419)
at org.apache.pig.tools.grunt.GruntParser.parseStopOnError(GruntParser.java:188)
at org.apache.pig.tools.grunt.GruntParser.parseStopOnError(GruntParser.java:164)
at org.apache.pig.tools.grunt.Grunt.exec(Grunt.java:81)
at org.apache.pig.Main.run(Main.java:427)
at org.apache.pig.Main.main(Main.java:108)
Caused by: java.lang.ClassNotFoundException: org.python.core.PyException
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)
... 9 more
================================================================================
I am guessing its because of the first line.. REGISTER udf.py USING jython AS udf;
and that I have to specify jython path? (since i am running this code on cluster.. i dont think i have set this thing up)..
Now... since i dont know much of java.. hence switched on python ... but how do i make this code run??
What sort of setup i have to do on my env... to debug this problem.
Thanks
Add $PIG_HOME/lib/jython.jar to your PIG_CLASSPATH environment variable.

Categories

Resources