Page 1 of 3 123 LastLast
Results 1 to 10 of 22

Thread: XML Validation Problems - A schema cannot contain two global components with the same

  1. #1
    Join Date
    Dec 2011
    Posts
    14

    Default XML Validation Problems - A schema cannot contain two global components with the same

    I'm not sure how to resolve this problem. I'm getting the following error in eclipse (STS 2.8.1.RELEASE) with my spring web project. My spring version is 3.1.0.RELEASE.

    Error Description
    --------------------------
    The errors below were detected when validating the file "spring-context-3.0.xsd" via the file "applicationContext-jpa.xml". In most cases these errors can be detected by validating "spring-context-3.0.xsd" directly. However it is possible that errors will only occur when spring-context-3.0.xsd is validated in the context of applicationContext-jpa.xml.

    Error
    --------------------------
    Description Resource Path Location Type
    Referenced file contains errors (jar:file:/C:/Users/m061385/.m2/repository/org/springframework/spring-beans/3.1.0.RELEASE/spring-beans-3.1.0.RELEASE.jar!/org/springframework/beans/factory/xml/spring-beans-3.0.xsd). For more information, right click on the message in the Problems View and select "Show Details..." applicationContext-jpa.xml /boss/src/main/resources/META-INF/spring line 1 XML Problem

    Error Details
    --------------------------
    sch-props-correct.2: A schema cannot contain two global components with the same name; this schema contains two occurrences of 'http://www.springframework.org/schema/beans,identifiedType'.


    Here are the the files...

    META-INF/spring/applicationContext.xml
    ---------------------------------------------
    Code:
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <beans xmlns="http://www.springframework.org/schema/beans" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context" xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd         http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd         http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd         http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.1.xsd         http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd">
    
        <context:property-placeholder location="classpath*:META-INF/spring/*.properties"/>
    
        <context:spring-configured/>
    
        <context:component-scan base-package="edu.company.project">
            <context:exclude-filter expression=".*_Roo_.*" type="regex"/>
            <context:exclude-filter expression="org.springframework.stereotype.Controller" type="annotation"/>
        </context:component-scan>
        <bean class="org.springframework.orm.jpa.JpaTransactionManager" id="transactionManager">
            <property name="entityManagerFactory" ref="entityManagerFactory"/>
        </bean>
        <tx:annotation-driven mode="aspectj" transaction-manager="transactionManager"/>
        <jee:jndi-lookup id="dataSource" jndi-name="jdbc/project"/>
        <bean class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean" id="entityManagerFactory">
            <property name="persistenceUnitName" value="persistenceUnit"/>
            <property name="dataSource" ref="dataSource"/>
        </bean>
        
    </beans>

    META-INF/spring/applicationContext-jpa.xml
    ---------------------------------------------
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans:beans xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.springframework.org/schema/data/jpa"
      xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd">
    
    	  <repositories base-package="edu.company.project" />
    
    </beans:beans>

    Any help would be much appreciated! Thanks.

  2. #2

    Default

    I'm having this same problem, exactly the same, and don't have any idea how to solve.
    I'm using this same versions of Spring Framework and STS, but my web project was generated by Spring Roo 1.2.

    I've thinking that the problem would be caused by Roo, but seems not.

  3. #3
    Join Date
    Dec 2011
    Posts
    14

    Default

    If you look closely, you'll see a couple of references to Spring Roo (1.2) in the config as well. That is also how my headers were generated. I posted in this forum because I didn't think it was a problem specific to Roo.

  4. #4
    Join Date
    Jan 2011
    Location
    Kirovohrad, Ukraine
    Posts
    59

    Default

    The problem is that spring-jpa-1.0.xsd hardcoded the version of spring-context to 3.0. That is the cause of the problems. Looks like this issue was fixed a while ago: https://jira.springsource.org/browse/DATAJPA-160. Unfortunately the fix is not in spring-data-jpa-1.0.2.RELEASE

  5. #5

    Default

    Thank you very much!

    I've changed the version of spring-data-jpa to 1.1.0.BUILD-SNAPSHOT and all worked fine.

  6. #6
    Join Date
    Dec 2011
    Posts
    15

    Default

    weird, I started having a problem like this when I installed cloud foundry plugin for eclipse, tried your solution, it did not solve my problem.


    the file applicationContext.jpa is acusing these errors:





    the application works, its just a pain in the ass the compilation error, it was right after I installed the cloud foundry plugin =/
    Last edited by lucas1223; Mar 18th, 2012 at 08:51 AM.

  7. #7
    Join Date
    Apr 2010
    Posts
    15

    Default To those lost in maven

    http://www.springsource.org/spring-data/jpa shows the exactly configuration.

    Like this:
    Code:
    <repository>
     <id>spring-milestone</id>
     <name>Spring Maven MILESTONE Repository</name>
     <url>http://repo.springsource.org/libs-milestone</url>
    </repository>
    
    <dependency>
     <groupId>org.springframework.data</groupId>
     <artifactId>spring-data-jpa</artifactId>
     <version>1.0.3.RELEASE</version>
    </dependency>
    or this:
    Code:
    <repository>
     <id>spring-snapshot</id>
     <name>Spring Maven SNAPSHOT Repository</name>
     <url>http://repo.springsource.org/libs-snapshot</url>
    </repository>
    
    <dependency>
     <groupId>org.springframework.data</groupId>
     <artifactId>spring-data-jpa</artifactId>
     <version>1.1.0.BUILD-SNAPSHOT</version>
    </dependency>

  8. #8
    Join Date
    Apr 2012
    Posts
    2

    Default What exactly needs to be done to avoid this error ?

    I'm pretty new to this.

    Therefore I'm looking for a step by step procedure to avoid the error.

    There should be some easy way because this error appears always directly after:

    web mvc setup

    any help is appreciated

  9. #9
    Join Date
    Apr 2010
    Posts
    15

    Red face Step by step

    Quote Originally Posted by chlub View Post
    I'm pretty new to this.

    Therefore I'm looking for a step by step procedure to avoid the error.

    There should be some easy way because this error appears always directly after:

    web mvc setup

    any help is appreciated
    1- Open the file pom.xml located at root of your project.
    2- Locate the tag <repositories> and the respective end tag
    3- before the end tag, put
    Code:
    <repository>
     <id>spring-snapshot</id>
     <name>Spring Maven SNAPSHOT Repository</name>
     <url>http://repo.springsource.org/libs-snapshot</url>
    </repository>
    now you will have a new repository location in internet that your maven will search for artifacs!
    4- Now you must update your artifact version, crtl+F (or command if you are in mac) and search for spring-data-jpa. You will find something like this:
    Code:
    <dependency>
     <groupId>org.springframework.data</groupId>
     <artifactId>spring-data-jpa</artifactId>
     <version>1.0.2.RELEASE</version>
    </dependency>
    5 - Replace the above with the right version like in :
    Code:
    <dependency>
     <groupId>org.springframework.data</groupId>
     <artifactId>spring-data-jpa</artifactId>
     <version>1.1.0.BUILD-SNAPSHOT</version>
    </dependency>

  10. #10
    Join Date
    Jul 2011
    Location
    Wokingham UK
    Posts
    35

    Default

    5 - Replace the above with the right version like in :
    Code:
    <dependency>
     <groupId>org.springframework.data</groupId>
     <artifactId>spring-data-jpa</artifactId>
     <version>1.1.0.BUILD-SNAPSHOT</version>
    </dependency>
    1.1.0.RELEASE - now available - thank goodness.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •