Duplicated definition for: 'identifiedType'

前端 未结 6 1797
日久生厌
日久生厌 2021-01-01 21:03

I have a web application where i am using spring 3.0 and oracle\'s XMLTYPE related jar\'s com.oracle.xdb which in turn depends on com.oracle.xml.xmlparserv2 , iam sure most

相关标签:
6条回答
  • 2021-01-01 21:15

    Step 4 of my answer here explains why it happens and a few approaches to fixing it.

    0 讨论(0)
  • 2021-01-01 21:16

    I have identified that the problem is due to the inhability of xmlparserv2 to appropriately parse the xsi:schemaLocation attribute.

    I have checked that this works:

    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"
    

    While this produces the eror:

    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
            http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd"
    

    The workaround is to remove the use of specific namespaces (such as tx, util..) and replace them by the equivalent definitions using common beans. For example, you can replace <tx:annotation-driven/> with <bean class="org.springframework.transaction.annotation.AnnotationTransactionAttributeSource"/>

    0 讨论(0)
  • 2021-01-01 21:23

    Remove /META-INF/services directory from xmlparserv2.jar - it's content registers Oracle's parser.

    0 讨论(0)
  • 2021-01-01 21:24
    1. Consistent versioning
      schema/beans/spring-beans**-3.1**.xsd schema/jee/spring-jee**-3.1**.xsd schema/mvc/spring-mvc**-3.1**.xsd
      etc.

    2. The order is important. spring-jee-3.1.xsd before spring-beans-3.1.xsd causes error, because in spring-jee-3.1.xsd file we have an import reference to spring-beans-3.1.xsd

    0 讨论(0)
  • 2021-01-01 21:31

    If two schemas have an import to the same XSD, you should import that XSD as well to prevent "duplicated definition" error.

    For example: I have three schemas:

    http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
    http://www.springframework.org/schema/util/spring-util-4.2.xsd
    http://www.springframework.org/schema/jee/spring-jee-4.2.xsd
    

    Now I'm getting an errror, because spring-util and spring-jee have an imports to:

    <xsd:import namespace="http://www.springframework.org/schema/beans" schemaLocation="http://www.springframework.org/schema/beans/spring-beans-4.2.xsd"/>
    <xsd:import namespace="http://www.springframework.org/schema/tool" schemaLocation="http://www.springframework.org/schema/tool/spring-tool-4.2.xsd"/>
    

    When spring-tool will be imported manually BEFORE spring-util and spring-jee:

    http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
    http://www.springframework.org/schema/tool/spring-tool-4.2.xsd
    http://www.springframework.org/schema/util/spring-util-4.2.xsd
    http://www.springframework.org/schema/jee/spring-jee-4.2.xsd
    

    the XML configuration will be properly parsed.

    Obviously, you should have consistient versions.

    Small workaround is to define some part of configuration in other files with described different schemas and import it using:

    <import resource="part_of_config.xml"/>
    
    0 讨论(0)
  • 2021-01-01 21:33

    Instead of modifying xmlparserv2.jar you can add

    -Djavax.xml.parsers.DocumentBuilderFactory=com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl

    Click here to read a post on Oracle's forums talking about the issue.

    0 讨论(0)
提交回复
热议问题