KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have two Service classes which implement the same interface ServiceClass1 @Service public class ServiceClass1 implements ItemsService{ @Autowired Class1DaoImpl class1Dao; @Transactional public List<Class1> getAllItems() { return class1Dao.getAllItems(); } ServiceClass2 @Service public class ServiceClass2 implements ItemsService{ @Autowired Class2DaoImpl class2Dao; @Transactional public List<Class2> getAllItems() { return class2Dao.getAllItems(); } And this is the controller class @Controller public class IndexController { @Autowired ServiceClass1 serviceClass1; @Autowired ServiceClass1 serviceClass2; ............ ..... } I got this error when the page was requested java.lang.IllegalArgumentException: Can not set com.package.ServiceClass1 field com.package.IndexController.serviceClass1 to $Proxy25 sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:146) sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:150) sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:63) java.lang.reflect.Field.set(Field.java:657) org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:500) org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:84) org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:284) org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1074) org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutow
Tags (comma-separated)
Save Edits
Cancel