2011-02-15 27 views
14

我有一个web应用程序,我使用spring 3.0和oracle的XMLTYPE相关的jar的com.oracle.xdb,而这又取决于com.oracle.xml.xmlparserv2,我相信大多数人知道当这些罐子弹簧3.0如下用你得到的异常的重复的定义:'identifiedType'

造成的:oracle.xml.parser.schema.XSDException:重复的定义:“identifiedType”

有是一些建议使用不同的分析器,如xerces,但在我们的情况,因为我们使用xdb依赖,它看起来像我们不能改变它使用除了com.oracle.xml.xmlparserv2之外的另一个解析器,它在2.5.6的spring中工作正常吗?有没有关于spring何时可以修复的信息?

回答

5

我已经确定问题是由于xmlparserv2的可吸入性,以适当解析xsi:schemaLocation属性。

我已检查,这种工作的:

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

虽然这产生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" 

解决方法是除去使用特定的命名空间(例如TX,UTIL ..)并用普通豆代替它们的等价定义。例如,您可以用替换<bean class="org.springframework.transaction.annotation.AnnotationTransactionAttributeSource"/>

+0

这并没有为我工作:( – saikosen 2017-03-25 13:32:10

5

从xmlparserv2.jar中删除/ META-INF/services目录 - 它的内容注册Oracle的解析器。

13

而不是修改xmlparserv2.jar,你可以添加

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

Click here阅读Oracle的论坛上谈到这一问题的帖子。

+0

尼斯一个 - 这解决了我的问题是否有在使用xerces分析器而不是Oracle分析器的任何影响?我的应用程序从Oracle数据库的XMLTYPE列中读取XML – CodeClimber 2012-07-12 15:00:05

+0

我只需在maven pom.xml中添加xercesImpl软件包,问题就解决了。 – ergoli 2017-02-18 03:34:48

3

第4步my answer here解释了为什么会发生,并解决它的几种方法。

1
  1. 一致的版本
    schema/beans/spring-beans**-3.1**.xsd schema/jee/spring-jee**-3.1**.xsd schema/mvc/spring-mvc**-3.1**.xsd

  2. 的顺序很重要。 弹簧JEE-3.1.xsd弹簧豆-3.1.xsd导致错误,因为在弹簧JEE-3.1.xsd文件中,我们有一个进口参考春天的bean-3.1.xsd

0

如果模式对同一个XSD有一个导入,则应该导入该XSD以防止出现“重复定义”错误。

例如: 我有三个模式:

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 

现在我得到一个errror,因为弹簧UTIL和弹簧JEE有一个进口:

<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"/> 

春天-tool将手动导入在spring-util和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 

XML配置将被正确解析。

显然,你应该有合适的版本。

小的解决办法是在其他文件中定义配置的某些部分与描述不同的架构,并使用导入:

<import resource="part_of_config.xml"/>