Results 1 to 8 of 8

Thread: Beans environment profile does not work

  1. #1
    Join Date
    Jul 2012
    Posts
    27

    Default Beans environment profile does not work

    I am trying to configure bean profiles but it does not work,
    I see in the log the message:
    DEBUG 2012-12-12 13:27:00,815 [main] core.env.PropertySourcesPropertyResolver - Found key 'spring.profiles.active' in [systemProperties] with type [String] and value 'dev'
    DEBUG 2012-12-12 13:27:00,824 [main] core.env.StandardEnvironment - Activating profile 'dev'

    which means that the profile was activated but it does not seem to work, can any one help me with this?

    Here is the xml configuration:
    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"
    	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">
           		
           		
    		
    <beans profile="dev">  
    		
    		<import resource="com.leadspace.common.msg.amq.xml" />            
    	    <!-- ********************* Task executors ************************ -->
    		<bean id="workersTaskExecutor" class="com.leadspace.common.messaging.taskexecutors.WorkersTaskExecutor">
    			<property name="taskExecutor" ref="threadPoolExecutor"/>
    		</bean>
    		
    		<bean id="threadPoolExecutor" class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor">
    				<property name="corePoolSize" value="20"/>
    				<property name="queueCapacity" value="40"/>
    				<property name="keepAliveSeconds" value="600"/>
    				<property name="maxPoolSize" value="50"/>
    			</bean>
    		
    		<!-- ********************* Task Services ************************ -->
    	
    	<bean id="taskService" class="com.leadspace.common.messaging.services.BasicTaskService"
    		abstract="true"
    		scope="singleton">
    		<property name="taskExecutor" ref="workersTaskExecutor" /> 
    	</bean>
    	
    	 <bean id="taskServiceDispatcher"
    		class="com.leadspace.common.messaging.services.BasicTaskService"
    		parent="taskService" scope="singleton">
            <property name="taskExecutor" ref="jmsSenderTaskExecutor"/>
    	</bean>
    	
    	<bean id="taskServiceExecutor"
    			class="com.leadspace.common.messaging.services.BasicTaskService"
    			parent="taskService" scope="singleton">
    	        <property name="taskExecutor" ref="workersTaskExecutor"/>
    		</bean>
    	
    		
    		<!-- ********************* Logics ************************ -->
    		 <bean id="runSpotLightProject"
    			class="com.leadspace.controller.messaging.logics.RunSpotLightProject">
    			<property name="service" ref="spotlightResultsService" /> 
    		</bean>
    		
    		<bean id="handleSpotlightResult"
    			class="com.leadspace.controller.task.SpotlightResultHandler">
    		</bean>
    		
    			<!-- ********************* Services ************************ -->
    		<bean id="service" class="com.leadspace.common.messaging.services.AbstractService"
    			abstract="true"
    			scope="prototype">
    			<property name="taskService" ref="taskService" /> 
    		</bean>
    		<bean id="spotlightResultsService" class="com.leadspace.controller.messaging.services.SpotlightResultService"
    			scope="prototype">
    			<property name="taskService" ref="taskServiceDispatcher" /> 
    		</bean>
    		
    </beans> 
    </beans>

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,624

    Default

    And it doesn't work becuase?! What is making you think it doesn't work.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  3. #3
    Join Date
    Jul 2012
    Posts
    27

    Default

    I have 2 processes: 1 in tomcat and one not. tomcat produces messages to the AMQ-queue and the other process consumes.
    I defined the spring xmls to have a profile called 'dev'
    the tomcat process loads the spring beans inside the active profile 'dev'
    but the jms listener which is on the other process and defined inside the profile 'dev' does call the 'onMessage' and
    when observing the acitve mq admin page i see no consumer on the queue defined.

    I have no idea to explain this.

  4. #4
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,624

    Default

    Why should the configuration on the tomcat side influence the config on the other side?! A system property is passed as a -D parameter one JVM doesn't influence the other JVM...
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  5. #5
    Join Date
    Jul 2012
    Posts
    27

    Default

    I know, i just mentioned this to show that i am configuring everything right since one side of the jms queue (the producer) works fine, but the other side does not.
    thanks

  6. #6
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,624

    Default

    Your story is confusing and for me you haven't configured it right... One JVM doesn't influence the other... So settings from x do nothing for y... Either make it an environment setting or pass the parameter to both processes...
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  7. #7
    Join Date
    Jul 2012
    Posts
    27

    Default

    I am sorry, i guess i didn't explain my self very well.
    The buttom line is that the listener bean which is defined in the active profile is not set as a consumer for some reason after i added the active profile support.
    It might be some problem I am responsible for, but i can't see it, since i configured other beans on other processes like this and they worked.
    Any way, I was wondering if someone ever tested this feature with the jms configuration in spring. if so, then it must be my mistake.
    thanks

  8. #8
    Join Date
    Jul 2012
    Posts
    27

    Default

    Hi,
    I found the problem, it was some configuration issues.
    thanks for the help.

Posting Permissions

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