What are the JARs required for Hadoop project at startup? - java

This must seem like an idiotic question but I am new to Hadoop and was trying to run a simple example. However, I keep running into problems with JAR files and dont seem to have the correct imports. I am using cloudera CDH 4 and it has a hole lot of JAR files to choose from with several versions of each. Since I am just starting off am not being able to differentiate. Presently i am getting this exception :
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/configuration/Configuration
at org.apache.hadoop.metrics2.lib.DefaultMetricsSystem.<init>(DefaultMetricsSystem.java:38)
at org.apache.hadoop.metrics2.lib.DefaultMetricsSystem.<clinit>(DefaultMetricsSystem.java:36)
at org.apache.hadoop.security.UserGroupInformation$UgiMetrics.create(UserGroupInformation.java:120)
at org.apache.hadoop.security.UserGroupInformation.<clinit>(UserGroupInformation.java:236)
at org.apache.hadoop.mapreduce.task.JobContextImpl.<init>(JobContextImpl.java:72)
at org.apache.hadoop.mapreduce.Job.<init>(Job.java:144)
at org.apache.hadoop.mapreduce.Job.<init>(Job.java:131)
at org.apache.hadoop.mapreduce.Job.<init>(Job.java:139)
at com.ayon.hadoop.firstimpl.Driver1.main(Driver1.java:23)Caused by: java.lang.ClassNotFoundException: org.apache.commons.configuration.Configuration
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)
... 9 more
It is probably because of a wrong JAR file import. So my question is this:
Can anyone tell me what are the basic JAR files needed to start up a simple Hadoop job? Also any pointers to the above exception will be much appreciated.

To include all the necessary jar files, compile your code using the following command:
# javac -cp `$HADOOP_HOME\bin\hadoop classpath` YourClassFile.java
Please note the quotes

If you're using Eclipse, follow below steps to add JARs to your project
1.Right click on the project
2.Go to Properties
3.Click on "Java Build Path"
4.Libraries Tab
5.Add External JARs
6.Select the path "/usr/local/hadoop"
7.Select all "JAR files" & add all JARs
8.Again "Add EXternal JARs"
9.Go to path "/usr/local/hadoop/lib"
10.ADD all JARs in there
11.Click "Ok"
You're set. Hope this helps.. again it depends on the Eclipse version you're using.

Related

Application runs fine in Intellij but doesn't work when packaged into an exe file

I have built a very simple command line application using picocli and I would like to package it into an executable file. I first packaged it into a jar file using Maven package, and then used Launch4J as recommended by several users on SO to obtain an executable. However, it throws the NoClassDefFound error, when I run Application.exe in the command prompt.
> Exception in thread "main" java.lang.NoClassDefFoundError:
> picocli/CommandLine
> at mycli.HelloCli.main(HelloCli.java:48)
> Caused by: java.lang.ClassNotFoundException: picocli.CommandLine
> at java.net.URLClassLoader.findClass(Unknown Source)
> at java.lang.ClassLoader.loadClass(Unknown Source)
> at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
> at java.lang.ClassLoader.loadClass(Unknown Source)
> ... 1 more
The application works perfectly well when executed in IntelliJ. I tried adding the custom jar file I created by looking at answers similar to these but it doesn't seem to help. I also tried changing the folder of execution but that doesn't solve the error either.
From several answers I searched across SO, I realized that the picocli jar needed to be on the class path. So I added the "Main class" as the one containing my main method, and specified the "Classpath" to the jar file created by building an artifact out of all the dependencies present, while configuring Launch4J.
For details on how to build an artifact jar out of a project's dependencies, visit this answer if you use Eclipse, or this answer if you use IntelliJ.)

Where can I add javax.media.jai Jar package in Java?

I am getting class not found(javax.media.jai.JAI) exception while running my code. I have downloaded(https://www.oracle.com/java/technologies/java-archive-downloads-java-client-downloads.html#jai-1_1_2_01-oth-JPR) the JAI jar and added in Project lib folder but not working getting same error again. where can I add this jar. Please advise.
Note : The is old servlet project structure there is no Maven features.
Error Log:
java.lang.ClassNotFoundException: javax.media.jai.JAI
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1365)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1188)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
enter image description here
You can go to build path and add ur external jars by downloading it online.

Unable to find bluecove jar while executing the project as a .jar

My Java Swing application works fine when I run it from eclipse. But when I try to run it as a jar file, it fails to recognise my referenced libraries (bluecove-2.1.1-SNAPSHOT.jar) and gives me the following error:
Exception in thread "main" java.lang.NoClassDefFoundError: javax/bluetooth/UUID
Caused by: java.lang.ClassNotFoundException: javax.bluetooth.UUID
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)
Is there something wrong in the way I am creating the jar file or is there some issue with the bluecove jar itself?
this is simple
right click on project-->Build Path-->Configure build path-->Order and Export
and check wheather bluecove library is marked if not check mark
The problem was that I was trying to export it to a jar and then manually adding the main class in manifest.MD and the jars it was using. All I had to do was export it to an 'executable' jar and check the extract all jars option while exporting :)

Java - NoClassDefFoundError although the class exists

I'm still very new to Java. I'm trying to use CMU's Sphinx4 voice recognition. When I used the compiling process they have prepared, everything worked fine. However, now that I'm trying to compile my own code separately I'm running into a problem.
In the codes source files (src/) exists an apps/ directory which contains the demos I'm trying to compile manually, along with a sphinx4/ directory which contains the main functions to be used. To compile the code I move into the apps/ directory and run
javac -classpath ../sphinx4/ edu/cmu/sphinx/demo/helloworld/HelloWorld.java. This compiles without error. However, then when I try to run the newly made class using java edu/cmu/sphinx/demo/helloworld/HelloWorld the result is:
Exception in thread "main" java.lang.NoClassDefFoundError: edu/cmu/sphinx/util/props/ConfigurationManager
at edu.cmu.sphinx.demo.helloworld.HelloWorld.main(HelloWorld.java:33)
Caused by: java.lang.ClassNotFoundException: edu.cmu.sphinx.util.props.ConfigurationManager
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:423)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
... 1 more
Yet, as far as I can tell, the class does exist right where it should be. src/sphinx4/edu/cmu/sphinx/util/props/ConfigurationManager.class exists. I'm guessing there is a good reason that it is considered not found when it is there, but I just don't know it because I don't know enough about Java yet. What might cause this to happen?
Thank you for your time!
Two problems:
You need to specify the classpath when you run as well as when you compile
You need to specify a class name to run; that won't have slashes in
You want:
java -classpath .:../sphinx4 edu.cmu.sphinx.demo.helloworld.HelloWorld
Use ";" instead of ":" if you're running on Windows.
(Your error message suggests that you actually are giving the right class name, in which case your question hasn't really shown what you're doing. It's important to be accurate in your question, in order to get helpful answers.)
Look:
Note 4:
If you have the source distribution, make sure that the JAR file lib/sphinx4.jar is built. If not, go to the top level directory and type: ant.
You should probably use ant to build the project with your new class(es).
Did you follow the instructions here: http://cmusphinx.sourceforge.net/sphinx4/#how_build ?
Good luck!

Unable to start tomcat server in netbeans and eclipse

I am trying to run Tomcat 6.0.18 from Netbeans 6.7 but getting the following output
on the server console.
java.lang.NoClassDefFoundError: org/apache/juli/logging/LogFactory
at org.apache.catalina.startup.Bootstrap.<clinit>(Bootstrap.java:54)
Caused by: java.lang.ClassNotFoundException: org.apache.juli.logging.LogFactory
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 sun.misc.Launcher$ExtClassLoader.findClass(Launcher.java:229)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
I have tried reinstalling , tried different versions of tomcat viz. 6.0.24 , 7.0.16 , 5.5 etc , shifted from eclipse to netbeans to but don't why it is coming. In one of the replies for the same it was suggested to add $CATALINA_HOME\bin\tomcat-juli.jar to the launch configuraton in case of eclipse but in netbeans this library along with the others in lib folder have already been added. still the situation is same :(
try this , it has solved the problem
it seems that the META-INF/MANIFEST.MF file in the bootstrap.jar contains a no reference for
tomcat-juli.jar
just add/update this entry in META-INF/MANIFEST.MF file in the bootstrap.jar
Class-Path: commons-daemon.jar tomcat-juli.jar
and then try to run the tomcat sever
Hi,I have just begun to learn, also encountered the same problem, and finally I get through the following steps:
Tomcat v7.0 Apache Open,
Information Overview in General launch
Open configuration >Edit >Configuration, >Classpath, >Entries,
External TOMCAT_HOME/bin/tomcat-juli.jar
restart your lomboz
For more information,you can view this picture,hope this will fix your problems.
For some reason, the tomcat-juli.jar (or whichever JAR contains org.apache.juli.logging.LogFactory) isn't added to the classpath.
You don't say how you start tomcat (Eclipse Tomcat plugin, Web Tools, ANT script, ...) so it's hard to say why it's not there. If you can, add a breakpoint in URLClassLoader.java:202 and examine the result of calling getURLs() (see point #5 in 5 Tips for Debugging Java Code in Eclipse).
Bootstrap.jar is missing that is why this Exception is coming

Categories