IN AEM 6.1 -- you need an AEM system user -- see this community article:
https://helpx.adobe.com/experience-manager/using/jqom.html
It shows you how to setup the system user and properly run this code:
Map<String, Object> param = new HashMap<String, Object>();
param.put(ResourceResolverFactory.SUBSERVICE, "jqom");
ResourceResolver resolver = null;
try {
//Invoke the getServiceResourceResolver method to create a Session instance
resolver = resolverFactory.getServiceResourceResolver(param);