无法在Pydev Project中使用Cloudera CDH3 jar

时间:2013-01-17 18:37:50

标签: eclipse hadoop pydev jython cloudera

我正在尝试编写我的第一个Jython程序。该程序将与远程Cloudera的CDH3 Hadoop实例通信。我继续从远程实例的usr / lib / Hadoop文件夹下载了* .jars,其中包括“hadoop-0.20.2-cdh3u5-core.jar”。

将罐子导入项目并将它们添加到PYTHONPATH(项目 - >属性 - > PyDev-PYTHONPATH->源文件夹 - >添加zip / jar / egg)后,我尝试将它们引用到我的代码。

这是我的简单代码:

from org.apache.hadoop.conf import Configuration

if __name__ == '__main__':
    print "hello"
    conf = Configuration()

我的错误输出如下:

Traceback (most recent call last):
  File "/home/eric/workspace/HelloJythonWorld/hellojython.py", line 10, in <module>
    from org.apache.hadoop.conf import Configuration
java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
    at org.apache.hadoop.conf.Configuration.<clinit>(Configuration.java:150)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:264)
    at org.python.core.Py.loadAndInitClass(Py.java:909)
    at org.python.core.Py.findClassInternal(Py.java:844)
    at org.python.core.Py.findClassEx(Py.java:895)
    at      org.python.core.packagecache.SysPackageManager.findClass(SysPackageManager.java:133)
    at    org.python.core.packagecache.PackageManager.findClass(PackageManager.java:28)
    at org.python.core.packagecache.SysPackageManager.findClass(SysPackageManager.java:122)
    at org.python.core.PyJavaPackage.__findattr_ex__(PyJavaPackage.java:137)
    at org.python.core.PyObject.__findattr__(PyObject.java:863)
    at org.python.core.imp.importFromAs(imp.java:1015)
    at org.python.core.imp.importFrom(imp.java:987)
    at org.python.pycode._pyx0.f$0(/home/eric/workspace/HelloJythonWorld/hellojython.py:14)
    at org.python.pycode._pyx0.call_function(/home/eric/workspace/HelloJythonWorld/hellojython.py)
    at org.python.core.PyTableCode.call(PyTableCode.java:165)
    at org.python.core.PyCode.call(PyCode.java:18)
    at org.python.core.Py.runCode(Py.java:1275)
    at org.python.util.PythonInterpreter.execfile(PythonInterpreter.java:235)
    at org.python.util.jython.run(jython.java:247)
    at org.python.util.jython.main(jython.java:129)
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:423)
       at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
       ... 21 more   

java.lang.NoClassDefFoundError: java.lang.NoClassDefFoundError:  org/apache/commons/logging/LogFactory

screenshot

从错误中可以清楚地看出没有找到该类。我进入jar内部并在其中找到了Configuration类,所以我不明白这是怎么回事。然后我尝试导入jar的另一部分,看看它本身是否与jar本身有关,所以我尝试了以下代码:

from org.apache.hadoop.fs import Path

if __name__ == '__main__':
    print "hello"
    co = Path(".")

我没有收到任何“类未找到”错误,这很奇怪。我在互联网上搜索了几个小时试图找出我的问题,但没有运气。如果有人能让我知道我做错了什么或指出我正确的方向,将非常感谢!谢谢!

背景: Eclipse Juno(Eclipse SDK Version:4.2.1)以Jython(2.5.3)作为解释器运行Pydev(2.7.1)。

0 个答案:

没有答案