error when replacing Spring Bean with a subclass

Hyphen

New Member
I have a working call to a web service; we implement the logic to call the web service with a Spring bean configured with annotation:\[code\]@ManagedResource(objectName = "bean:name=XServiceMBean")@Service("xService")public class XServiceImpl implements XService{// working code here}\[/code\]For testing purposes, I would like to extend this class and inject the subclass instead of this one, so I made:\[code\]@ManagedResource(objectName = "bean:name=XServiceMBean")@Service("xService")public class XServiceImplTest extends XServiceImpl{// working code here}\[/code\]and commented out the two annotation lines from the superclass. Spring doesn't like it. When I run, I get:\[code\]Error creating bean with name 'xService':Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'xService' must be of type [com.hsc.correspondence.rules.XService], but was actually of type [com.hsc.correspondence.rules.impl.XServiceImplTest]\[/code\]I tried it again putting an explicit "implements XService on my subclass, with the same result. Am I doing something illegal in Spring? The original XServiceImpl has a number of @Resource annotations in it; I didn't think that would matter, I expected them to get injected just like they did before. Is there a way to do what I want to do, which is have a test class with absolute minimized changes to the original? (I would consider configuring in XML except I don't make those decisions in the project I'm on, but I didn't think it would matter to what I'm trying to do.
 
Top