Java Xpath no result

Hi all,

I’m upgrading to 12 and now a piece of code does not work anymore:
try {
String qString = String.format("//%s[(@jcr:primaryType=‘hst:template’)]", template);
final Query query = JcrUtils.createXPathQuery(request.getRequestContext().getSession(), qString);

        final javax.jcr.query.QueryResult result = query.execute();
        final javax.jcr.NodeIterator iterator = result.getNodes();
        if (iterator.hasNext()) {
            final Node templateNode = iterator.nextNode();
            final String renderPath = templateNode.getProperty("hst:renderpath").getString();
            logger.info("Found renderpath {} for template {}", renderPath, template);
            response.setRenderPath(renderPath);
        } else {
            logger.warn("Failed to find renderpath for template {}", template);
        }
    } catch (RepositoryException e) {
        logger.warn("Unable to retrieve renderpath for template {}", template);
    }

Debugging tells me that path I’m looking for cannot be found anymore. I searched with:
request.getRequestContext().getSession().getRootNode().getNodes().forEachRemaining(node → { Node nodeName = (Node) node;
try {
String name = nodeName.getName();
} catch (RepositoryException e) {
logger.warn("text ", e);
}
});
I cannot find /hst:hst node, I do see jcr:system, hippo:log, content, webfiles, namespaces.

Use case for this code is to overrule the default template of a component. Overruling is done in channelmanager and in doBeforeRender the path of template is set.

Preferably I would like to keep this way of working, for now.

What can I do?

most probably user session has not enough rights to access that node.
In most cases you get pathnotfound exceptions…even though real cause is “access denied”

Thanks Marijan, working again!
The user aspect of this was out of my scope, now I will not forget about that!