启动 weblogic 时出现 java.lang.ClassCastException: org.apache.xerces.jaxp.DocumentBuilderFactoryImpl
作为我们应用程序的一部分,我们使用 apache 的 xerces jaxp 解析器。当我们在 weblogic 9.2 上部署应用程序时,出现以下错误。
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.apache.cxf.wsdl.WSDLManager' defined in class path resource [META-INF/cxf/cxf.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.apache.cxf.wsdl11.WSDLManagerImpl]: Constructor threw exception; nested exception is java.lang.ClassCastException: org.apache.xerces.jaxp.DocumentBuilderFactoryImpl
根据我们的分析,weblogic 正在尝试加载自己的 DocumentBuilderFactoryImpl
,它存在于 weblogic.jar 中,而不是 apache 的 xerces。
我们尝试了以下方法来强制 weblogic 从 xerces 加载 DocumentBuilderFactoryImpl
i) 我们已将以下标记添加到 weblogic.xml
<prefer-web-inf-classes>true</prefer-web-inf-classes>
ii) 我们已将最新版本的 xalan 放入 jre /lib/endorced 文件夹。这并没有解决我们的问题。
ii) 我们在 weblogic-application.xml 中添加了条目
<weblogic-application xmlns="http://www.bea.com/ns/weblogic/90">
<application-param>
<param-name>webapp.encoding.default</param-name>
<param-value>UTF-8</param-value>
</application-param>
<prefer-application-packages>
<package-name>javax.jws.*</package-name>
<package-name>org.apache.xerces.*</package-name>
<package-name>org.apache.xerces.jaxp.*</package-name>
</prefer-application-packages>
</weblogic-application>
ii) 在 weblogic-application.xml 中添加了以下条目
<xml>
<parser-factory>
<saxparser-factory>org.apache.xerces.jaxp.SAXParserFactoryImpl</saxparser-factory>
<document-builder-factory>org.apache.xerces.jaxp.DocumentBuilderFactoryImpl</document-builder-factory>
<transformer-factory>org.apache.xalan.processor.TransformerFactoryImpl</transformer-factory>
</parser-factory>
</xml>
iii) 添加了 jaxp.properties
以将 DocumentBuilderFactoryImpl
从 xerces 加载到jre/lib 并启动服务器。在这种情况下,weblogic 没有启动。
iv) 然后我们首先启动服务器,然后在服务器启动时的运行时复制jaxp.properties
文件。但是没有成功
以上都对我们不起作用。
非常感谢任何帮助。
As part of our application we are using apache's xerces jaxp parser. When we deploy the application on weblogic 9.2, we are getting the following error.
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.apache.cxf.wsdl.WSDLManager' defined in class path resource [META-INF/cxf/cxf.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.apache.cxf.wsdl11.WSDLManagerImpl]: Constructor threw exception; nested exception is java.lang.ClassCastException: org.apache.xerces.jaxp.DocumentBuilderFactoryImpl
As per our analysis, weblogic is trying to to load its own DocumentBuilderFactoryImpl
which is present in weblogic.jar instead of apache's xerces.
We tried the following to force the weblogic to load DocumentBuilderFactoryImpl
from xerces
i) we have added the following tag into weblogic.xml
<prefer-web-inf-classes>true</prefer-web-inf-classes>
ii) we have put latest versions of xalan in jre/lib/endorced folder. this didn't resolve our problem.
ii) we have added entries in weblogic-application.xml
<weblogic-application xmlns="http://www.bea.com/ns/weblogic/90">
<application-param>
<param-name>webapp.encoding.default</param-name>
<param-value>UTF-8</param-value>
</application-param>
<prefer-application-packages>
<package-name>javax.jws.*</package-name>
<package-name>org.apache.xerces.*</package-name>
<package-name>org.apache.xerces.jaxp.*</package-name>
</prefer-application-packages>
</weblogic-application>
ii)Added the following entry in weblogic-application.xml
<xml>
<parser-factory>
<saxparser-factory>org.apache.xerces.jaxp.SAXParserFactoryImpl</saxparser-factory>
<document-builder-factory>org.apache.xerces.jaxp.DocumentBuilderFactoryImpl</document-builder-factory>
<transformer-factory>org.apache.xalan.processor.TransformerFactoryImpl</transformer-factory>
</parser-factory>
</xml>
iii) Added jaxp.properties
to load DocumentBuilderFactoryImpl
from xerces to the jre/lib and started the server.In this case, the weblogic didnt start.
iv) Then we started the server first and then copied the jaxp.properties
file during the run time when server starts.But no success
None of the above worked for us.
Any help is highly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
你做了很多事情,我都不明白具体的情况。我的建议是严格遵循 应用程序服务器我过去曾在 WLS 9.2 中成功使用过 WebLogic 的特定配置指南。
您肯定需要在
prefer-application-packages
下添加更多包来设置 Weblogic ClassLoader 过滤 但在问题的当前状态下,不可能提供准确的答案。以防万一,您可以尝试盲目使用 这个帖子:
但这只是一个盲目的尝试。
You did so many things that I don't understand the exact status. My advice would be to strictly follow the Application Server Specific Configuration Guide for WebLogic that I've successfully used in the past with WLS 9.2.
You'll certainly have to add more packages under
prefer-application-packages
to setup Weblogic ClassLoader filtering but in the current state of the question, it's impossible to provide a precise answer.Just in case, you can maybe try to blindly use the
weblogic-application.xml
from this thread:But this is a shot in the dark.
您可以尝试强制使用指定的文档构建器工厂作为命令行选项:
这假设您的类路径中有所需的 Xerces 构建器工厂类。
一般来说,您不应再使用单独的 xerces.jar,除非某些遗留代码需要。 Xerces 解析器类随 JRE 一起提供,包名称以 com.sun.org.apache 而不是 org.apache 开头。您还可以尝试
从类路径中完全删除 xerces.jar(这是我们在 WLS 10.3 和 Java 1.6 上所做的)。
You could try forcing the use of the specified document builder factory as a command line option:
This is assuming that you have the required Xerces builder factory class in your classpath.
In general, you shouldn't use a separate xerces.jar anymore, unless required by some legacy code. The Xerces parser classes come with the JRE, the package names just start with com.sun.org.apache instead of org.apache. You could try also
and remove xerces.jar from your classpath altogether (this is what we did on WLS 10.3 and Java 1.6).
我设法通过简单的解决方案解决了找不到 DocumentBuilderFactory 的问题。
尝试将 xercesImpl.jar 复制到 weblogic MyDomain\servers\MyServer\lib 上的域特定 lib 目录。
I managed to resolve the issue DocumentBuilderFactory not found with simple solution.
Try to copy xercesImpl.jar to the domain specific lib directory on weblogic MyDomain\servers\MyServer\lib.
就我而言,问题是我依赖于 commons-digester ,而后者又使用了 xerces 的另一个版本(这导致了冲突)。因此,您可以检查您的依赖项,以防某些其他版本的 xerces 被传递包含在内。
In my case the problem was that i made a dependency on commons-digester which in turn used another version of xerces (that caused the conflict). So you can review your dependencies in case some other version of xerces was transitively included.