Results 1 to 3 of 3

Thread: Beans environment profile does not work

  1. #1
    Join Date
    Jul 2012
    Posts
    27

    Default Beans environment profile does not work

    Hi,
    i am trying to use the beans environment profile - new feature of spring-beans-3.1
    but it does not work.
    This is what i did:

    Spring xml:
    ***********
    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:context="http://www.springframework.org/schema/context" xmlns:util="http://www.springframework.org/schema/util"
    	xmlns:jms="http://www.springframework.org/schema/jms"
    	xsi:schemaLocation="http://www.springframework.org/schema/beans 
    	       	http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
    	       	http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd
           		http://www.springframework.org/schema/context
           		http://www.springframework.org/schema/context/spring-context-3.0.xsd
           		http://www.springframework.org/schema/jms
           		http://www.springframework.org/schema/jms/spring-jms-3.0.xsd">
           		
    
    <beans profile="dev">
    	 <bean id="propertyConfigurer" class="com.leadspace.common.spring.EnvConfigurablePropertyPlaceholder">
    	    <property name="propertyFiles">
    				<list>
    				<value>properties/leadspace.properties</value>
    				<value>properties/custom.properties</value>
    				<value>properties/messaging.properties</value>
    				</list>
    		</property>
    		<property name="envPropertiesFileLocation" value="LEADSPACE_HOME" />
    	</bean>
    	
    
    	<!-- ******************* AMQ configuration **********************-->
    
        <!-- ********************** Producer ********************************* -->
    	<bean id="jmsSenderTaskExecutor" class="com.leadspace.common.messaging.taskexecutors.JmsSenderTaskExecutor">
    		 <property name="jmsTemplate" ref="jmsTemplate"/>  
    	</bean>
    
        .......... some more beans here ........
    </beans>
    </beans>
    registration of the profile:
    *********************
    Code:
    	((KnowledgeControllerServerContext) context).mSpringContext = SpringInitializerProxy.initialize(LeadspaceProperties.getControllerSpring());
    ApplicationContext appContext = ((KnowledgeControllerServerContext) context).mSpringContext;
    				
    FileSystemXmlApplicationContext fileContext = ((FileSystemXmlApplicationContext)(appContext));
    fileContext.getEnvironment().setActiveProfiles(LeadspaceProperties.getActiveProfile());
    I see in the log that the "dev" profile has been activated, but nothing works.

    Any ideas what might be the problem?
    thanks

  2. #2
    Join Date
    Dec 2009
    Location
    India
    Posts
    108

    Default

    I think you're setting the active profile too late as when here, your application context should be already loaded. Trying setting this option while starting your application using
    -Dspring.profiles.active=dev
    startup property

  3. #3
    Join Date
    Jul 2012
    Posts
    27

    Default

    Thanks, you are right. this was one of my problems. any ways, it works now.
    thanks

Posting Permissions

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