java - 撒克逊 + Spring - IllegalArgumentException : Unknown Attribute http://java. sun.com/xml/jaxp/properties/schemaLanguage

标签 java spring xpath saxon

我正在尝试从 Xalan 迁移到 Saxon(为了 xslt 2.0 支持)并且遇到以下异常。我已确保环境中不再有所有 Xalan jar ,现在包括一些 Saxon 9.1.0.8 jar 。

转换似乎有效,但这个异常是在启动时发生的,我想解决它。

org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
    org.springframework.beans.factory.BeanDefinitionStoreException: Parser configuration exception parsing XML from ServletContext resource [/WEB-INF/config/app-config-tomcat.xml]; nested exception is javax.xml.parsers.ParserConfigurationException: Unable to validate using XSD: Your JAXP provider [net.sf.saxon.dom.DocumentBuilderFactoryImpl@9c8a67] does not support XML Schema. Are you running on Java 1.4 with Apache Crimson? Upgrade to Apache Xerces (or Java 1.5) for full XSD support.
        at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:404)
        at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
        at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
        at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:143)
        at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:178)
        at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:149)
        at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:124)
        at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:93)
        at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:130)
        at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:465)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:395)
        at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:276)
        at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197)
        at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
        at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3972)
        at org.apache.catalina.core.StandardContext.start(StandardContext.java:4467)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:568)
        at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:903)
        at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:740)
        at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:500)
        at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1282)
        at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:321)
        at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
        at org.apache.catalina.core.StandardHost.start(StandardHost.java:807)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
        at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
        at org.apache.catalina.core.StandardService.start(StandardService.java:519)
        at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
        at org.apache.catalina.startup.Catalina.start(Catalina.java:579)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
    Caused by: javax.xml.parsers.ParserConfigurationException: Unable to validate using XSD: Your JAXP provider [net.sf.saxon.dom.DocumentBuilderFactoryImpl@9c8a67] does not support XML Schema. Are you running on Java 1.4 with Apache Crimson? Upgrade to Apache Xerces (or Java 1.5) for full XSD support.
        at org.springframework.beans.factory.xml.DefaultDocumentLoader.createDocumentBuilderFactory(DefaultDocumentLoader.java:102)
        at org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:70)
        at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:388)
        ... 37 more
    Caused by: java.lang.IllegalArgumentException: Unknown attribute http://java.sun.com/xml/jaxp/properties/schemaLanguage
        at net.sf.saxon.Configuration.setConfigurationProperty(Configuration.java:3347)
        at net.sf.saxon.dom.DocumentBuilderFactoryImpl.setAttribute(DocumentBuilderFactoryImpl.java:49)
        at org.springframework.beans.factory.xml.DefaultDocumentLoader.createDocumentBuilderFactory(DefaultDocumentLoader.java:99)
        ... 39 more

最佳答案

Question answered在撒克逊帮助列表上。

如果帖子将来不可用,这里有一个副本供引用:

It looks as if Spring (or an application using Spring) is using the JAXP mechanism to find a DOM implementation, and for some reason is finding the Saxon DOM implementation. This isn't a good idea, because Saxon's DOM implementation isn't a general-purpose one, and there are lots of things it doesn't support, for example update. So why is it finding it? Saxon doesn't register this implementation in the JAR file manifest, so I don't think it's finding it simply from the classpath search; that would suggest someone is setting the relevant system property. Setting the system property jaxp.debug="1" might shed more light as to why this DocumentBuilder is being loaded.

It's possible that the problem is benign in that the DocumentBuilder is being loaded but isn't being used, or properties are being set on it that aren't actually needed; or perhaps Spring catches the exception and recovers by loading a different DocumentBuilder. But I agree with you, it would be better to stop it happening.

关于java - 撒克逊 + Spring - IllegalArgumentException : Unknown Attribute http://java. sun.com/xml/jaxp/properties/schemaLanguage,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9083168/

相关文章:

selenium - Selenium 中的动态 x 路径中的输入及其属性不断变化

java - Spring 安全 + MVC : Questions around context definition & bean scope

java - 将连续 Controller 数据写入 MIDI 文件

java - 关于 StringBuilder indexOf 的 javadoc 注释有误导性吗?

java - 创建名称为 'studentController' : Injection of autowired dependencies failed 的 bean 时出错

java - 使用 Spring 3.0.5 将 Jasper Reports 导出为 XLSX 格式

java - 无法使用 Java/webDriver 中的选择类更改选择框值

java - 从具有关系权重的表生成视觉表示

spring - 如何在运行时在spring中加载额外的bean配置文件

XPATH 删除属性