1

我尝试了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 的安装版本可能有问题?

4

0 回答 0