cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Accessing model data during Spring bean initialization

Former Member
0 Likes
936

Hi,

I am trying to associate configuration values to the bean during initialization. The runtimeConfig is a service class that looks up the input parameter from DB. Saw some examples in google that the below approach is possible. However, I am getting the below exception:

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mqQueueConnectionFactory' defined in class path resource [orrpocintegration-messaging-spring.xml]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanExpressionException: Expression parsing failed; nested exception is java.lang.NullPointerException

My Spring Configuration:

where

 <bean name="defaultRuntimeConfigurationService" class="com.prasun.integration.runtime.service.impl.DefaultRuntimeConfigurationService" />

Need help. Thanks.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Likes

My hybris is running on a cluster 6 nodes and I would need to change the configuration at runtime depending on situation. App Node hAC is not accessible. Hence, I am planning to use DB based configuration rather than using local.properties.

andyfletcher
Active Contributor
0 Likes

But that wouldn't work with your original config anyway. The properties aren't live they are just fed in at configuration time.

I'm not familiar with a Spring 'runtimeConfig' and can't find any documentation on it. How would it work? Is it wrapping the bean in a proxy that intercepts the getters? It's not at all clear from your example how this is supposed to work.

Perhaps something with a ConfigChangeListener and a ClusterAwareEvent to broadcast those changes would work for you?

andyfletcher
Active Contributor
0 Likes

You don't seem to have declared a runtimeConfig bean. Why not use the more Hybris-y ConfigurationService ? Then it'll pick up the values from your local.properties file.

e.g.

 <bean id="qohMQConnectionFactory" class="org.springframework.jms.connection.CachingConnectionFactory">
  <property name="targetConnectionFactory">
      <bean id="mqQueueConnectionFactory" class="com.ibm.mq.jms.MQQueueConnectionFactory"
          p:transportType="#{configurationService.configuration.getString('qoh.mq.transport-type')}" 
          p:queueManager="#{configurationService.configuration.getString('qoh.mq.queue-manager')}"
          p:channel="#{configurationService.configuration.getString('qoh.mq.channel')}" 
          p:hostName="#{configurationService.configuration.getString('qoh.mq.host')}" 
          p:port="#{configurationService.configuration.getString('qoh.mq.port')}"
          p:clientReconnectTimeout="#{configurationService.configuration.getString('qoh.mq.connection.retry.timeout')}"/>        
  </property>
  </bean>