Results 1 to 3 of 3

Thread: DispatcherServlet spring.profiles.active init-param

  1. #1
    Join Date
    Oct 2006
    Posts
    3

    Default DispatcherServlet spring.profiles.active init-param

    Hi,

    I've defined two beans
    HTML Code:
    <beans profile="dev">
        <jdbc:embedded-database id="dataSource" type="H2">
            ...
        </jdbc:embedded-database>
    </beans>
    
    <beans profile="prod">
        <jee:jndi-lookup id="dataSource" jndi-name="java:comp/env/jdbc/datasource"/>
    </beans>
    To enable a profile I've the following in my web.xml file (http://blog.springsource.com/2011/02...-1-m1-released)
    HTML Code:
    <servlet>
        <servlet-name>appServlet</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>/WEB-INF/spring/appServlet/servlet-context.xml</param-value>
        </init-param>
        <init-param>
            <param-name>spring.profiles.active</param-name>
            <param-value>dev</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>
    When I run my app I see the following in the console
    Code:
    Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in ServletContext resource [/WEB-INF/spring/data.xml]: Cannot resolve reference to bean 'dataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'dataSource' is defined
    Apparently it doesn't take the spring.profiles.active param
    Any ideas how to solve this ?


    Tim

  2. #2
    Join Date
    Aug 2011
    Location
    Mexico City / Atlanta GA
    Posts
    30

    Default

    Are you sure you are running Spring 3.1? Spring bean profiles is available as of version 3.1. By this time maybe you have solved the issue.

  3. #3
    Join Date
    Jun 2012
    Posts
    1

    Default

    This seems to be a common problem, per my experience and this post http://blog.wookets.com/2011/11/spri...t-profile.html
    You can use JVM args or system properties instead, read that page.

    This may be the explanation:
    http://forum.springsource.org/showth...-init-param-gt

Posting Permissions

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