title: Spring3 Dependency Injection not working with mule
body: <p>I am unable to inject customerDao object in reference variable inside CustomerServiceImpl service class.</p>
  
  <p>Here is my mule_flow.mflow file</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  
  &lt;mule xmlns:http="http://www.mulesoft.org/schema/mule/http"
      xmlns:cxf="http://www.mulesoft.org/schema/mule/cxf"
      xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:spring="http://www.springframework.org/schema/beans" version="CE-3.3.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="
  http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd 
  http://www.mulesoft.org/schema/mule/cxf http://www.mulesoft.org/schema/mule/cxf/current/mule-cxf.xsd 
  http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd 
  http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd "&gt;
  
  
  &lt;flow name="helloService" doc:name="helloService"&gt;
  &lt;http:inbound-endpoint exchange-pattern="request-response"
  address="http://localhost:8081/hello" doc:name="HTTP" /&gt;
  &lt;cxf:simple-service serviceClass="com.proj.pos.demo.HelloWorld"
  doc:name="SOAP" /&gt;
  &lt;component class="com.proj.pos.demo.ServiceAImplService"
  doc:name="Java" /&gt;
  &lt;/flow&gt;
  
  &lt;flow name="addCustomer" doc:name="addCustomer"&gt;
  &lt;http:inbound-endpoint exchange-pattern="request-response"
  address="http://localhost:8081/pos/addCustomer" doc:name="HTTP" /&gt;
  &lt;cxf:simple-service serviceClass="com.proj.pos.webservice.interfac.CustomerService"
  doc:name="SOAP" /&gt;
  &lt;component class="com.proj.pos.webservice.implementation.CustomerServiceImpl"
  doc:name="Java" /&gt;
  &lt;/flow&gt;
  
  &lt;spring:beans&gt;
   &lt;spring:import resource="classpath:spring-mule.xml"/&gt;
  &lt;/spring:beans&gt;
  &lt;/mule&gt;
  </code></pre>
  
  <p>Here is my Spring-mule.xml file</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:aop="http://www.springframework.org/schema/aop"
      xmlns:context="http://www.springframework.org/schema/context"
      xmlns:jee="http://www.springframework.org/schema/jee"
      xmlns:lang="http://www.springframework.org/schema/lang"
      xmlns:p="http://www.springframework.org/schema/p"
      xmlns:tx="http://www.springframework.org/schema/tx"
      xmlns:util="http://www.springframework.org/schema/util"
      xmlns:mvc="http://www.springframework.org/schema/mvc"
      xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
          http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
          http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
          http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee.xsd
          http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang.xsd
          http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
          http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd
          http://www.springframework.org/schema/mvc
          http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd" &gt;
  
  
          &lt;bean id="datasource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"&gt;
  &lt;property name="driverClassName" value="oracle.jdbc.OracleDriver" /&gt;
  &lt;property name="url" value="jdbc:oracle:thin:@localhost:1521:xe" /&gt;
  &lt;property name="username" value="test" /&gt;
  &lt;property name="password" value="test" /&gt;
  &lt;/bean&gt; 
  
      &lt;bean id="sessionFactory"
          class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"&gt;
          &lt;property name="dataSource" ref="datasource" /&gt;
          &lt;property name="configLocation"&gt;
              &lt;value&gt;classpath:hibernate.cfg.xml&lt;/value&gt;
          &lt;/property&gt;
          &lt;property name="configurationClass"&gt;
              &lt;value&gt;org.hibernate.cfg.AnnotationConfiguration&lt;/value&gt;
          &lt;/property&gt;
          &lt;property name="hibernateProperties"&gt;
              &lt;props&gt;
                  &lt;prop key="hibernate.dialect"&gt;org.hibernate.dialect.Oracle10gDialect&lt;/prop&gt;
                  &lt;prop key="hibernate.show_sql"&gt;true&lt;/prop&gt;
                  &lt;prop key="cache.provider_class"&gt;org.hibernate.cache.NoCacheProvider&lt;/prop&gt;
                  &lt;prop key="hibernate.connection.release_mode"&gt;auto&lt;/prop&gt;
              &lt;/props&gt;
          &lt;/property&gt;
      &lt;/bean&gt;
  
      &lt;tx:annotation-driven /&gt;
      &lt;bean id="transactionManager"
          class="org.springframework.orm.hibernate3.HibernateTransactionManager"&gt;
          &lt;property name="sessionFactory" ref="sessionFactory" /&gt;
      &lt;/bean&gt;
  
       &lt;bean id="customerDao" class="com.proj.pos.dao.implementation.CustomerDaoImpl"&gt;
      &lt;property name="sessionFactory"&gt;
      &lt;ref local="sessionFactory"/&gt;
      &lt;/property&gt;
      &lt;/bean&gt;
  
      &lt;bean id="customerService" scope="prototype" class="com.proj.pos.webservice.implementation.CustomerServiceImpl"&gt;
      &lt;property name="customerDao" &gt;
      &lt;ref local="customerDao"/&gt;
      &lt;/property&gt;
      &lt;/bean&gt;
   &lt;/beans&gt;
  </code></pre>
  
  <p>Here is my CustomerServiceImpl.java</p>
  
  <pre><code>package com.proj.pos.webservice.implementation;
  
  import javax.jws.WebMethod;
  import javax.jws.WebParam;
  import javax.jws.WebResult;
  import javax.jws.WebService;
  
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.transaction.annotation.Transactional;
  
  import com.proj.pos.dao.interfac.CustomerDao;
  import com.proj.pos.entity.Customer;
  import com.proj.pos.webservice.interfac.CustomerService;
  @WebService(endpointInterface = "com.proj.pos.webservice.interfac.CustomerService",
          serviceName = "CustomerService")
  public class CustomerServiceImpl implements CustomerService {
  
      public CustomerDao getCustomerDao() {
          return customerDao;
      }
      public void setCustomerDao(CustomerDao customerDao) {
          this.customerDao = customerDao;
      }
      @Autowired
      private CustomerDao customerDao;//not getting populated.tried removing autowired as well.
      @Transactional
      @WebMethod(operationName="addCustomer")
      @WebResult(name="addCustomerResult")  
      @Override
      public Customer addCustomer(@WebParam(name="customerId")long customerId,@WebParam(name="fname")String fname,@WebParam(name="lname")String lname,@WebParam(name="age")long age,@WebParam(name="dateOfBirth")String dateOfBirth,@WebParam(name="address")String address) {
          Customer customer=new Customer(customerId, fname, lname, age, dateOfBirth, address);
          customer.setCustomerId(customerDao.persist(customer));//throws NUllPointerException here as customerDao is null..
           return customer;
      }
  
  }
  </code></pre>
  
  <p>Any idea why DI not working?</p>