Mr Smith
Mr Smith

Reputation: 3486

Spring UnsatisfiedDependencyException after upgrading spring from 3.1.1 to 4.3.3

I'm trying to upgrade my application to the latest version of Spring & Camel, but I'm getting the exception listed below. I also listed the config section that spring is having an issue with. FYI, my application, including this config element, is working fine with the older versions of the libraries. Why can't spring 4.3.3 find that class when Spring 3.1.1 finds it without any issues?

These are the libraries I'm updating:

I really only changed the pom.xml & a couple minor changes due to the library updates. Can anyone point me in the right direction on how to resolve this?

Spring is having an issue here

<bean id="test.format" class="org.apache.camel.dataformat.bindy.fixed.BindyFixedLengthDataFormat">
        <constructor-arg value="com.application.businessobject.test" />
</bean>

Exception

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'test.format' defined in class path resource [trs.application.finance.businessactivities.watchers.externaldata.xml]: Unsatisfied dependency expressed through constructor parameter 0: Could not convert argument value of type [java.lang.String] to required type [java.lang.Class]: Failed to convert value of type [java.lang.String] to required type [java.lang.Class]; nested exception is java.lang.IllegalArgumentException: Cannot find class [com.application.businessobject.test]

Upvotes: 1

Views: 1691

Answers (2)

hammerfest
hammerfest

Reputation: 2273

https://github.com/apache/camel/blob/master/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/fixed/BindyFixedLengthDataFormat.java

Apparently in earlier CAMEL versions there was a constructor of this class that expected packages as a String... vararg parameter, but has been since removed with this commit

https://github.com/apache/camel/commit/ce6bf6e6feb5f425cd544c4c1edfa2eb34641907

So your bean declaration is not valid any more and results in the above exception

Could not convert argument value of type [java.lang.String] to required type [java.lang.Class]:

Should be declared instead

<bean id="test.format" class="org.apache.camel.dataformat.bindy.fixed.BindyFixedLengthDataFormat">
  <constructor-arg>
    <value type="java.lang.Class">com.application.businessobject.Test</value>
  </constructor-arg>
</bean>

Upvotes: 2

ritesh.garg
ritesh.garg

Reputation: 3943

You need to change the constructor arg to be a class. Something like this:

<constructor-arg>
<value type="java.lang.Class">com.application.businessobject.Test</value>
</constructor-arg>

Upvotes: 2

Related Questions