java - Cannot find dataSource, even though the dataSource is defined in context.xml -


i have following bean declared 1 particular dao method use different data source rest of project.

    @bean(name="kingsdatasource")     public datasource kingsdatasource(){      jndidatasourcelookup jndi = new jndidatasourcelookup();     jndi.setresourceref(true);      return jndi.getdatasource("datasource/kings"); 

here's use of bean.

    @resource(name="kingsdatasource")     private datasource ds; 

here's context.xml (omitting user , password, have been verified correct, , have been throwing different error if wrong anyway.) have played putting in context.xml of server, having in 1 place , not other, , having in both places.

  <resource    name="datasource/kings"    auth="container"   type="com.mysql.jdbc.jdbc2.optional.mysqldatasource"   factory="org.apache.naming.factory.beanfactory"   url="jdbc:mysql://kings/db_netlogs" /> 

the error name not found exception -

caused by: javax.naming.namenotfoundexception: name [datasource/kings]  not bound in context. unable find [datasource]. 

my question, then, - bind , how?

try add resource-ref web.xml

<resource-ref>     <res-ref-name>datasource/kings</res-ref-name>     <res-type>javax.sql.datasource</res-type>     <res-auth>container</res-auth>     <res-sharing-scope>shareable</res-sharing-scope> </resource-ref> 

Comments

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -