Announcement Announcement Module
Collapse
No announcement yet.
XML Validation Problems - A schema cannot contain two global components with the same Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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.

    Comment


    • #3
      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.

      Comment


      • #4
        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

        Comment


        • #5
          Thank you very much!

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

          Comment


          • #6
            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:


            http://img195.imageshack.us/img195/8...20318at103.png


            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, 08:51 AM.

            Comment


            • #7
              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>

              Comment


              • #8
                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

                Comment


                • #9
                  Step by step

                  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>

                  Comment


                  • #10
                    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.

                    Comment


                    • #11
                      Thanks, this fixed my problem

                      Comment


                      • #12
                        Originally posted by lucas1223 View Post
                        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:


                        http://img195.imageshack.us/img195/8...20318at103.png


                        the application works, its just a pain in the ass the compilation error, it was right after I installed the cloud foundry plugin =/
                        I have solved it by doing 3 things:

                        1. Added this repository to my POM:
                        <repository>
                        <id>spring-milestone</id>
                        <name>Spring Maven MILESTONE Repository</name>
                        <url>http://repo.springsource.org/libs-milestone</url>
                        </repository>


                        2. I'm using this version of spring-jpa:
                        <dependency>
                        <groupId>org.springframework.data</groupId>
                        <artifactId>spring-data-jpa</artifactId>
                        <version>1.2.0.RELEASE</version>
                        </dependency>


                        3. I removed the xsd versions from my context (although I'm not sure it is necessary):
                        <?xml version="1.0" encoding="UTF-8"?>
                        <beans xmlns="http://www.springframework.org/schema/beans"
                        xmlns:context="http://www.springframework.org/schema/context"
                        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jdbc="http://www.springframework.org/schema/jdbc"
                        xmlns:jpa="http://www.springframework.org/schema/data/jpa" xmlns:tx="http://www.springframework.org/schema/tx"
                        xsi:schemaLocation="
                        http://www.springframework.org/schema/beans http://www.springframework.org/schem...ring-beans.xsd
                        http://www.springframework.org/schema/context http://www.springframework.org/schem...ng-context.xsd
                        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
                        http://www.springframework.org/schema/data/jpa http://www.springframework.org/schem...spring-jpa.xsd
                        http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd">



                        I hope this helps.
                        Last edited by forhas; Dec 6th, 2012, 03:29 AM.

                        Comment


                        • #13
                          I'm still getting this error with Spring 3.1.4 and Spring Data JPA 1.2.0 and 1.3.0.
                          Using Spring 3.0.7 is obviously fine.

                          None of the mentioned tips has helped to resolve this issue so far, its really quite annoying.

                          Comment


                          • #14
                            This happens on Framework 3.2.1.RELEASE when using Spring Data JPA 1.2.0.RELEASE and 1.3.0.RELEASE as well. Generic or versioned XSD references seem to make no difference. I also tried reorganizing my POM to ensure that transient dependencies were resolved at the correct version with no luck. This is rather annoying...

                            Comment


                            • #15
                              Originally posted by michael_lashinsky View Post
                              This happens on Framework 3.2.1.RELEASE when using Spring Data JPA 1.2.0.RELEASE and 1.3.0.RELEASE as well. Generic or versioned XSD references seem to make no difference. I also tried reorganizing my POM to ensure that transient dependencies were resolved at the correct version with no luck. This is rather annoying...
                              Of course this just made me a liar... I had versioned schema locations, made them generic, reordered my POM and made the assumption that versionless should work regardless. Went back versioned my schemas and the error was resolved.

                              my spring config header:
                              Code:
                              <?xml version="1.0" encoding="UTF-8"?>
                              <beans xmlns="http://www.springframework.org/schema/beans" 
                                     	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                                     	xmlns:p="http://www.springframework.org/schema/p" 
                                     	xmlns:tx="http://www.springframework.org/schema/tx"
                                     	xmlns:context="http://www.springframework.org/schema/context"
                                     	xmlns:jdbc="http://www.springframework.org/schema/jdbc"
                                     	xmlns:jpa="http://www.springframework.org/schema/data/jpa"
                                     	xmlns:util="http://www.springframework.org/schema/util"
                                     	xsi:schemaLocation="
                              			http://www.springframework.org/schema/beans 
                              			http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
                              			http://www.springframework.org/schema/tx 
                              			http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
                              			http://www.springframework.org/schema/context
                              			http://www.springframework.org/schema/context/spring-context-3.2.xsd
                              			http://www.springframework.org/schema/jdbc 
                              			http://www.springframework.org/schema/jdbc/spring-jdbc-3.2.xsd
                              			http://www.springframework.org/schema/data/jpa
                                 			http://www.springframework.org/schema/data/jpa/spring-jpa-1.3.xsd
                              			http://www.springframework.org/schema/util 
                              			http://www.springframework.org/schema/util/spring-util-3.2.xsd">
                              my pom.xml
                              Code:
                                   ...
                                  <!-- Spring Web MVC -->
                                  <dependency>
                                    <groupId>org.springframework</groupId>
                                    <artifactId>spring-webmvc</artifactId>
                                    <version>3.2.1.RELEASE</version>
                                    <exclusions>
                                      <exclusion>
                                        <groupId>commons-logging</groupId>
                                        <artifactId>commons-logging</artifactId>
                                      </exclusion>
                                    </exclusions>
                                  </dependency>
                                   ...
                                  <!-- Spring JPA -->
                                  <dependency>
                                    <groupId>org.springframework.data</groupId>
                                    <artifactId>spring-data-jpa</artifactId>
                                    <version>1.3.0.RELEASE</version>
                                  </dependency>
                                  ...
                              The reason this works makes no sense to me, but it does so I am semi-happy. Hope someone else finds this useful.

                              Comment

                              Working...
                              X