0

I'm autowiring one of the dao class in my impl class as

@WebService
public class TransactionImpl implements Transaction{        

@Autowired
BBDao dao;

}

BBDao interface is as follows

public interface BBDao { /* Methods in it */ }

The implementation class which is implementing BBDao interface is

public class BBDaoImpl extends JdbcDaoSupport implements BBDao {    

@Autowired
ServletContext ctx; 

@Autowired
DataSource dataSource;

// Methods overriding here 

}

Servlet defined in web.xml

<servlet>
    <servlet-name>spring-web</servlet-name>
    <servlet-class>
                org.springframework.web.servlet.DispatcherServlet
            </servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
    <servlet-name>spring-web</servlet-name>
    <url-pattern>/</url-pattern>
</servlet-mapping>

And finally the spring-web-servlet.xml is

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="
    http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
    http://www.springframework.org/schema/mvc
    http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
    http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context-3.2.xsd">


<context:property-placeholder location="classpath:datasource-cfg.properties" />


<bean id="bbDAO" class="net.bb.dao.BBDaoImpl">
    <property name="dataSource" ref="dataSource" />
</bean> 

<!-- AS400 Data source Bean -->
<bean id="dataSource"
     class="org.springframework.jdbc.datasource.DriverManagerDataSource">

    <property name="driverClassName" value="com.ibm.as400.access.AS400JDBCDriver" />
    <property name="url" value="${as400.url}" />
    <property name="username" value="${as400.username}" />
    <property name="password" value="${as400.password}" />
</bean>

<mvc:annotation-driven />

</beans>

The BBDao bean object is coming as null.

Is there any mistake in my configuration? Any advice would be greatly appreciated.

Yakhoob
  • 559
  • 1
  • 12
  • 32
  • @ChackoMathew, Added , but still same – Yakhoob Nov 19 '17 at 09:22
  • Can you try adding `@Qualifier("bbDAO")` on autowired `BBDao` field in `TransactionImpl` class? – Chacko Nov 19 '17 at 09:31
  • @ChackoMathew No :( – Yakhoob Nov 19 '17 at 09:33
  • You are mixing many styles here! Autowiring and manual bean creation. Do these: Add ``, Add `@Component` on `BBDaoImpl`, remove the manual `bbDAO` bean creation – Chacko Nov 19 '17 at 09:34
  • @Chacko, it gives the exception No qualifying bean of type 'com.bb.dao.BBDao' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Qualifier(value=bbDAO), @org.springframework.beans.factory.annotation.Autowired(required=true)} – Yakhoob Nov 19 '17 at 09:42
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/159327/discussion-between-yakhoob-and-chacko-mathew). – Yakhoob Nov 19 '17 at 09:43

0 Answers0