java.lang.NoClassDefFoundError: org/dom4j/Document
我有一个名为 XMLtoXML.java 的类,这是它的方法之一...
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 应用程序的一部分并在类路径中添加 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 存在于类路径中。 有人对问题有什么想法吗?
I have a class called XMLtoXML.java and this is one of it's methods...
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);
last line of code block uses a dom4j Document.i have dom4j-full.jar in my classpath.
if i run this class as standalone(Run as Java application in eclipse) then it works fine.
when i add this class as part of web appllication and dom4j-full.jar in my classpath.
i got following exception.
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)
I am also sure that the dom4j jar present on classpath.
Anybody have any ideas about issue?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看起来
dom4j-full.jar
包含dom4j
和jaxen
。从你的stacktrace中我了解到
dom4j
在类路径中,它可以找到jaxen
,但是当jaxen
查找dom4j
时> 它找不到它。我认为从 dom4j 加载的 jaxen 出于某种原因不是 dom4j-full.jar 中的一个,而是应用程序服务器类路径中的另一个(当然不是在你的日食中),可能是从不同的类加载器加载的。也许您的共享库中有一个
jaxen.jar
或类似的东西。Looks like
dom4j-full.jar
contains bothdom4j
andjaxen
.From you stacktrace I understand
dom4j
is in the classpath, and it can findjaxen
, but whenjaxen
looks fordom4j
it can't find it.I think the jaxen that has been loaded from
dom4j
isn't for some reason that one inside thedom4j-full.jar
but another one that you have within your application server classpath (and not in your eclipse of course), perhaps loaded from a different classloader. Maybe you have ajaxen.jar
in your shared libraries or something like this.堆栈跟踪清楚地表明其他 org.dom4j 类存在并正在使用。
所以看来你有库版本冲突。
dom4j 和 jaxen 版本应该相互兼容。
将它们的版本与在独立模式下运行良好的版本进行比较。
The stacktrace clearly states that other
org.dom4j
classes are present and being used.So it seems you have library version conflict.
dom4j and jaxen versions should be compatible with each other.
Compare their versions with those that work well in standalone mode.