Announcement Announcement Module
Collapse
No announcement yet.
Beans environment profile does not work Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

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

    Comment


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

      Comment

      Working...
      X