Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

DataSourcePool in WorkflowProcess - unsolved

Avatar

Avatar
Affirm 3
Level 2
crich2784
Level 2

Likes

4 likes

Total Posts

32 posts

Correct Reply

2 solutions
Top badges earned
Affirm 3
Boost 3
Give Back
Validate 1
Boost 1
View profile

Avatar
Affirm 3
Level 2
crich2784
Level 2

Likes

4 likes

Total Posts

32 posts

Correct Reply

2 solutions
Top badges earned
Affirm 3
Boost 3
Give Back
Validate 1
Boost 1
View profile
crich2784
Level 2

27-05-2021

Don't know how my answer was accepted because I didn't accept it

https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/datasourcepool-in-workflow...

 

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

 

crich2784_0-1622141532084.png

 

I know it's probably something simple like permissions or proper placement of the sling:OsgiConfig.

 

Help is appreciated.

 

 

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Ignite 3
Level 5
davidjgonzalezzzz
Level 5

Likes

69 likes

Total Posts

77 posts

Correct Reply

31 solutions
Top badges earned
Ignite 3
Affirm 25
Ignite 1
Give Back 5
Give Back 3
View profile

Avatar
Ignite 3
Level 5
davidjgonzalezzzz
Level 5

Likes

69 likes

Total Posts

77 posts

Correct Reply

31 solutions
Top badges earned
Ignite 3
Affirm 25
Ignite 1
Give Back 5
Give Back 3
View profile
davidjgonzalezzzz
Level 5

27-05-2021

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;

Answers (1)

Answers (1)

Avatar

Avatar
Affirm 3
Level 2
crich2784
Level 2

Likes

4 likes

Total Posts

32 posts

Correct Reply

2 solutions
Top badges earned
Affirm 3
Boost 3
Give Back
Validate 1
Boost 1
View profile

Avatar
Affirm 3
Level 2
crich2784
Level 2

Likes

4 likes

Total Posts

32 posts

Correct Reply

2 solutions
Top badges earned
Affirm 3
Boost 3
Give Back
Validate 1
Boost 1
View profile
crich2784
Level 2

27-05-2021

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.