Resource Resolver is null, tried everything I could find!
I have seen the same issue as I have listed numerous times in this forum and everything suggested I appear to have done.
Here is my simple class, all I am trying to do at this point is create an instance of a user manager and be done.
@Component(immediate = true, service = Servlet.class, property = { Constants.SERVICE_DESCRIPTION + "=User Sync",
"sling.servlet.methods=GET", "sling.servlet.paths=/services/userSync" })
public class UserSyncServlet extends SlingAllMethodsServlet {
private static final long serialVersionUID = 1L;
private static final Logger LOGGER = LoggerFactory.getLogger(UserSyncServlet.class);
private Session adminSession;
@Reference
private ResourceResolverFactory resolverFactory;
protected void doGet(final SlingHttpServletRequest req, final SlingHttpServletResponse resp)
throws ServletException, IOException {
resp.setContentType("text/plain");
resp.getWriter().write("User Sync POC\n");
ResourceResolver resolver = null;
try {
Map<String, Object> authInfoParam = new HashMap<String, Object>();
authInfoParam.put(ResourceResolverFactory.SUBSERVICE, "dataservice");
resp.getWriter().write(authInfoParam + "\n");
if (resolverFactory != null) {
resolver = resolverFactory.getServiceResourceResolver(authInfoParam);
adminSession = resolver.adaptTo(Session.class);
final UserManager userManager = resolver.adaptTo(UserManager.class);
} else {
resp.getWriter().write("Resolver is null\n");
}
} catch (Exception e) {
resp.getWriter().write("Exception..." + e.getMessage() + "\n");
} finally {
if (adminSession != null && adminSession.isLive()) {
adminSession.logout();
}
if (resolver != null)
resolver.close();
}
}
}
When I run this I get this...
User Sync POC
{sling.service.subservice=dataservice}
Resolver is null
My bundle is named thusly...
com.charter.panorama.bluesky.aem.AEMUserSync.core
My user mapper is set up like this
com.charter.panorama.bluesky.aem.AEMUserSync.core:dataservice=datawrite
And datawrite is a SYSTEM user, created thru the JCR and also I checked it is a member of the admins group and, just to be double sure has all permissions checked in the useradmin tool.
What am I doing wrong?
If it helps, the only logs this seems to throw out to help me are on the sync.log
01.05.2019 13:00:02.938 *DEBUG* [qtp1919192112-69] org.apache.jackrabbit.oak.spi.security.authentication.AbstractLoginModule Login: retrieving Credentials using callback.
01.05.2019 13:00:02.938 *DEBUG* [qtp1919192112-69] org.apache.jackrabbit.oak.spi.security.authentication.AbstractLoginModule Login: No supported credentials obtained from callback; trying shared state.
01.05.2019 13:00:02.938 *DEBUG* [qtp1919192112-69] org.apache.jackrabbit.oak.spi.security.authentication.AbstractLoginModule Login: No supported credentials found in shared state; looking for credentials in subject.
01.05.2019 13:00:02.938 *DEBUG* [qtp1919192112-69] org.apache.jackrabbit.oak.spi.security.authentication.AbstractLoginModule No credentials found.
01.05.2019 13:00:02.938 *DEBUG* [qtp1919192112-69] org.apache.jackrabbit.oak.spi.security.authentication.AbstractLoginModule Login: retrieving Credentials using callback.
01.05.2019 13:00:02.938 *DEBUG* [qtp1919192112-69] org.apache.jackrabbit.oak.spi.security.authentication.AbstractLoginModule Login: No supported credentials obtained from callback; trying shared state.
01.05.2019 13:00:02.939 *DEBUG* [qtp1919192112-69] org.apache.jackrabbit.oak.spi.security.authentication.AbstractLoginModule Login: No supported credentials found in shared state; looking for credentials in subject.
01.05.2019 13:00:02.939 *DEBUG* [qtp1919192112-69] org.apache.jackrabbit.oak.spi.security.authentication.AbstractLoginModule No credentials found.
01.05.2019 13:00:02.962 *DEBUG* [qtp1919192112-69] org.apache.jackrabbit.oak.spi.security.authentication.AbstractLoginModule Login: retrieving Credentials using callback.
01.05.2019 13:00:02.964 *DEBUG* [qtp1919192112-69] org.apache.jackrabbit.oak.spi.security.authentication.AbstractLoginModule Login: Credentials 'org.apache.jackrabbit.api.security.authentication.token.TokenCredentials@22d5bd39' obtained from callback
01.05.2019 13:00:02.969 *DEBUG* [0:0:0:0:0:0:0:1 [1556733602967] GET /services/userSync HTTP/1.1] org.apache.jackrabbit.oak.spi.security.authentication.external.impl.ExternalLoginModule No 'SupportedCredentials' configured. Using default implementation supporting 'SimpleCredentials'.
it does seem to indicate some creds are pulled back but it ends with No 'SupportedCredentials' configured.
so that seems to be my issue but going thru video demo's I seem to have set up everything correctly.
Please help.
Thanks