2013-11-27 91 views
1

我已经创造了一个的IntelliJ Maven项目有三个类文件:行家的IntelliJ的Java MapReduce的测试程序

package mavenKris; 

import org.apache.hadoop.io.Text; 
import org.apache.hadoop.mapreduce.Mapper; 

import java.io.IOException; 
import java.util.StringTokenizer; 

/** 
* Created with IntelliJ IDEA. 
* User: kshk 
* Date: 11/27/13 
* Time: 2:27 PM 
* To change this template use File | Settings | File Templates. 
*/ 
public class WordMapper extends Mapper<Text,Text,Text,Text> { 
    private Text word = new Text(); 
    public void map(Text key, Text value, Context context) throws IOException, InterruptedException 
    { 
     StringTokenizer itr = new StringTokenizer(value.toString(),","); 
     while (itr.hasMoreTokens()) 
     { 
      word.set(itr.nextToken()); 
      context.write(key, word); 
     } 
    } 
} 

package mavenKris; 

import org.apache.hadoop.io.Text; 
import org.apache.hadoop.mapreduce.Reducer; 

import java.io.IOException; 

/** 
* Created with IntelliJ IDEA. 
* User: kshk 
* Date: 11/27/13 
* Time: 2:29 PM 
* To change this template use File | Settings | File Templates. 
*/ 
public class AllTranslationsReducer extends Reducer<Text, Text, Text, Text> { 
    private Text result = new Text(); 
    @Override 
    protected void reduce(Text key, Iterable<Text> values, Context context) throws IOException, InterruptedException { 
     String translations = ""; 
     for (Text val : values) { 
      translations += "|" + val.toString(); 
     } 
     result.set(translations); 
     context.write(key, result); 
    } 
} 

和主...

package mavenKris; 

import org.apache.hadoop.conf.Configuration; 
import org.apache.hadoop.fs.Path; 
import org.apache.hadoop.io.Text; 
import org.apache.hadoop.mapreduce.Job; 
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat; 
import org.apache.hadoop.mapreduce.lib.input.KeyValueTextInputFormat; 
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat; 
import org.apache.hadoop.mapreduce.lib.output.TextOutputFormat; 

import java.io.IOException; 

/** 
* Created with IntelliJ IDEA. 
* User: kshk 
* Date: 11/27/13 
* Time: 2:30 PM 
* To change this template use File | Settings | File Templates. 
*/ 
public class Dictionary { 
    public static void main(String[] args) throws Exception 
    { 
     Configuration conf = new Configuration(); 
     Job job = new Job(conf, "dictionary"); 
     job.setJarByClass(Dictionary.class); 
     job.setMapperClass(WordMapper.class); 
     job.setReducerClass(AllTranslationsReducer.class); 
     job.setOutputKeyClass(Text.class); 
     job.setOutputValueClass(Text.class); 
     job.setMapOutputKeyClass(Text.class); 
     job.setMapOutputValueClass(Text.class); 
     job.setInputFormatClass(KeyValueTextInputFormat.class); 
     job.setOutputFormatClass(TextOutputFormat.class); 
     FileInputFormat.addInputPath(job, new Path(args[0])); 
     FileOutputFormat.setOutputPath(job, new Path(args[1])); 
     boolean result = job.waitForCompletion(true); 
     System.exit(result ? 0 : 1); 
    } 
} 

