我试图在hdfs中创建一个文件,并从我的windows机器上测试我的代码。为此,我在这里关注了这个链接,它与文章中的give代码配合得很好,因为它是一个maven项目。
我需要的是在eclipse中创建一个动态web项目。我所做的是将hadoop-client-2.6.1.jar放在我的项目中,但是当它尝试下面的代码行时,它最终会被阻塞
Configuration configuration = new Configuration();
configuration.set("fs.defaultFS",hdfsUri );
FileSystem fs = FileSystem.get(new URI(sHdfsLandOutPath), configuration);
Path file = new Path(sHdfsLandOutPath + sTableName + ".txt");
我不明白是什么问题,因为当我从windows机器上运行它时,它不会抛出任何错误,而当我通过linux运行它时,我会得到下面的错误。
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58)
Caused by: java.lang.NoClassDefFoundError: com/google/common/collect/Interners
at org.apache.hadoop.util.StringInterner.<clinit>(StringInterner.java:48)
at org.apache.hadoop.conf.Configuration.loadResource(Configuration.java:2108)
at org.apache.hadoop.conf.Configuration.loadResources(Configuration.java:2001)
at org.apache.hadoop.conf.Configuration.getProps(Configuration.java:1918)
at org.apache.hadoop.conf.Configuration.get(Configuration.java:721)
at org.apache.hadoop.conf.Configuration.getTrimmed(Configuration.java:740)
at org.apache.hadoop.conf.Configuration.getBoolean(Configuration.java:1093)
at org.apache.hadoop.fs.FileSystem.get(FileSystem.java:363)
at com.jms.demo.JMSConsumer.runConsumer(JMSConsumer.java:115)
at com.jms.demo.JMSConsumer.main(JMSConsumer.java:79)
... 5 more
Caused by: java.lang.ClassNotFoundException: com.google.common.collect.Interners
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
暂无答案!
目前还没有任何答案,快来回答吧!