You don't need and don't want to call JcrUtils.getRepository
in a Sling/CQ app, you should rather access the SlingRepository OSGi service that CQ provides.
The simplest is to use an @Reference
annotation in an OSGi declarative services @Component
- there are multiple examples of this in the Apache Sling codebase, the http://svn.apache.org/repos/asf/sling/trunk/samples/slingbucks sample is a good starting point for that.
If your code executes as part of request processing, you don't need to create a Session yourself, you can get it by calling request.getResourceResolver().adaptTo(Session.class)
where request
is the SlingHttpServletRequest
that you get in a Sling servlet.