我正试图使用嵌入式方法访问exist xml db,如here所述。
这个页面有一个类路径所需的jar列表,我已经在那里找到了所有jar,但是我一直得到这个错误:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/ws/commons/serialize/DOMSerializer
下面是我的类路径中的内容;我正在使用eclipse:
antlr-2.7.7.jar
commons-collections-3.2.1.jar
commons-logging-1.1.1.jar
commons-pool-1.6.jar
exist-modules.jar
exist-optional.jar
exist.jar
jta-1.1.jar
log4j-1.2.17.jar
pkg-repo.jar
quartz-2.1.6.jar
slf4j-api-1.7.2.jar
slf4j-log4j12-1.7.2.jar
sunxacml-1.2.jar
xmldb.jar
xmlrpc-client-3.1.3.jar
xmlrpc-common-3.1.3.jar
xmlrpc-server-3.1.3.jar
saxonhe-9.4.0.7.jar
serializer-2.7.1.jar
xalan-2.7.1.jar
xercesImpl-2.11.0.jar
xml-apis-1.4.01.jar
xml-resolver-1.2.jar
以下是相关代码:
System.out.println("trying to call class.forname on " + DRIVER);
Class cl = Class.forName(DRIVER);
System.out.println("creating db instance");
Database database = (Database) cl.newInstance();
database.setProperty("create-database", "true");
System.out.println("register database");
DatabaseManager.registerDatabase(database);
System.out.println("getting collection: " + URI + collectionName);
Collection collection = DatabaseManager.getCollection(URI + collectionName);
//collection.setProperty(OutputKeys.INDENT, "yes");
//System.out.println("getting resource");
//XMLResource xmlRes = (XMLResource)collection.getResource(resourceName);
下面是控制台输出,包括错误:
******************************************************
reading a doc from xml db
******************************************************
reading doc...
trying to call class.forname on org.exist.xmldb.DatabaseImpl
creating db instance
register database
getting collection: xmldb:exist://localhost:8080/exist/xmlrpc/db/test-journal
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/ws/commons/serialize/DOMSerializer
at org.apache.xmlrpc.serializer.NodeSerializer.<clinit>(NodeSerializer.java:30)
at org.apache.xmlrpc.common.TypeFactoryImpl.<clinit>(TypeFactoryImpl.java:88)
at org.apache.xmlrpc.common.XmlRpcController.<init>(XmlRpcController.java:31)
at org.apache.xmlrpc.client.XmlRpcClient.<init>(XmlRpcClient.java:51)
at org.exist.xmldb.DatabaseImpl.getRpcClient(DatabaseImpl.java:324)
at org.exist.xmldb.DatabaseImpl.getRemoteCollection(DatabaseImpl.java:240)
at org.exist.xmldb.DatabaseImpl.getCollection(DatabaseImpl.java:164)
at org.exist.xmldb.DatabaseImpl.getCollection(DatabaseImpl.java:153)
at org.xmldb.api.DatabaseManager.getCollection(Unknown Source)
at org.xmldb.api.DatabaseManager.getCollection(Unknown Source)
at com.jasonwardenburg.codetest.exist.ExistDBFileReader.readDoc(ExistDBFileReader.java:48)
at com.jasonwardenburg.codetest.exist.ExistDBFileReader.main(ExistDBFileReader.java:27)
Caused by: java.lang.ClassNotFoundException: org.apache.ws.commons.serialize.DOMSerializer
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 12 more
我访问了apache xml rpc页面,但是大多数镜像站点都不能正常工作……有谁知道如何最好地实现这一点?
谢谢!
最佳答案
$exist廑home/lib/core中缺少ws-commons-util-1.0.2.jar。
我想文件已经过时了。您应该确保至少包含了$exist-home/lib/core中的所有库。
关于java - eXist xml db:java.lang.NoClassDefFoundError:org/apache/ws/commons/serialize/DOMSerializer,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/21471252/