和这就是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/xsd/maven-4.0.0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 

    <groupId>mavenKris</groupId> 
    <artifactId>mavenKris</artifactId> 
    <version>1.0-SNAPSHOT</version> 
    <packaging>jar</packaging> 

    <name>mavenKris</name> 
    <url>http://maven.apache.org</url> 
    <repositories> 
     <repository> 
      <id>anorak-releases</id> 
      <url>http://ip-10-40-3-96.cloud.trendinglines.co.uk:8081/nexus/content/repositories/releases/</url> 
      <releases> 
       <enabled>true</enabled> 
      </releases> 
      <snapshots> 
       <enabled>false</enabled> 
      </snapshots> 
     </repository> 

     <repository> 
      <id>atlassian-releases</id> 
      <url>http://repository.opencastproject.org/nexus/content/repositories/atlassian/</url> 
      <releases> 
       <enabled>true</enabled> 
      </releases> 
      <snapshots> 
       <enabled>false</enabled> 
      </snapshots> 
     </repository> 

     <repository> 
      <id>central</id> 
      <name>Maven Central</name> 
      <url>http://repo1.maven.org/maven2/</url> 
     </repository> 
    </repositories> 


    <properties> 
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
    </properties> 

    <dependencies> 
    <dependency> 
     <groupId>junit</groupId> 
     <artifactId>junit</artifactId> 
     <version>3.8.1</version> 
     <scope>test</scope> 
    </dependency> 
     <dependency> 
      <groupId>org.apache.hadoop</groupId> 
      <artifactId>hadoop-core</artifactId> 
      <version>1.0.3-gphd-1.2.0.0</version> 
      <scope>provided</scope> 
     </dependency> 
    </dependencies> 

</project> 

我使用Hadoop的Greenplum的分布,now..when我运行上面的项目中,我得到这个错误....

/usr/java/jdk1.7.0_40/bin/java -Didea.launcher.port=7551 -Didea.launcher.bin.path=/home/kshk/Software/idea-IC-129.1359/bin -Dfile.encoding=UTF-8 -classpath /usr/java/jdk1.7.0_40/jre/lib/jce.jar:/usr/java/jdk1.7.0_40/jre/lib/management-agent.jar:/usr/java/jdk1.7.0_40/jre/lib/resources.jar:/usr/java/jdk1.7.0_40/jre/lib/jfr.jar:/usr/java/jdk1.7.0_40/jre/lib/jsse.jar:/usr/java/jdk1.7.0_40/jre/lib/rt.jar:/usr/java/jdk1.7.0_40/jre/lib/plugin.jar:/usr/java/jdk1.7.0_40/jre/lib/deploy.jar:/usr/java/jdk1.7.0_40/jre/lib/charsets.jar:/usr/java/jdk1.7.0_40/jre/lib/javaws.jar:/usr/java/jdk1.7.0_40/jre/lib/jfxrt.jar:/usr/java/jdk1.7.0_40/jre/lib/ext/zipfs.jar:/usr/java/jdk1.7.0_40/jre/lib/ext/localedata.jar:/usr/java/jdk1.7.0_40/jre/lib/ext/sunpkcs11.jar:/usr/java/jdk1.7.0_40/jre/lib/ext/sunec.jar:/usr/java/jdk1.7.0_40/jre/lib/ext/dnsns.jar:/usr/java/jdk1.7.0_40/jre/lib/ext/sunjce_provider.jar:/home/kshk/IdeaProjects/mavenKris/target/classes:/home/kshk/Software/idea-IC-129.1359/lib/idea_rt.jar com.intellij.rt.execution.application.AppMain mavenKris.Dictionary 
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/hadoop/conf/Configuration 
    at mavenKris.Dictionary.main(Dictionary.java:24) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
    at java.lang.reflect.Method.invoke(Method.java:606) 
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120) 
Caused by: java.lang.ClassNotFoundException: org.apache.hadoop.conf.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:424) 
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) 
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357) 
    ... 6 more 

Process finished with exit code 1 

什么想法?

UPDATE:

如果我指定命令行从类路径叫Dictionary类的路径,但给人的错误,所以必须有我的IDE一些设置不speciying类路径hadoop-核心运行时.....

