Expand my Community achievements bar.

Submissions are now open for the 2026 Adobe Experience Maker Awards.

Mark Solution

This conversation has been locked due to inactivity. Please create a new post.

SOLVED

SQL-2 query produces results in crxde lite tools but not from an osgi

Avatar

Level 6

In trying to query the JCR from an OSGI bundle I am not getting any errors, just 0 returns.

 

The query I use is SELECT * FROM [cq:Page] WHERE ISDESCENDANTNODE('/content/***/en/recipes/all-recipes').

If I run the query tool in CRXDE lite I get back 174 results.

 

 

 In my OSGI bundle I have code as follows

param.put(ResourceResolverFactory.SUBSERVICE, "readService"); ResourceResolver resolver = null; try { resolver = resolverFactory.getServiceResourceResolver(param); } catch (LoginException e) { e.printStackTrace(); } try { session = resolver.adaptTo(Session.class); } catch (Exception e) { e.printStackTrace(); } try { javax.jcr.query.QueryManager queryManager = session.getWorkspace().getQueryManager(); String sqlStatement = "SELECT * FROM [cq:Page] WHERE ISDESCENDANTNODE('/content/***/en/recipes/all-recipes')"; javax.jcr.query.Query query = queryManager.createQuery(sqlStatement, "JCR-SQL2"); javax.jcr.query.QueryResult result = query.execute(); javax.jcr.NodeIterator nodeIter = result.getNodes(); Long length = nodeIter.getSize(); if (length == 0) { return recipesList; } //length is always 0, I get no errors. while (nodeIter.hasNext()) { String row = ""; javax.jcr.Node node = nodeIter.nextNode(); row = node.getProperty("couponsCategory").getString(); recipesList.add(row); }

 

 

Regards

Clive Stewart

1 Accepted Solution

Avatar

Correct answer by
Level 10

See this as an example:

https://helpx.adobe.com/experience-manager/using/java-swing-applications.html

Then once you know the code works - place it within an OSGi bundle. 

View solution in original post

3 Replies

Avatar

Level 10

Try setting up a Java desktop app and debug through the code. That is the nice part of the JCR API - you can run it from an Eclipse Java project and main method. 

Avatar

Correct answer by
Level 10

See this as an example:

https://helpx.adobe.com/experience-manager/using/java-swing-applications.html

Then once you know the code works - place it within an OSGi bundle. 

Avatar

Level 6

smacdonald2008 wrote...

Try setting up a Java desktop app and debug through the code. That is the nice part of the JCR API - you can run it from an Eclipse Java project and main method. 

 


Thank you Scott, your advice always clarifies to me what I need to do.

Regards

Clive Stewart