0

We have been using Spring integration 4.3.1.RELEASE along with Spring core 4.3.2.RELEASE. Recently we had to upgrade the stack with 5.5.11 and 5.3.19 versions resp. This is not a Spring boot app.

After the migration, we are getting below error on start up

Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'channelInitializer': Initialization of bean failed; neste
d exception is org.springframework.beans.factory.BeanExpressionException: Expression parsing failed; nested exception is org.springframework.beans.factory.BeanNotOfRequired
TypeException: Bean named 'integrationGlobalProperties' is expected to be of type 'org.springframework.integration.context.IntegrationProperties' but was actually of type '
com.sun.proxy.$Proxy37'
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:628)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)
        at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:953)
        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583)
        at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:202)
        at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:177)
        at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:163)
        at com.xxx.xxx.report.listener.generator.ReportListener.main(ReportListener.java:65)
Caused by: org.springframework.beans.factory.BeanExpressionException: Expression parsing failed; nested exception is org.springframework.beans.factory.BeanNotOfRequiredType
Exception: Bean named 'integrationGlobalProperties' is expected to be of type 'org.springframework.integration.context.IntegrationProperties' but was actually of type 'com.
sun.proxy.$Proxy37'
        at org.springframework.context.expression.StandardBeanExpressionResolver.evaluate(StandardBeanExpressionResolver.java:170)
        at org.springframework.beans.factory.support.AbstractBeanFactory.evaluateBeanDefinitionString(AbstractBeanFactory.java:1631)
        at org.springframework.beans.factory.support.BeanDefinitionValueResolver.doEvaluate(BeanDefinitionValueResolver.java:280)
        at org.springframework.beans.factory.support.BeanDefinitionValueResolver.evaluate(BeanDefinitionValueResolver.java:252)
        at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:226)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1707)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1452)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:619)
        ... 12 more
Caused by: org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'integrationGlobalProperties' is expected to be of type 'org.springframework.integration.context.IntegrationProperties' but was actually of type 'com.sun.proxy.$Proxy37'
        at org.springframework.integration.context.IntegrationContextUtils.obtainUserProperties(IntegrationContextUtils.java:251)
        at org.springframework.integration.context.IntegrationContextUtils.getIntegrationProperties(IntegrationContextUtils.java:207)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.springframework.expression.spel.support.ReflectiveMethodExecutor.execute(ReflectiveMethodExecutor.java:139)
        at org.springframework.expression.spel.ast.MethodReference.getValueInternal(MethodReference.java:139)
        at org.springframework.expression.spel.ast.MethodReference.getValueInternal(MethodReference.java:95)
        at org.springframework.expression.spel.ast.CompoundExpression.getValueRef(CompoundExpression.java:61)
        at org.springframework.expression.spel.ast.CompoundExpression.getValueInternal(CompoundExpression.java:91)

Below is the spring configuration XML we use; we have not configured any bean by the name of 'integrationGlobalProperties' directly -

<bean id="propertyConfigurer" class="org.springframework.context.support.PropertySourcesPlaceholderConfigurer">
<property name="locations">
   <list>
        <value>classpath*:xx.properties</value>
        <value>classpath*:yy.properties</value>
   </list>
</property>
</bean>

<!-- Control channel -->
    <int:channel id="controlChannel" />
<jms:message-driven-channel-adapter.........
<int-xml:xpath-router ...........
<int:service-activator..........
<oxm:jaxb2-marshaller........

Main class is as below -

private static ClassPathXmlApplicationContext context;
public static void main(String[] args) {
String inboundChannel = "cccc";
context = new ClassPathXmlApplicationContext("/context.xml", ReportListener.class);
MessageChannel controlChannel = context.getBean("controlChannel", MessageChannel.class);
}

As per https://docs.spring.io/spring-integration/reference/html/whats-new.html, it is mentioned

The integrationGlobalProperties bean (if declared) must be now an instance of  
 org.springframework.integration.context.IntegrationProperties instead of java.util.Properties,  
 which support is deprecated for backward compatibility. 

But we have not explicitly configured this bean; as per documentation, there is a default set of global properties which will be applied if we do not override it.

Could anyone help advise what could be the reason for this exception?

Regards
Jacob

Jacob
  • 426
  • 3
  • 19
  • Seems adding a blank bean definition with id as "integrationGlobalProperties" and class as "org.springframework.integration.context.IntegrationProperties" in spring configuration XML fixed the issue. Is this the recommended way? – Jacob Jun 01 '22 at 07:34

1 Answers1

0

According to the error, it looks like there is some global AOP advice which is applied to this IntegrationProperties as well. So, please, revise that part of configuration to make it more specific for exact type of bean you'd like to proxy.

Artem Bilan
  • 113,505
  • 11
  • 91
  • 118
  • I have in spring config XML. Corresponding Aspect class is using specific advices like - Around("within(*..*Processor)"), Around("within(*..util.*)"), Around("within(*..services.*)"), Around("within(*..dao.*)"). Not sure how this may be getting applied to IntegrationProperties. – Jacob Jun 02 '22 at 05:18
  • I’d be glad to investigate if you share some simple project to reproduce and play with. Thanks – Artem Bilan Jun 02 '22 at 11:28