[[email protected] mavenKris]$ /usr/java/jdk1.7.0_40/bin/java -Didea.launcher.port=7537 -Didea.launcher.bin.path=/home/kshk/Software/idea-IC-129.1359/bin -Dfile.encoding=UTF-8 -classpath /usr/java/jdk1.7.0_40/jre/lib/jce.jar:/usr/java/jdk1.7.0_40/jre/lib/management-agent.jar:/usr/java/jdk1.7.0_40/jre/lib/resources.jar:/usr/java/jdk1.7.0_40/jre/lib/jfr.jar:/usr/java/jdk1.7.0_40/jre/lib/jsse.jar:/usr/java/jdk1.7.0_40/jre/lib/rt.jar:/usr/java/jdk1.7.0_40/jre/lib/plugin.jar:/usr/java/jdk1.7.0_40/jre/lib/deploy.jar:/usr/java/jdk1.7.0_40/jre/lib/charsets.jar:/usr/java/jdk1.7.0_40/jre/lib/javaws.jar:/usr/java/jdk1.7.0_40/jre/lib/jfxrt.jar:/usr/java/jdk1.7.0_40/jre/lib/ext/zipfs.jar:/usr/java/jdk1.7.0_40/jre/lib/ext/localedata.jar:/usr/java/jdk1.7.0_40/jre/lib/ext/sunpkcs11.jar:/usr/java/jdk1.7.0_40/jre/lib/ext/sunec.jar:/usr/java/jdk1.7.0_40/jre/lib/ext/dnsns.jar:/usr/java/jdk1.7.0_40/jre/lib/ext/sunjce_provider.jar:/home/kshk/IdeaProjects/mavenKris/target/classes:/home/kshk/Software/idea-IC-129.1359/lib/idea_rt.jar:/home/kshk/.m2/repository/org/apache/hadoop/hadoop-core/1.0.3-gphd-1.2.0.0/hadoop-core-1.0.3-gphd-1.2.0.0.jar com.intellij.rt.execution.application.AppMain mavenKris.Dictionary 
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory 
    at org.apache.hadoop.conf.Configuration.<clinit>(Configuration.java:143) 
    at mavenKris.Dictionary.main(Dictionary.java:25) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
    at java.lang.reflect.Method.invoke(Method.java:606) 
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120) 
Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory 
    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:424) 
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) 
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357) 
    ... 7 more 
[[email protected] mavenKris]$ 

UPDATE2:添加路径共享记录-1.0.3.jar后

..........

