google data api for youtube - java

I'm trying to run the sample program, which comes with Google Data API. I get a runtime error at following line
YouTubeService myService = new YouTubeService("gdataSample-YouTube-1");
The error is the following:
run:
Exception in thread "main" java.lang.NoClassDefFoundError: com/google/common/collect/Maps
at com.google.gdata.wireformats.AltRegistry.<init>(AltRegistry.java:118)
at com.google.gdata.wireformats.AltRegistry.<init>(AltRegistry.java:100)
at com.google.gdata.client.Service.<clinit>(Service.java:532)
at YouTubeReadonlyClient.main(YouTubeReadonlyClient.java:713)
Caused by: java.lang.ClassNotFoundException: com.google.common.collect.Maps
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)
... 4 more
Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)
I tried both Google Data API versions 1.35.0 and 1.35.1, and I get the same error in both cases.

Looks like you don't have the collections library in your class path.
It's in the gdata/java/deps directory in the zip file. Include the google-collect-1.0-rc1.jar file in your classpath and you should be fine. (You may also need jsr305.jar - I'm not sure.)

Three little steps:
Download the zip file from
http://www.docjar.com/jar_detail/google-collect-1.0-rc1.jar.html
Extract the zip file
Add the jar to your build path.

Related

Hbase example, Exception in thread "main" java.lang.NoClassDefFoundError

We are trying to execute basic Hbase example on hortonworks sandbox (2.3).
hadoop jar /usr/hdp/2.3.0.0-2557/hbase/lib/hbase-examples.jar org.apache.hadoop.hbase.mapreduce.IndexBuilder
We are getting below exception after executing this program.
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/hadoop/hbase/util/Bytes
at org.apache.hadoop.hbase.mapreduce.IndexBuilder.<clinit>(IndexBuilder.java:67)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:278)
at org.apache.hadoop.util.RunJar.run(RunJar.java:214)
at org.apache.hadoop.util.RunJar.main(RunJar.java:136)
Caused by: java.lang.ClassNotFoundException: org.apache.hadoop.hbase.util.Bytes
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
... 5 more
Based on this error we tried to set the Hadoop classpath in Hbase-env.sh.
/usr/hdp/2.3.0.0-2557/hbase/lib/hbase-client-1.1.1.2.3.0.0-2557.jar:/usr/hdp/2.3.0.0-2557/hbase/lib/hbase-common-1.1.1.2.3.0.0-2557.jar:/usr/hdp/2.3.0.0-2557/hbase/lib/protobuf-java-2.5.0.jar:/usr/hdp/2.3.0.0-2557/hbase/lib/guava-12.0.1.jar:$/usr/hdp/2.3.0.0-2557/hbase/lib/zookeeper.jar:/usr/hdp/2.3.0.0-2557/hbase/lib/hbase-protocol-1.1.1.2.3.0.0-2557.jar:/usr/hdp/2.3.0.0-2557/hbase/lib/commons-configuration-1.6.jar:/usr/hdp/2.3.0.0-2557/hbase/lib/hadoop-common.jar:/usr/hdp/2.3.0.0-2557/hbase/lib/hbase-0.94.27.jar
But still getting the same error.
Instead of manually adding jars into classpath you can directly use below command.
$(hbase classpath) recursively search in hortonworks hadoop folders and finds the required jars from sandbox.
HADOOP_CLASSPATH=$(hbase classpath):/usr/hdp/2.3.0.0-2557/hbase/conf hadoop jar /usr/hdp/2.3.0.0-2557/hbase/lib/hbase-examples.jar org.apache.hadoop.hbase.mapreduce.IndexBuilder
When I face NoClassDefFoundError error with mapreduce, I add jar using one of the jar class in JobBuilder to resolve it.
e.g.
Job job = new Job(conf);
job.setJarByClass(org.apache.hadoop.hbase.util.Bytes.class);
Supply jars using libjars parameter to your job-
e.g.
LIB=hbase-x.x.x.jar
hadoop jar /usr/hdp/2.3.0.0-2557/hbase/lib/hbase-examples.jar org.apache.hadoop.hbase.mapreduce.IndexBuilder -libjars ${LIB}
you can also add jar to HADOOP_CLASSPATH variable before launch job.
Is all the latest code included in the jar? Use a java decompiler such as jd-gui to look inside the jar file to make sure this class you are referencing is actually there. Also check that the necessary import statements are present in the Java class.

Java program that uses pptx4j throws org/apache/commons/lang/NotImplementedException

