I have spring bean like:
<bean id="testBean" class="TestBean"
......
<property name="resolver" ref="resolver"....
class Resolver extends BaseResolver implements IManagementInterface
in class TestBean setter:
public void setResolver (IManagementInterface resolver) {
this.resolver=resolver;
...
But when I run I receive exception:
Cannot convert value of type Resolver to required type IManagementInterface.
But this seems not correct – because Resolver is also type IManagementInterface. What the sense of this error? Or may be I should clean install all my project?
Do a clean install first. If this doesn’t make the problem disappear, you might be experiencing a classloader problem. If your
Resolverinstance (and the corresponding class declarations) was loaded by a different classloader thanTestBean, it belongs to a different classloader realm, and it (or specifically its super interfaceIManagementInterface) is thus seen by the JVM as a completely different type from theIManagementInterfaceparameter type ofTestBean.setResolver. So one can’t be cast to another.See this earlier answer of mine for a way to verify whether or not this is the root cause.