[[email protected] repository]$ /usr/java/jdk1.7.0_40/bin/java -Didea.launcher.port=7537 -Didea.launcher.bin.path=/home/kshk/Software/idea-IC-129.1359/bin -Dfile.encoding=UTF-8 -classpath /usr/java/jdk1.7.0_40/jre/lib/jce.jar:/usr/java/jdk1.7.0_40/jre/lib/management-agent.jar:/usr/java/jdk1.7.0_40/jre/lib/resources.jar:/usr/java/jdk1.7.0_40/jre/lib/jfr.jar:/usr/java/jdk1.7.0_40/jre/lib/jsse.jar:/usr/java/jdk1.7.0_40/jre/lib/rt.jar:/usr/java/jdk1.7.0_40/jre/lib/plugin.jar:/usr/java/jdk1.7.0_40/jre/lib/deploy.jar:/usr/java/jdk1.7.0_40/jre/lib/charsets.jar:/usr/java/jdk1.7.0_40/jre/lib/javaws.jar:/usr/java/jdk1.7.0_40/jre/lib/jfxrt.jar:/usr/java/jdk1.7.0_40/jre/lib/ext/zipfs.jar:/usr/java/jdk1.7.0_40/jre/lib/ext/localedata.jar:/usr/java/jdk1.7.0_40/jre/lib/ext/sunpkcs11.jar:/usr/java/jdk1.7.0_40/jre/lib/ext/sunec.jar:/usr/java/jdk1.7.0_40/jre/lib/ext/dnsns.jar:/usr/java/jdk1.7.0_40/jre/lib/ext/sunjce_provider.jar:/home/kshk/IdeaProjects/mavenKris/target/classes:/home/kshk/Software/idea-IC-129.1359/lib/idea_rt.jar:/home/kshk/.m2/repository/org/apache/hadoop/hadoop-core/1.0.3-gphd-1.2.0.0/hadoop-core-1.0.3-gphd-1.2.0.0.jar:/home/kshk/.m2/repository/commons-logging/commons-logging/1.0.3/commons-logging-1.0.3.jar com.intellij.rt.execution.application.AppMain mavenKris.Dictionary 
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/configuration/Configuration 
    at org.apache.hadoop.metrics2.lib.DefaultMetricsSystem.<init>(DefaultMetricsSystem.java:37) 
    at org.apache.hadoop.metrics2.lib.DefaultMetricsSystem.<clinit>(DefaultMetricsSystem.java:34) 
    at org.apache.hadoop.security.UgiInstrumentation.create(UgiInstrumentation.java:51) 
    at org.apache.hadoop.security.UserGroupInformation.initialize(UserGroupInformation.java:216) 
    at org.apache.hadoop.security.UserGroupInformation.ensureInitialized(UserGroupInformation.java:184) 
    at org.apache.hadoop.security.UserGroupInformation.isSecurityEnabled(UserGroupInformation.java:236) 
    at org.apache.hadoop.security.KerberosName.<clinit>(KerberosName.java:79) 
    at org.apache.hadoop.security.UserGroupInformation.initialize(UserGroupInformation.java:209) 
    at org.apache.hadoop.security.UserGroupInformation.ensureInitialized(UserGroupInformation.java:184) 
    at org.apache.hadoop.security.UserGroupInformation.isSecurityEnabled(UserGroupInformation.java:236) 
    at org.apache.hadoop.security.UserGroupInformation.getLoginUser(UserGroupInformation.java:466) 
    at org.apache.hadoop.security.UserGroupInformation.getCurrentUser(UserGroupInformation.java:452) 
    at org.apache.hadoop.mapreduce.JobContext.<init>(JobContext.java:80) 
    at org.apache.hadoop.mapreduce.Job.<init>(Job.java:50) 
    at org.apache.hadoop.mapreduce.Job.<init>(Job.java:54) 
    at mavenKris.Dictionary.main(Dictionary.java:26) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
    at java.lang.reflect.Method.invoke(Method.java:606) 
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120) 
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:424) 
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) 
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357) 
    ... 21 more 

更新3:

补充说:/home/kshk/.m2/repository/commons-configuration/commons-configuration/1.6/commons-configuration-1.6.jar到路径... 。

