1

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?

skaffman
  • 398,947
  • 96
  • 818
  • 769
user710818
  • 23,228
  • 58
  • 149
  • 207

1 Answers1

2

Do a clean install first. If this doesn't make the problem disappear, you might be experiencing a classloader problem. If your Resolver instance (and the corresponding class declarations) was loaded by a different classloader than TestBean, it belongs to a different classloader realm, and it (or specifically its super interface IManagementInterface) is thus seen by the JVM as a completely different type from the IManagementInterface parameter type of TestBean.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.

Community
  • 1
  • 1
Péter Török
  • 114,404
  • 31
  • 268
  • 329