Don't know how my answer was accepted because I didn't accept it
I'll give some more detail because I have RTFM as was answered (and accepted mysteriously).
This is my code for injecting the DataSourcePool Reference.
The SIADB is not found.
public class queryForSingleRow implements WorkflowProcess {
private static final Logger log = LoggerFactory.getLogger(queryForSingleRow.class);
@reference
private DataSourcePool dsp;
@Override
public void execute(WorkItem workItem, WorkflowSession workflowSession, MetaDataMap args) throws WorkflowException {
String dataSourceName = "SIADB";
Connection connection = null;
DataSource ds = null;
try {
log.info("Checking datasources");
for(Iterator<String> it = dsp.getAllJndiDataSourceNames().iterator(); it.hasNext();) {
String dsname = it.next();
log.info("Found datasource " + dsname);
}
log.info("Using DataSourcePool service lookup to get connection pool " + dataSourceName);
ds = (DataSource) dsp.getDataSource(dataSourceName);
connection = ds.getConnection();
//More code after
Log file output:
2021-05-27 13:41:21.737 INFO [com.s360g.aem.workflowcomponent.custom.queryForSingleRow] Checking datasources
2021-05-27 13:41:21.737 INFO [com.s360g.aem.workflowcomponent.custom.queryForSingleRow] Using DataSourcePool service lookup to get connection pool SIADB
2021-05-27 13:41:21.737 INFO [com.s360g.aem.workflowcomponent.custom.queryForSingleRow] Unable to find datasource SIADB.
com.day.commons.datasource.poolservice.DataSourceNotFoundException: No data source found with name 'SIADB' (after asking 0 providers)
I have this in CRX - /apps/source360/com.day.commons.datasource.jdbcpool.JdbcPoolService-SIADB
I know it's probably something simple like permissions or proper placement of the sling:OsgiConfig.
Help is appreciated.
Solved! Go to Solution.
Views
Replies
Total Likes
Just a quick note, @reference should be @Reference (capital R).
Then, OSGi configs in the JCR must be in folder named "config" (or "config.<runmode>") that is no more than 4 levels from the root; So it should be at: /apps/source360/config/com.day.commons.datasource.jdbcpool.JdbcPoolService-SIADB
Lastly, you should be able to do away with your lookup logic and let OSGi annotations do all the hard work...
@Reference(target="(datasource.name=SIADB)")
private DataSourcePool dsp;
Ok, I figured it out.
Making an sling:OsgiConfig node in CRX manually does not work as the instructions imply.
Go to ConfigMgr
Search for jdbcpool
Add new configuration.
The datasource.name is waaay at the bottom - I missed that.
Save it and it works.
Just a quick note, @reference should be @Reference (capital R).
Then, OSGi configs in the JCR must be in folder named "config" (or "config.<runmode>") that is no more than 4 levels from the root; So it should be at: /apps/source360/config/com.day.commons.datasource.jdbcpool.JdbcPoolService-SIADB
Lastly, you should be able to do away with your lookup logic and let OSGi annotations do all the hard work...
@Reference(target="(datasource.name=SIADB)")
private DataSourcePool dsp;
Views
Replies
Total Likes
Views
Replies
Total Likes
Views
Likes
Replies