English 中文(简体)
不兼容的ClassChange 用名称空间评价Xpath表述
原标题:IncompatibleClassChangeError when evaluating xpath expressions with namespace

i need to modify an xml document which has multiple namespaces. my code runs without problems on my local machine but i m encountering java.lang.IncompatibleClassChangeError when i deployed it to IBM Websphere application server.

i m using xercesImpl-2.8.1.jar and xalan-2.7.0.jar. what is causing this error and how do i resolve it? alternatively, are there other ways to modify xml documents with namespace support?

法典:

System.setProperty("javax.xml.parsers.DocumentBuilderFactory", "org.apache.xerces.jaxp.DocumentBuilderFactoryImpl");

DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true);
DocumentBuilder db = dbf.newDocumentBuilder();
org.w3c.dom.Document doc = db.parse(new java.io.FileInputStream("c:/test.xml"));

System.setProperty("javax.xml.xpath.XPathFactory", "org.apache.xpath.jaxp.XPathFactoryImpl");
XPathFactory xf = XPathFactory.newInstance();
XPath xpath = xf.newXPath();
xpath.setNamespaceContext(new MyNamespaceContext());

// get the node for editing
String xpathExpr = ...
org.w3c.dom.Node n = (org.w3c.dom.Node)xpath.compile(xpathExpr).evaluate(doc, XPathConstants.NODE); // IncompatibleClassChangeError here

例外追踪:

java.lang.IncompatibleClassChangeError
        at org.apache.xpath.jaxp.JAXPPrefixResolver.getNamespaceForPrefix(JAXPPrefixResolver.java:45)
        at org.apache.xpath.compiler.Lexer.mapNSTokens(Lexer.java:587)
        at org.apache.xpath.compiler.Lexer.tokenize(Lexer.java:265)
        at org.apache.xpath.compiler.Lexer.tokenize(Lexer.java:96)
        at org.apache.xpath.compiler.XPathParser.initXPath(XPathParser.java:110)
        at org.apache.xpath.XPath.<init>(XPath.java:176)
        at org.apache.xpath.XPath.<init>(XPath.java:264)
        at org.apache.xpath.jaxp.XPathImpl.compile(XPathImpl.java:394)
        at com.ibm._jsp._xml._jspService(_xml.java:94)
        at com.ibm.ws.jsp.runtime.HttpJspBase.service(HttpJspBase.java:87)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
        at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1146)
        at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:592)
        at com.ibm.ws.wswebcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:525)
        at com.ibm.wsspi.webcontainer.servlet.GenericServletWrapper.handleRequest(GenericServletWrapper.java:122)
        at com.ibm.ws.jsp.webcontainerext.AbstractJSPExtensionServletWrapper.handleRequest(AbstractJSPExtensionServletWrapper.java:232)
        at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3548)
        at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:269)
        at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:831)
        at com.ibm.ws.wswebcontainer.WebContainer.handleRequest(WebContainer.java:1478)
        at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:133)
        at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:458)
        at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:387)
        at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:267)
        at com.ibm.ws.ssl.channel.impl.SSLConnectionLink.determineNextChannel(SSLConnectionLink.java:1037)
        at com.ibm.ws.ssl.channel.impl.SSLConnectionLink$MyReadCompletedCallback.complete(SSLConnectionLink.java:644)
        at com.ibm.ws.ssl.channel.impl.SSLReadServiceContext$SSLReadCompletedCallback.complete(SSLReadServiceContext.java:1818)
        at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
        at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
        at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
        at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:136)
        at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:196)
        at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:751)
        at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:881)
        at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1497)
最佳回答

i ve设法解决这一问题。 这是由于一个类别文件(javax.xml.namespace.NamespaceContext/code>)从Xml-apis.jar装载,i 也在使用。

javax.xml.namespace.NamespaceContext is an对面, present in xml-apis.jar and JRE. 在“JRE”这一类版本中,接口方法都是很抽象的,但在“Xml-apis”中。 杰尔版的接口方法不是抽象的。 i 认为这造成了双重兼容性问题,造成一犯错误。

因此解决了我的问题,即改变我的班轮配置,在申请舱载人之前使用母子舱载荷,以便使用JRE的<代码>javax.xml.namespace.NamespaceContext

问题回答

我通常的统治是,不兼容 职等ChangeError表示,汇编者在编纂时看到的某些类别版本与同期装满的同一类别版本不符。 st痕表明,XPath发动机正在向您的名号空间Resolver发出呼吁,以便集中调查。

我的猜测是,网吧有另一个版本的xerces或xalan的复制件,而你的申请则使用不同的版本。 我将首先设法查明哪些版本被网上使用,以及你的申请是否与这一版本有关。

If you are on Java 6 you could also try to use the newInstance methods taking a classname and classloader and pass your webapps context classloader.





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签