[[email protected] repository]$ /usr/java/jdk1.7.0_40/bin/java -Didea.launcher.port=7537 -Didea.launcher.bin.path=/home/kshk/Software/idea-IC-129.1359/bin -Dfile.encoding=UTF-8 -classpath /usr/java/jdk1.7.0_40/jre/lib/jce.jar:/usr/java/jdk1.7.0_40/jre/lib/management-agent.jar:/usr/java/jdk1.7.0_40/jre/lib/resources.jar:/usr/java/jdk1.7.0_40/jre/lib/jfr.jar:/usr/java/jdk1.7.0_40/jre/lib/jsse.jar:/usr/java/jdk1.7.0_40/jre/lib/rt.jar:/usr/java/jdk1.7.0_40/jre/lib/plugin.jar:/usr/java/jdk1.7.0_40/jre/lib/deploy.jar:/usr/java/jdk1.7.0_40/jre/lib/charsets.jar:/usr/java/jdk1.7.0_40/jre/lib/javaws.jar:/usr/java/jdk1.7.0_40/jre/lib/jfxrt.jar:/usr/java/jdk1.7.0_40/jre/lib/ext/zipfs.jar:/usr/java/jdk1.7.0_40/jre/lib/ext/localedata.jar:/usr/java/jdk1.7.0_40/jre/lib/ext/sunpkcs11.jar:/usr/java/jdk1.7.0_40/jre/lib/ext/sunec.jar:/usr/java/jdk1.7.0_40/jre/lib/ext/dnsns.jar:/usr/java/jdk1.7.0_40/jre/lib/ext/sunjce_provider.jar:/home/kshk/IdeaProjects/mavenKris/target/classes:/home/kshk/Software/idea-IC-129.1359/lib/idea_rt.jar:/home/kshk/.m2/repository/org/apache/hadoop/hadoop-core/1.0.3-gphd-1.2.0.0/hadoop-core-1.0.3-gphd-1.2.0.0.jar:/home/kshk/.m2/repository/commons-logging/commons-logging/1.0.3/commons-logging-1.0.3.jar:/home/kshk/.m2/repository/commons-configuration/commons-configuration/1.6/commons-configuration-1.6.jar com.intellij.rt.execution.application.AppMain mavenKris.Dictionary 
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/lang/StringUtils 
    at org.apache.hadoop.metrics2.lib.MetricMutableStat.<init>(MetricMutableStat.java:59) 
    at org.apache.hadoop.metrics2.impl.MetricsSystemImpl.<init>(MetricsSystemImpl.java:75) 
    at org.apache.hadoop.metrics2.impl.MetricsSystemImpl.<init>(MetricsSystemImpl.java:120) 
    at org.apache.hadoop.metrics2.lib.DefaultMetricsSystem.<init>(DefaultMetricsSystem.java:37) 
    at org.apache.hadoop.metrics2.lib.DefaultMetricsSystem.<clinit>(DefaultMetricsSystem.java:34) 
    at org.apache.hadoop.security.UgiInstrumentation.create(UgiInstrumentation.java:51) 
    at org.apache.hadoop.security.UserGroupInformation.initialize(UserGroupInformation.java:216) 
    at org.apache.hadoop.security.UserGroupInformation.ensureInitialized(UserGroupInformation.java:184) 
    at org.apache.hadoop.security.UserGroupInformation.isSecurityEnabled(UserGroupInformation.java:236) 
    at org.apache.hadoop.security.KerberosName.<clinit>(KerberosName.java:79) 
    at org.apache.hadoop.security.UserGroupInformation.initialize(UserGroupInformation.java:209) 
    at org.apache.hadoop.security.UserGroupInformation.ensureInitialized(UserGroupInformation.java:184) 
    at org.apache.hadoop.security.UserGroupInformation.isSecurityEnabled(UserGroupInformation.java:236) 
    at org.apache.hadoop.security.UserGroupInformation.getLoginUser(UserGroupInformation.java:466) 
    at org.apache.hadoop.security.UserGroupInformation.getCurrentUser(UserGroupInformation.java:452) 
    at org.apache.hadoop.mapreduce.JobContext.<init>(JobContext.java:80) 
    at org.apache.hadoop.mapreduce.Job.<init>(Job.java:50) 
    at org.apache.hadoop.mapreduce.Job.<init>(Job.java:54) 
    at mavenKris.Dictionary.main(Dictionary.java:26) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
    at java.lang.reflect.Method.invoke(Method.java:606) 
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120) 
Caused by: java.lang.ClassNotFoundException: org.apache.commons.lang.StringUtils 
    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:424) 
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) 
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357) 
    ... 24 more 

UPDATE 4:

加入:/home/kshk/.m2/repository/commons-lang/commons-lang/2.1/commons-郎2.1.jar类路径

