Results 1 to 4 of 4

Thread: Autowiring Class Issue (argument type mismatch)

  1. #1

    Default Autowiring Class Issue (argument type mismatch)

    I have a Interface:
    Code:
    public interface IGenericDAO
    and a implementing abstract class:
    Code:
    @Repository
    public abstract class  GenericDAOImpl implements IGenericDAO
    Then there are class that extends the abstract class like:
    Code:
    @Repository
    public class ClientDAO extends GenericDAOImpl
    When i try to autowire ClientDAO into serverice as below:
    Code:
    @Component
    public class ClientServiceImpl implements ClientService{
    	private ClientDAO clientDAO;
    	@Autowired
    	public void setClientDAO(Object clientDAO) {
    		this.clientDAO = clientDAO;
    	}
    It throws exception below:
    Code:
    Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire method: 
    public void com.xxx.service.impl.ClientServiceImpl.setClientDao(com.xxx.dao.ClientDAO); 
    nested exception is java.lang.IllegalArgumentException: argument type mismatch

  2. #2

    Default

    Just get it fixed. I aspect applied as:
    <aop:aspectj-autoproxy/>

    therefore marking it as :
    <aop:aspectj-autoproxy proxy-target-class = "true"/>

    fixes the issue.

  3. #3
    Join Date
    Jul 2010
    Location
    Venice, Italy
    Posts
    709

    Default

    You don't have to force classproxies to resolve this issue.
    Just use proper javabean setter specification (make the setter argument match the return type):

    Code:
    private ClientDAO clientDAO;
    	@Autowired
    	public void setClientDAO(ClientDAO clientDAO) {
    		this.clientDAO = clientDAO;
    	}
    or get rid of the setter altogether and autowire directly on the class variable:

    Code:
    @Autowired
    private ClientDAO clientDAO;

  4. #4

    Default

    I removed all setters and put @Autowired on variables. However this doesn't solve issue until class proxies are applied.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •