You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@mahout.apache.org by Sameer Tilak <ss...@live.com> on 2013/12/19 22:33:17 UTC

More on Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/mahout/math/Vector

Hi Everyone,

I have added math jar file to my javac command. As per the documentation, " Include the JAR in the “-libjars” command line option of the `hadoop jar …` command. The jar will be placed in distributed cache and will be made available to all of the job’s task attempts. " Ideally, this would make the all mahout jars available in the distributed cache and available to all the tasktrackers. I am not sure what other steps I need to do to resolve this issue.


javac -d /apps/analytics/ -classpath .:/apps/mahout/trunk/core/target/mahout-core-0.9-SNAPSHOT.jar:/users/p529444/software/hadoop-1.0.3/hadoop-core-1.0.3.jar:/apps/mahout/trunk/core/target/mahout-core-0.9-SNAPSHOT-job.jar:/apps/mahout/trunk/math/target/mahout-math-0.9-SNAPSHOT.jar  SimpleKMeansClustering.java
-bash-4.1$ jar -cf myanalytics.jar  myanalytics/
-bash-4.1$ hadoop jar /apps/analytics/myanalytics.jar myanalytics.SimpleKMeansClustering -libjars /apps/mahout/trunk/core/target/mahout-core-0.9-SNAPSHOT.jar /apps/mahout/trunk/core/target/mahout-core-0.9-SNAPSHOT-job.jar:/apps/mahout/trunk/math/target/mahout-math-0.9-SNAPSHOT.jar
Warning: $HADOOP_HOME is deprecated.

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/mahout/math/Vector
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:264)
    at org.apache.hadoop.util.RunJar.main(RunJar.java:149)
Caused by: java.lang.ClassNotFoundException: org.apache.mahout.math.Vector
    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 java.lang.ClassLoader.loadClass(ClassLoader.java:356)
    ... 3 more


jar -tf /apps/mahout/trunk/math/target/mahout-math-0.9-SNAPSHOT.jar | grep "Vector"
Shows a bunch of classes including the following:
org/apache/mahout/math/VectorBinaryAggregate$AggregateIterateUnionSequential.class
org/apache/mahout/math/RandomAccessSparseVector$NonDefaultIterator.class
org/apache/mahout/math/Vector.class
org/apache/mahout/math/VectorBinaryAggregate$AggregateAllLoop.class
org/apache/mahout/math/VectorView$DecoratorElement.class
org/apache/mahout/math/VectorView.class

 		 	   		  

RE: More on Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/mahout/math/Vector

Posted by Sameer Tilak <ss...@live.com>.
Hi,I was able to resolve this problem by adding the jar files to HADOOP_CLASSPATH. Here is a command sequence:
export HADOOP_CLASSPATH=~/software/hadoop-1.0.3/hadoop-core-1.0.3.jar:/apps/mahout/trunk/core/target/mahout-core-0.9-SNAPSHOT.jar:/apps/mahout/trunk/core/target/mahout-core-0.9-SNAPSHOT-job.jar:/apps/mahout/trunk/math/target/mahout-math-0.9-SNAPSHOT.jar
javac -d /apps/analytics/ -classpath .:/apps/mahout/trunk/core/target/mahout-core-0.9-SNAPSHOT.jar:/users/p529444/software/hadoop-1.0.3/hadoop-core-1.0.3.jar:/apps/mahout/trunk/core/target/mahout-core-0.9-SNAPSHOT-job.jar:/apps/mahout/trunk/math/target/mahout-math-0.9-SNAPSHOT.jar SimpleKMeansClustering.java
jar -cf myanalytics.jar myanalytics/

hadoop jar /apps/analytics/myanalytics.jar myanalytics.SimpleKMeansClustering -libjars /apps/mahout/trunk/core/target/mahout-core-0.9-SNAPSHOT.jar /apps/mahout/trunk/core/target/mahout-core-0.9-SNAPSHOT-job.jar:/apps/mahout/trunk/math/target/mahout-math-0.9-SNAPSHOT.jar
Thanks!

> From: sstilak@live.com
> To: user@mahout.apache.org
> Subject: More on Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/mahout/math/Vector
> Date: Thu, 19 Dec 2013 13:33:17 -0800
> 
> Hi Everyone,
> 
> I have added math jar file to my javac command. As per the documentation, " Include the JAR in the “-libjars” command line option of the `hadoop jar …` command. The jar will be placed in distributed cache and will be made available to all of the job’s task attempts. " Ideally, this would make the all mahout jars available in the distributed cache and available to all the tasktrackers. I am not sure what other steps I need to do to resolve this issue.
> 
> 
> javac -d /apps/analytics/ -classpath .:/apps/mahout/trunk/core/target/mahout-core-0.9-SNAPSHOT.jar:/users/p529444/software/hadoop-1.0.3/hadoop-core-1.0.3.jar:/apps/mahout/trunk/core/target/mahout-core-0.9-SNAPSHOT-job.jar:/apps/mahout/trunk/math/target/mahout-math-0.9-SNAPSHOT.jar  SimpleKMeansClustering.java
> -bash-4.1$ jar -cf myanalytics.jar  myanalytics/
> -bash-4.1$ hadoop jar /apps/analytics/myanalytics.jar myanalytics.SimpleKMeansClustering -libjars /apps/mahout/trunk/core/target/mahout-core-0.9-SNAPSHOT.jar /apps/mahout/trunk/core/target/mahout-core-0.9-SNAPSHOT-job.jar:/apps/mahout/trunk/math/target/mahout-math-0.9-SNAPSHOT.jar
> Warning: $HADOOP_HOME is deprecated.
> 
> Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/mahout/math/Vector
>     at java.lang.Class.forName0(Native Method)
>     at java.lang.Class.forName(Class.java:264)
>     at org.apache.hadoop.util.RunJar.main(RunJar.java:149)
> Caused by: java.lang.ClassNotFoundException: org.apache.mahout.math.Vector
>     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 java.lang.ClassLoader.loadClass(ClassLoader.java:356)
>     ... 3 more
> 
> 
> jar -tf /apps/mahout/trunk/math/target/mahout-math-0.9-SNAPSHOT.jar | grep "Vector"
> Shows a bunch of classes including the following:
> org/apache/mahout/math/VectorBinaryAggregate$AggregateIterateUnionSequential.class
> org/apache/mahout/math/RandomAccessSparseVector$NonDefaultIterator.class
> org/apache/mahout/math/Vector.class
> org/apache/mahout/math/VectorBinaryAggregate$AggregateAllLoop.class
> org/apache/mahout/math/VectorView$DecoratorElement.class
> org/apache/mahout/math/VectorView.class
> 
>