类Cast异常:com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl [英] Class Cast exception: com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl

查看:543
本文介绍了类Cast异常:com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对jboss的问题感到震惊。当我尝试将我的.war部署到服务器时,我收到以下错误,

I'm struck with a problem in jboss. When I try to deploy my .war into the server, I get this following error,

java.lang.ClassCastException:com.sun.org .apache.xerces.internal.jaxp.SAXParserF
actoryImpl无法强制转换为javax.xml.parsers.SAXParserFactory

很明显,图书馆存在冲突。所以,我删除了包含xerces的jar文件,这是由jaxp-ri-1.4.1.jar发生的。现在,当我尝试重新部署时,我收到了这个新错误,

from which, it is quite evident that there is a clash of libraries. So, I removed the jar file which contains xerces, which happened to by jaxp-ri-1.4.1.jar. Now, when I try to re-deploy, I get this new error,

java.lang.NullPointerException
    at org.apache.commons.digester.Digester.getXMLReader(Digester.java:944)
    at org.apache.commons.digester.Digester.parse(Digester.java:1765)
    at org.apache.struts.action.ActionServlet.initServlet(ActionServlet.java

它抱怨它无法找到xml解析器。

where it is complaining that it can't find the xml parsers.

所以,现在我的问题是,是否有人知道什么是解决方案。任何不包含xerces包的jaxp jar文件?

So, now my questions is that does anybody know what can be a solution. Any jaxp jar file that doesn't contain the xerces package?

更新

我按建议做了这里现在我有一个新的错误,

I did as suggested here and now I have a new error,

java.lang.NoClassDefFoundError: Could not initialize class com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl

这是我删除的一个包含SaxParserFactory的罐子的类:(

which is a class from one of the jars I deleted which contains SaxParserFactory :(

推荐答案

您似乎删除了错误的JAR。当一个SAXParserFactoryImpl实例(它是SAXParserFactory的子类型)被强制转换为SAXParserFactory时,会报告原始的ClassCastException。

It appears that you've deleted the wrong JAR. The original ClassCastException was reported when an instance of SAXParserFactoryImpl (which is a subtype of SAXParserFactory) is being cast to SAXParserFactory.

该异常更可能是由于这一事实SAXParserFactory有两个实例,而不是在JVM中加载两个SAXParserFactoryImpl实例。在转换时,返回由不同类加载器加载的SAXParserFactory导致异常。因此,修复是在类路径中标识具有冲突版本的SAXParserFactory的JAR。如果Commons Digester正在寻找特定的实现,那么删除解析器实现本身可能并不明智。

The exception is more likely to be due to the fact that there are two instances of SAXParserFactory rather than two instances of SAXParserFactoryImpl being loaded in the JVM. At the time of casting, the SAXParserFactory loaded by a different classloader was returned resulting in the exception. The fix therefore is to identify JARs in your classpath that have conflicting versions of SAXParserFactory. Removing the parser implementation itself might not be wise, if Commons Digester is looking for a particular implementation.

这篇关于类Cast异常:com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