我有一個叫XMLtoXML.java類,這是它的方法之一...java.lang.NoClassDefFoundError:組織/ dom4j中/文件
import org.dom4j.Document;
import org.dom4j.Element;
import org.dom4j.Node;
import org.dom4j.io.OutputFormat;
import org.dom4j.io.XMLWriter;
public Object[] process(Object data) {
String templateXML = null;
Object result[] = null;
String inputxml = null;
String templateNumber = null;
Iterator iterator = null;
String scenarioConfigUrl = null;
Node inputNode;
Node outputNode;
String subTemplateXML = null;
String outputXml = null;
if (delay != null) {
long time = Long.parseLong(delay);
try {
Thread.sleep(time);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
inputxml = (String) metadata.get(Constants.REQUEST);
if (inputxml == null) {
throw new NullRecordException("input data to XMLtoXML class in
metadata map is null");
}
Document inputXMLDocument = Dom4jUtils.getDocument(inputxml);
代碼塊的最後一行使用一棵dom4j Document.i在我的類路徑中有dom4j-full.jar。 如果我作爲獨立運行這個類(在Eclipse中作爲Java應用程序運行),那麼它工作正常。 當我添加這個類作爲web appllication和dom4j-full.jar在我的類路徑中的一部分。
我得到以下異常。
java.lang.NoClassDefFoundError: org/dom4j/Document
at org.jaxen.dom4j.DocumentNavigator.getDocumentNode(DocumentNavigator.java:346)
at org.jaxen.expr.DefaultAbsoluteLocationPath.evaluate
(DefaultAbsoluteLocationPath.java:102)
at org.jaxen.expr.DefaultXPathExpr.asList(DefaultXPathExpr.java:102)
at org.jaxen.BaseXPath.selectNodesForContext(BaseXPath.java:674)
at org.jaxen.BaseXPath.selectNodes(BaseXPath.java:213)
at org.jaxen.BaseXPath.selectSingleNode(BaseXPath.java:234)
at org.dom4j.xpath.DefaultXPath.selectSingleNode(DefaultXPath.java:156)
at org.dom4j.tree.AbstractNode.selectSingleNode(AbstractNode.java:188)
at org.amdocs.convert.XMLtoXML.process(XMLtoXML.java:134)
at org.openadaptor.core.node.Node.processSingleRecord(Node.java:148)
at org.openadaptor.core.node.Node.process(Node.java:170)
at org.openadaptor.core.node.ProcessorNode.process(ProcessorNode.java:96)
at org.openadaptor.core.router.AbstractRouter.process(AbstractRouter.java:239)
at org.openadaptor.core.router.AbstractRouter.process(AbstractRouter.java:223)
at org.openadaptor.core.router.AbstractRouter.processResponse(AbstractRouter.java:249)
at org.openadaptor.core.router.AbstractRouter.process(AbstractRouter.java:239)
at org.openadaptor.core.router.AbstractRouter.process(AbstractRouter.java:223)
at org.openadaptor.core.router.AbstractRouter.process(AbstractRouter.java:180)
at org.openadaptor.core.adaptor.Adaptor.process(Adaptor.java:285)
at org.openadaptor.core.node.Node.callChainedMessageProcessor(Node.java:213)
at org.openadaptor.core.node.Node.process(Node.java:199)
at org.openadaptor.core.node.ReadNode.process(ReadNode.java:241)
at org.openadaptor.core.node.ReadNode.run(ReadNode.java:196)
at java.lang.Thread.run(Thread.java:619)
我也確定dom4j jar出現在classpath中。 任何人有任何關於問題的想法?
那麼,你是如何嘗試在你的類路徑中包含dom4j-full.jar的?這聽起來像是真的*不是*那裏 - 或者至少不能被'jaxen'訪問。 classpath上的'jaxen'在哪裏? –
使用我的[classfinder](http://www.adarshr.com/papers/classfinder)搜索哪個jar包含給定的類。 – adarshr
@JonSkeet Dom4j在開始的時候似乎是在那裏,如果你看一下堆棧跟蹤,但是當jaxen查找'Document'類時,它就會被提名。這很奇怪! – javanna