日期:2014-05-16  浏览次数:20439 次

jsp操作xml文件出现的一个异常
tomcat坏境下java对XML进行操作的时候出现异常:

javax.xml.transform.TransformerFactoryConfigurationError: Provider org.apache.xalan.processor.TransformerFactoryImpl not found



错误原因:
是由于jdk1.5 与 tomcat5.0之间的关于 TransformerFactoryImpl 类的冲突造成的。tomcat-5.0.28\common\endorsed下有两个jar包:xercesImpl.jar和xml-apis.jar,其中的类javax.xml.transform.TransformerFactory 与jdk1.5中的类org.apache.xalan.processor.TransformerFactoryImpl其实是同一个类。in tomcat java is called with the following argument:-Djava.endorsed.dirs="X:\my_app\Portal\tomcat\common\endorsed"In this directory you find two jar files: xercesImpl.jar and xml-apis.jar needed by tomcat and that must be loaded before all xmsl stuff present in the jdk (1.4 naming problem). And in the file xml-apis.jar the TransformerFactoryImpl is set to "org.apache.xalan.processor.TransformerFactoryImpl"。
也就是tomcat5.0.28缺失包xalan.jar,包存放的位置:tomcat\common\endorsed 


三个解决办法:
1. 将xml-apis.jar移出endorsed文件夹。
2. 用xalan系列jar包替换原来的xercesImpl.jar和xml-apis.jar。
   xalan系列jar包:serializer.jar、xalan.jar、xercesImpl.jar和xml-apis.jar。
3. 使用1.4的JDK和tomcat5.0或者JDK1.5 tomcat5.5 这2种类型是匹配的 。

xalan.jar 下载地址
http://apache.etoak.com/xml/xalan-j/binaries/