Getting cannot derive user name for bundle and sub service while creating resource resolver | Community
Skip to main content
Level 3
Nov 25, 2020 2:03 PM UTC
Solved

Getting cannot derive user name for bundle and sub service while creating resource resolver

Hi.

I'm using AEM 6.3

I have followed this correctly I think. and also followed Ensure authhorizable


I don't know if only one is required or both are required. I'm new at this.

 

Map<String, Object> params = new HashMap<>();
params.put(ResourceResolverFactory.SUBSERVICE, SERVICE);
ResourceResolver resourceResolver = resourceResolverFactory.getServiceResourceResolver(params)

 The above line is where I get the error. Have I missed something?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Manjunath_K
Manjunath_KAccepted solution
Level 7
Nov 27, 2020 5:06 PM UTC

Hi @vinit_pillai ,

Please cross check below points once.

 

1. Bundle symbolic name (project.core) defined in ServiceUserMapperImpl config xml is same as defined in core pom.xml 

<?xml version="1.0" encoding="UTF-8"?> <jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" jcr:primaryType="sling:OsgiConfig" user.mapping="[project.core:ServiceUser=ServiceUser]"/>

 

core pom.xml:

<Bundle-SymbolicName>project.core</Bundle-SymbolicName>

 

2. Access user admin (http://localhost:4502/useradmin ) & check whether service user created by EnsureServiceUser config xml

 

3. same subServiceName is used in backend java as defined in  ServiceUserMapperImpl config xml.

user.mapping="[project.core:ServiceUser=ServiceUser]

 

params.put(ResourceResolverFactory.SUBSERVICE, "ServiceUser");

 

Hope this helps!

6 replies

shelly-goel
Employee
Nov 28, 2020 5:53 PM UTC

@vinit_pillai  Since you're on AEM6.3, migrating to Sling RepoInit would be better to ensure authorizables https://sling.apache.org/documentation/bundles/repository-initialization.html

 

Translate
Manjunath_K
Manjunath_KAccepted solution
Level 7
Nov 27, 2020 5:06 PM UTC

Hi @vinit_pillai ,

Please cross check below points once.

 

1. Bundle symbolic name (project.core) defined in ServiceUserMapperImpl config xml is same as defined in core pom.xml 

<?xml version="1.0" encoding="UTF-8"?> <jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" jcr:primaryType="sling:OsgiConfig" user.mapping="[project.core:ServiceUser=ServiceUser]"/>

 

core pom.xml:

<Bundle-SymbolicName>project.core</Bundle-SymbolicName>

 

2. Access user admin (http://localhost:4502/useradmin ) & check whether service user created by EnsureServiceUser config xml

 

3. same subServiceName is used in backend java as defined in  ServiceUserMapperImpl config xml.

user.mapping="[project.core:ServiceUser=ServiceUser]

 

params.put(ResourceResolverFactory.SUBSERVICE, "ServiceUser");

 

Hope this helps!

Translate
Level 3
Nov 30, 2020 8:36 AM UTC

Symbolic name was the issue. I solved it before reading your answer but thanks. You were right.

Translate
arunpatidar
New Participant
Nov 25, 2020 3:34 PM UTC

Can you share the Apache sling Service User Mapper Service Amendment. mapping.

Make sure the system user is available and your code have the SERVICE name same as mapping

 

Please http://www.sgaemsolutions.com/2017/10/sling-service-authentication-in-aem-63.html

Translate
Arun Patidar
Level 3
Nov 25, 2020 3:46 PM UTC

<?xml version="1.0" encoding="UTF-8"?> <jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" jcr:primaryType="sling:OsgiConfig" user.mapping="[project.core:ServiceUser=ServiceUser]"/>

Translate