I'm getting an error -
org.springframework.beans.factory.BeanCreationException: Error creating bean
with name 'netLogsDao': Injection of resource dependencies failed; nested
exception is org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'abcDataSource' defined in
com.kinsale.submclrmgr.config.DataConfig: Bean instantiation via factory
method failed; nested exception is
org.springframework.beans.BeanInstantiationException: Failed to instantiate
[javax.sql.DataSource]: Factory method 'abcDataSource' threw exception;
nested exception is
org.springframework.jdbc.datasource.lookup.DataSourceLookupFailureException:
Failed to look up JNDI DataSource with name 'dataSource/abc'; nested
exception is javax.naming.NameNotFoundException: Name [dataSource/abc] is
not bound in this Context. Unable to find [dataSource].
I am trying to figure out how to bind my data source, however the documentation I've found isn't helpful. there is a JndiTemplate that I can use to bind the data source, passing the parameters of String name and Object object, but nothing I can find tells me anything about the object.
What is the object that I bind to the name of the data source? And is it the name of the Bean I am creating or the name of the Resource in the context.xml?
Here is the Bean -
@Bean(name="abcDataSource")
public DataSource abcDataSource(){
JndiDataSourceLookup jndi = new JndiDataSourceLookup();
jndi.setResourceRef(true);
return jndi.getDataSource("dataSource/abc");
Here is the use of the bean -
@Resource(name="abcDataSource")
private DataSource ds;
Here is the context.xml entry (I do have the correct username and password)-
<Resource
name="dataSource/abc"
auth="Container"
type="com.mysql.jdbc.jdbc2.optional.MysqlDataSource"
factory="org.apache.naming.factory.BeanFactory"
URL="jdbc:mysql://abc/db_netlogs" />