[[email protected] tmp]$ /usr/java/jdk1.7.0_40/bin/java -Didea.launcher.port=7537 -Didea.launcher.bin.path=/home/kshk/Software/idea-IC-129.1359/bin -Dfile.encoding=UTF-8 -classpath /usr/java/jdk1.7.0_40/jre/lib/jce.jar:/usr/java/jdk1.7.0_40/jre/lib/management-agent.jar:/usr/java/jdk1.7.0_40/jre/lib/resources.jar:/usr/java/jdk1.7.0_40/jre/lib/jfr.jar:/usr/java/jdk1.7.0_40/jre/lib/jsse.jar:/usr/java/jdk1.7.0_40/jre/lib/rt.jar:/usr/java/jdk1.7.0_40/jre/lib/plugin.jar:/usr/java/jdk1.7.0_40/jre/lib/deploy.jar:/usr/java/jdk1.7.0_40/jre/lib/charsets.jar:/usr/java/jdk1.7.0_40/jre/lib/javaws.jar:/usr/java/jdk1.7.0_40/jre/lib/jfxrt.jar:/usr/java/jdk1.7.0_40/jre/lib/ext/zipfs.jar:/usr/java/jdk1.7.0_40/jre/lib/ext/localedata.jar:/usr/java/jdk1.7.0_40/jre/lib/ext/sunpkcs11.jar:/usr/java/jdk1.7.0_40/jre/lib/ext/sunec.jar:/usr/java/jdk1.7.0_40/jre/lib/ext/dnsns.jar:/usr/java/jdk1.7.0_40/jre/lib/ext/sunjce_provider.jar:/home/kshk/IdeaProjects/mavenKris/target/classes:/home/kshk/Software/idea-IC-129.1359/lib/idea_rt.jar:/home/kshk/.m2/repository/org/apache/hadoop/hadoop-core/1.0.3-gphd-1.2.0.0/hadoop-core-1.0.3-gphd-1.2.0.0.jar:/home/kshk/.m2/repository/commons-logging/commons-logging/1.0.3/commons-logging-1.0.3.jar:/home/kshk/.m2/repository/commons-configuration/commons-configuration/1.6/commons-configuration-1.6.jar:/home/kshk/.m2/repository/commons-lang/commons-lang/2.1/commons-lang-2.1.jar com.intellij.rt.execution.application.AppMain mavenKris.Dictionary 
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0 
    at mavenKris.Dictionary.main(Dictionary.java:37) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
    at java.lang.reflect.Method.invoke(Method.java:606) 
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120) 
[[email protected] tmp]$ 

编辑:

库罐中的IntelliJ enter image description here

回答

2

因为你是从IDE运行它,你应该首先改变你的POM到:

<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/xsd/maven-4.0.0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 

    <groupId>mavenKris</groupId> 
    <artifactId>mavenKris</artifactId> 
    <version>1.0-SNAPSHOT</version> 
    <packaging>jar</packaging> 

    <name>mavenKris</name> 
    <url>http://maven.apache.org</url> 

    <build> 
     <plugins> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-compiler-plugin</artifactId> 
       <version>3.1</version> 
       <configuration> 
        <source>1.6</source> 
        <target>1.6</target> 
       </configuration> 
      </plugin> 
     </plugins> 
    </build> 
    <repositories> 
     <repository> 
      <id>anorak-releases</id> 
      <url>http://ip-10-40-3-96.cloud.trendinglines.co.uk:8081/nexus/content/repositories/releases/</url> 
      <releases> 
       <enabled>true</enabled> 
      </releases> 
      <snapshots> 
       <enabled>false</enabled> 
      </snapshots> 
     </repository> 

     <repository> 
      <id>atlassian-releases</id> 
      <url>http://repository.opencastproject.org/nexus/content/repositories/atlassian/</url> 
      <releases> 
       <enabled>true</enabled> 
      </releases> 
      <snapshots> 
       <enabled>false</enabled> 
      </snapshots> 
     </repository> 

     <repository> 
      <id>central</id> 
      <name>Maven Central</name> 
      <url>http://repo1.maven.org/maven2/</url> 
     </repository> 
    </repositories> 



    <properties> 
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
    </properties> 

    <dependencies> 
     <dependency> 
      <groupId>junit</groupId> 
      <artifactId>junit</artifactId> 
      <version>3.8.1</version> 
      <scope>test</scope> 
     </dependency> 
     <dependency> 
      <groupId>org.apache.hadoop</groupId> 
      <artifactId>hadoop-core</artifactId> 
      <version>1.0.3-gphd-1.2.0.0</version> 
      <scope>provided</scope> 
     </dependency> 
    </dependencies> 

</project> 

我想anorak-releases是本地的mvn仓库,而且你有hadoop-core。检查它是否存在,因为它不适合我,所以我不得不说:

<dependency> 
     <groupId>org.apache.hadoop</groupId> 
     <artifactId>hadoop-core</artifactId> 
     <version>0.20.2</version> 
    </dependency> 

