JAXP XSLT转换器默认使用错误的实现 [英] JAXP XSLT transformer using wrong implementation by default

查看:269
本文介绍了JAXP XSLT转换器默认使用错误的实现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Tomcat 5.5 Web应用程序,该应用程序使用Apache Commons-Configuration库在运行时生成XML配置文件.反过来,Commons-Configuration使用javax.xml.transform JAXP API来完成此任务.

I've got a Tomcat 5.5 web application that uses the Apache Commons-Configuration library to generate an XML configuration file at runtime. Commons-Configuration, in turn, uses the javax.xml.transform JAXP API to accomplish this.

由于升级到Java 7,操作失败,并显示以下错误消息:

Since upgrading to Java 7, the operation fails with the following error message:

Caused by: javax.xml.transform.TransformerFactoryConfigurationError: Provider org.apache.xalan.processor.TransformerFactoryImpl not found
    at javax.xml.transform.TransformerFactory.newInstance(Unknown Source)

在过去的发行版中,我从未捆绑过xalan.jar,而是依赖于平台默认的XSLT实现.

In past releases, I've never bundled xalan.jar, instead relying on the platform default XSLT implementation.

我检查过的一些事情:

  • 我的任何应用程序JAR文件,库jar或Tomcat jar中都没有META-INF/services/javax.xml.transform.TransformerFactory条目
  • 未设置javax.xml.transform.TransformerFactory系统属性(在运行时通过JVisualVM进行了验证)
  • jre/lib目录中没有任何jaxp.properties文件
  • There are no META-INF/services/javax.xml.transform.TransformerFactory entries in any of my application JAR files, library jars, or in the Tomcat jars
  • The javax.xml.transform.TransformerFactory system property is unset (verified at runtime through JVisualVM)
  • There is no jaxp.properties file in the jre/lib directory

使用-Djaxp.debug=1运行会产生以下输出:

Running with -Djaxp.debug=1 produces the following output:

JAXP: find factoryId =javax.xml.transform.TransformerFactory
JAXP: loaded from fallback value: org.apache.xalan.processor.TransformerFactoryImpl

此后备值从何而来? Oracle附带了Xalan转换器,但从1.7开始将其重新打包为com.sun.org.apache.xalan.processor.... 不应该是后备值吗?

Where's this fallback value coming from? Oracle ships the Xalan transformer, but since 1.7 has repackaged it as com.sun.org.apache.xalan.processor.... Shouldn't that be the fallback value?

推荐答案

我自己发现了问题.事实证明,从Java 1.4.2迁移时,我已经安装了apache-tomcat-5.5.23-compat文件.解决方案是删除$CATALINA_HOME/common/endorsed目录(尤其是xercesImpl.jarxml-apis.jar)和bin/jmx.jar文件下的所有内容.

Found the issue myself. It turns out that I had the apache-tomcat-5.5.23-compat files installed, as I was migrating from Java 1.4.2. The solution was to remove everything under the $CATALINA_HOME/common/endorsed directory (in particular xercesImpl.jar and xml-apis.jar) and the bin/jmx.jar files.

这篇关于JAXP XSLT转换器默认使用错误的实现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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