I am trying to make DAO with JdbcTemplate. But it seems that Spring injection not going well. I am injecting DataSource with JNDI from Tomcat.
Also I wrote settings in Tomcats server.xml, ResourceLink in /META-INF, resource-ref in web.xml, tried to add context-listener in web.xml, it also doesn`t help (actually, should I add listener, if I am not accessing DataSource from servlets, but only from DAO?).
What am I missing, why Spring not injecting it?
dao-context.xml
<context:component-scan base-package="somepackage"/>
<jee:jndi-lookup id="dataSource" jndi-name="jdbc/phonebook" expected-type="javax.sql.DataSource"/>
<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
<constructor-arg ref="dataSource"/>
</bean>
web.xml
<resource-ref>
<description>DatasourceJNDI</description>
<res-ref-name>jdbc/phonebook</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
META-INF/context.xml
<Context>
<ResourceLink name="jdbc/phonebook" global="jdbc/global_phonebook" type="javax.sql.DataSource"/>
server.xml in Tomcat
<Resource name="jdbc/global_phonebook" auth="Container" type="javax.sql.DataSource" driverClassName="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost:3306/phonebook" username="root" password="1234" maxActive="10" maxIdle="5" maxWait="-1" defaultAutoCommit="false" defaultTransactionIsolation="READ_COMMITTED"/>
tomcat localhost log http://shorttext.com/700e4579 tomcat catalina log http://shorttext.com/700f24cb