反而让它工作。

右键单击InteliJ中的pom文件并选择“同步POM”以导入正确的库。然后从IDE启动您的程序。

后此命令行看起来像:

/usr/lib/jvm/java-6-sun-1.6.0.26/bin/java -Didea.launcher.port = 7533 -Didea.launcher .bin.path =/opt/instalations/idea-IU-123.169/bin -Dfile.encoding = UTF-8 -classpath /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/jce。罐子:/usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/javaws.jar:/usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/plugin。罐子:/usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/charsets.jar:/usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/management- agent.jar中:/usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar:/usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/ jsse.jar:/usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/deploy.jar:/usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/ resourc es.jar:/usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/ext/sunjce_provider.jar:/usr/lib/jvm/java-6-sun-1.6.0.26/jre/ lib/ext目录/ dnsns.jar:/usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/ext/sunpkcs11.jar:/usr/lib/jvm/java-6-sun-1.6。 0.26/JRE/lib/ext目录/ localedata.jar:/工作/电子教学/ reactive_scala/HW2 /无/ mavenKris /目标/类:/root/.m2/repository/org/apache/hadoop/hadoop-core/0.20.2 /hadoop-core-0.20.2.jar:/root/.m2/repository/commons-cli/commons-cli/1.2/commons-cli-1.2.jar:/root/.m2/repository/xmlenc/xmlenc/0.52 /xmlenc-0.52.jar:/root/.m2/repository/commons-httpclient/commons-httpclient/3.0.1/commons-httpclient-3.0.1.jar:/root/.m2/repository/commons-logging/commons -logging/1.0.3 /共享记录-1.0.3.jar:/root/.m2/repository/commons-codec/commons-codec/1.3/commons-codec-1.3.jar:/root/.m2/repository /commons-net/commons-net/1.4.1/commons-net-1.4.1.jar:/root/.m2/repository/oro/oro/2.0.8/oro-2.0.8.jar:/root/ .m2目录/库/组织/ mortbay /码头/码头/ 6.1.14 /码头,6.1.14.jar:/root/.m2/repository/org/mortbay/j etty /码头-UTIL/6.1.14 /码头-UTIL-6.1.14.jar:/root/.m2/repository/org/mortbay/jetty/servlet-api-2.5/6.1.14/servlet-api-2.5- 6.1.14.jar:/root/.m2/repository/tomcat/jasper-runtime/5.5.12/jasper-runtime-5.5.12.jar:/root/.m2/repository/tomcat/jasper-compiler/5.5。 12 /碧玉编译-5.5.12.jar:/root/.m2/repository/org/mortbay/jetty/jsp-api-2.1/6.1.14/jsp-api-2.1-6.1.14.jar:/根/.m2/repository/org/mortbay/jetty/jsp-2.1/6.1.14/jsp-2.1-6.1.14.jar:/root/.m2/repository/org/eclipse/jdt/core/3.1.1/核心3.1.1.jar:/root/.m2/repository/ant/ant/1.6.5/ant-1.6.5.jar:/root/.m2/repository/commons-el/commons-el/1.0/公共-EL-1.0.jar:/root/.m2/repository/net/java/dev/jets3t/jets3t/0.7.1/jets3t-0.7.1.jar:/root/.m2/repository/net/sf/ kosmosfs/KFS/0.3/KFS-0.3.jar:/root/.m2/repository/hsqldb/hsqldb/1.8.0.10/hsqldb-1.8.0.10.jar:/opt/instalations/idea-IU-123.169/lib/idea_rt .jar com.intellij.rt.execution.application.AppMain mavenKris.Dictionary diction ary.txt output.txt

+0

对不起,我没有得到关于类路径? AFAIK我执行从IntelliJ运行.... – krisdigitx

+0

我已经做了改变,以便从InteliJ工作。 – user987339

+0

感谢您的回复,我已经复制了新的pom.xml,但我仍然得到相同的错误.... – krisdigitx