cluster analysis - Running Kmeans Clustering example with Maven (Mahout in Action) -
i'm considering same example in how run examples in mahout in action book, want use maven run it. builds fine
> mvn clean -dskiptests package
but when try run it:
> java -cp target/k-means-1.0-snapshot.jar clustering.kmeans error: jni error has occurred, please check installation , try again exception in thread "main" java.lang.noclassdeffounderror: org/apache/mahout/math/vector @ java.lang.class.getdeclaredmethods0(native method) @ java.lang.class.privategetdeclaredmethods(class.java:2701) @ java.lang.class.privategetmethodrecursive(class.java:3048) @ java.lang.class.getmethod0(class.java:3018) @ java.lang.class.getmethod(class.java:1784) @ sun.launcher.launcherhelper.validatemainclass(launcherhelper.java:544) @ sun.launcher.launcherhelper.checkandloadmain(launcherhelper.java:526) caused by: java.lang.classnotfoundexception: org.apache.mahout.math.vector @ java.net.urlclassloader.findclass(urlclassloader.java:381) @ java.lang.classloader.loadclass(classloader.java:424) @ sun.misc.launcher$appclassloader.loadclass(launcher.java:331) @ java.lang.classloader.loadclass(classloader.java:357) ... 7 more
this strange, since included mahout-math-0.7 in pom.xml, , manually checked includes vector.class. what's going wrong? need use hadoop rather java, or there wrong pom.xml? i'm assuming having http://maven.apache.org fine if i'm pulling http://mvnrepository.com/ ...
for reference, here's have in pom.xml:
<project xmlns="http://maven.apache.org/pom/4.0.0" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://maven.apache.org/pom/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelversion>4.0.0</modelversion> <groupid>clustering</groupid> <artifactid>k-means</artifactid> <packaging>jar</packaging> <version>1.0-snapshot</version> <name>k-means</name> <url>http://maven.apache.org</url> <dependencies> <dependency> <groupid>junit</groupid> <artifactid>junit</artifactid> <version>3.8.1</version> <scope>test</scope> </dependency> <dependency> <groupid>org.apache.mahout</groupid> <artifactid>mahout-mr</artifactid> <version>0.10.0</version> </dependency> <dependency> <groupid>org.apache.mahout</groupid> <artifactid>mahout-core</artifactid> <version>0.7</version> </dependency> <dependency> <groupid>org.apache.mahout</groupid> <artifactid>mahout-math</artifactid> <version>0.7</version> </dependency> </dependencies> </project>
and here imports:
import org.apache.hadoop.conf.configuration; import org.apache.hadoop.fs.filesystem; import org.apache.hadoop.fs.path; import org.apache.hadoop.io.intwritable; import org.apache.hadoop.io.longwritable; import org.apache.hadoop.io.sequencefile; import org.apache.hadoop.io.text; import org.apache.mahout.clustering.cluster; import org.apache.mahout.clustering.classify.weightedpropertyvectorwritable; import org.apache.mahout.clustering.kmeans.kmeansdriver; import org.apache.mahout.clustering.kmeans.kluster; import org.apache.mahout.common.distance.euclideandistancemeasure; import org.apache.mahout.math.randomaccesssparsevector; import org.apache.mahout.math.vector; import org.apache.mahout.math.vectorwritable; import java.io.file; import java.io.ioexception; import java.util.arraylist; import java.util.list;
you classpath doesn't include jars.
also don't mix versions.
Comments
Post a Comment