Announcement Announcement Module
Collapse
No announcement yet.
SAXParseException when defining beans in profiles other than default and cloud Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • SAXParseException when defining beans in profiles other than default and cloud

    I'm attempting to use env's/profiles to provide a third option for deploying my Spring 3.1 app to Heroku as well as CloudFoundry but get a SAXParseException at runtime due to a duplicate id reference even though they're wrapped by different profiles. Here's my context:

    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:mongo="http://www.springframework.org/schema/data/mongo"
           xmlns:cloud="http://schema.cloudfoundry.org/spring"
           xmlns:context="http://www.springframework.org/schema/context"
           xsi:schemaLocation="http://www.springframework.org/schema/data/mongo http://www.springframework.org/schema/data/mongo/spring-mongo-1.0.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://schema.cloudfoundry.org/spring http://schema.cloudfoundry.org/spring/cloudfoundry-spring.xsd">
    
        <context:property-placeholder location="classpath*:*.properties"/>
    
        <mongo:repositories base-package="com.javamatters.repository" mongo-template-ref="mongoTemplate"/>
    
        <bean id="mongoTemplate" class="org.springframework.data.mongodb.core.MongoTemplate">
            <constructor-arg name="mongoDbFactory" ref="mongoDbFactory"/>
        </bean>
    
        <beans profile="default">
            <mongo:db-factory id="mongoDbFactory" dbname="javamatters" host="127.0.0.1"/>
        </beans>
    
        <beans profile="heroku">
            <mongo:db-factory id="mongoDbFactory" uri="${MONGOHQ_URL}"/>
        </beans>
    
        <beans profile="cloud">
            <cloud:mongo-db-factory id="mongoDbFactory"/>
        </beans>
    
    </beans>
    Here's the exception:

    https://gist.github.com/1601045

    Is there a workaround to prevent the SAXParseException or is this a known issue?

  • #2
    I was able to work around this issue by removing the id attributes from the mongo:db-factory bean definitions in the default and heroku profiles.

    Comment

    Working...
    X