I'm using sample code from www.docx4java.org to run the program that will create a powerpoint slide so that i can learn the use of the docx4j library. But it gives me an exception even tough i have already added both commons-logging-1.2.jar and commons-logging-1.2-javadoc.jar to my classpaths library as (in which i also have apache-logging-log4j.jar, docx4j-3.2.1.jar, slf4j-nop-1.6.1 and slf4j-api-1.7.5.jar). This is the output:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/lang/NotImplementedException
at org.docx4j.openpackaging.packages.PresentationMLPackage.createPackage(PresentationMLPackage.java:169)
at org.docx4j.openpackaging.packages.PresentationMLPackage.createPackage(PresentationMLPackage.java:146)
at org.docx4j.samples.CreateHelloWorld.main(CreateHelloWorld.java:30)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.lang.NotImplementedException
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
... 3 more
Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)
Is there an incompatibility betweent the jars i am using or am i missing more jar files to work with pptx4j?
Originally i added docx4j-3.2.1.jar and slf4j-api-1.7.5.jar to work with this sample code that creates a word file. But with the pptx4j i haven't found a solution, shouldn't it work since i already have apache-logging-log4j and commons-logging-1.2?
It's not throwing org/apache/commons/lang/NotImplementedException, it's saying it can't find it:
NoClassDefFoundError: org/apache/commons/lang/NotImplementedException
You need to add Apache Commons Lang v2.x (not v3, that uses a different package name to the one the error mentions) to your classpath.

Install and compile JacORB

I was following this tutorial to install JacORB Tutorial. In the last step, when I want to compile it, I got this error
Buildfile: /Users/adm/Downloads/jacorb/build.xml
base-init:
init-properties:
init-path:
init-javac-common:
init-javac-jdk:
init-javac-j2me:
init:
src-check:
BUILD FAILED
/Users/adm/Downloads/jacorb/build.xml:21: Unable to find src files. Is this a binary distribution?
But if I try ant in a demo file it builde successfully. I don't have to do the last step in the tutorial ? The second question is how to excute the build file ? after I builded the hello demo, I tried "jaco build" but I got a java exception
jaco build
Exception in thread "main" java.lang.NoClassDefFoundError: build
Caused by: java.lang.ClassNotFoundException: build
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)
You likely have the binary distribution of JacORB.
Download the source distribution of JacORB instead. On the JacORB Download page, click the link for Full source code.
Or see https://github.com/JacORB/JacORB/ for the official source code.
I would recommend asking questions about JacORB on the jacorb-developer list (http://www.jacorb.org/contact.html)

How to fix: Exception in thread "main" java.lang.NoClassDefFoundError in BoneCP

I'm working from this example and I am running into this error after adding log4j, slf4j and bonecp to the project:
run:
Exception in thread "main" java.lang.NoClassDefFoundError: com/google/common/base/FinalizableReferenceQueue
at com.jolbox.bonecp.BoneCP.<init>(BoneCP.java:321)
at javasampleapps.BoneCPExample.main(BoneCPExample.java:35)
Caused by: java.lang.ClassNotFoundException: com.google.common.base.FinalizableReferenceQueue
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)
... 2 more
Java Result: 1
BUILD SUCCESSFUL (total time: 3 seconds)
In addition to BoneCP and SLF4J, you need to add Google Guava, because BoneCP's requirements page states that it needs to be present. Download guava-*.jar and add it to your classpath the same way you did with SLF4J and BoneCP.
You will need to add those jars to the classpath of your Java process when you run it. For example,
java -classpath lib/log4j.jar;lib/slf4j.jar;lib/bonecp.jar [your_class]
This assumes that the jars are in a dir called lib which is in the directory you execute the Java command from.

Can any one help in following problem in Netbeans running java code

This happens when I try to run my project in netbeans 6.9.1 and there is no error in any java files.
debug:
Have no file for C:\Program Files (x86)\Java\jdk1.6.0_24\jre\lib\modules\jdk.boot.jar
java.lang.NoClassDefFoundError: qkd/QKDApp
Caused by: java.lang.ClassNotFoundException: qkd.QKDApp
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:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
Could not find the main class: qkd.QKDApp. Program will exit.
Exception in thread "main" Java Result: 1
BUILD SUCCESSFUL (total time: 2 seconds)
In your project properties (right click on your project and select properties). Select under categories Run. Check the setting for your main class. I expect it is still set to qkd.QKDApp enter the class name of your new main class.

Categories

Resources