Jython需要SimpleXMLRPCServer才能工作?

时间:2013-01-19 01:15:30

标签: jython simplexmlrpcserver

我尝试了SimpleXMLRPCServer的python文档中的第一个示例。

它在python中运行得很好,但是当我使用jython尝试它时,我得到以下内容 堆栈跟踪:

Traceback (most recent call last):
  File "sampleclient.py", line 4, in <module>
    print s.pow(2,3)  # Returns 2**3 = 8
  File "/usr/share/jython/Lib/xmlrpclib.py", line 1147, in __call__
    return self.__send(self.__name, args)
  File "/usr/share/jython/Lib/xmlrpclib.py", line 1433, in _ServerProxy__request
    response = self.__transport.request(
  File "/usr/share/jython/Lib/xmlrpclib.py", line 1201, in request
    return self._parse_response(h.getfile(), sock)
  File "/usr/share/jython/Lib/xmlrpclib.py", line 1324, in _parse_response
    p, u = self.getparser()
  File "/usr/share/jython/Lib/xmlrpclib.py", line 1210, in getparser
    return getparser(use_datetime=self._use_datetime)
  File "/usr/share/jython/Lib/xmlrpclib.py", line 1023, in getparser
    parser = ExpatParser(target)
  File "/usr/share/jython/Lib/xmlrpclib.py", line 536, in __init__
    self._parser = parser = expat.ParserCreate(None, None)
  File "/usr/share/jython/Lib/xml/parsers/expat.py", line 63, in ParserCreate
    return XMLParser(encoding, namespace_separator)
  File "/usr/share/jython/Lib/xml/parsers/expat.py", line 91, in __init__
    self._reader = XMLReaderFactory.createXMLReader(_xerces_parser)
java.lang.ClassNotFoundException: org.apache.xerces.parsers.SAXParser
    at org.xml.sax.helpers.XMLReaderFactory.loadClass(XMLReaderFactory.java:229)
    at org.xml.sax.helpers.XMLReaderFactory.createXMLReader(XMLReaderFactory.java:220)
    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:601)

org.xml.sax.SAXException: org.xml.sax.SAXException: SAX2 driver class org.apache.xerces.parsers.SAXParser not found
java.lang.ClassNotFoundException: org.apache.xerces.parsers.SAXParser

我对python比java更有经验,所以我不知道如何解决这个问题。我的系统是否缺少依赖项,还是需要使用类路径?

编辑:我使用Jython网站上的独立版本重新尝试了这个版本,并且它们有效,所以看起来Ubuntu的安装版本可能会出现问题?

0 个答案:

没有答案