resourceResolver.commit() , works on Author server , throws "Access denied" on Publish server | Community
Skip to main content
New Participant
July 31, 2018
Solved

resourceResolver.commit() , works on Author server , throws "Access denied" on Publish server

  • July 31, 2018
  • 12 replies
  • 7335 views

Hi All,

I have a Java component bean which creates a child resource and then calls resourceResolver.commit().

It is working fine on the 6.3 Author server.

But on the 6.3 Publish server it is throwing the following exception:-

org.apache.sling.api.resource.PersistenceException: Unable to commit changes to session.

Caused by: org.apache.jackrabbit.oak.api.CommitFailedException: OakAccess0000: Access denied

    at org.apache.jackrabbit.oak.security.authorization.permission.PermissionValidator.checkPermissions(PermissionValidator.java:210) [org.apache.jackrabbit.oak-core:1.8.2]

Does anyone know how I can investigate / resolve this?

Thank you for your time.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by RobertBailey1

THANK YOU ALL!!     

Got there eventually using the steps below to create a System User , and then "map" System User with OSGi bundle :-

1.1.  Goto http://localhost:4542/crx/explorer/index.jsp

1.2.  Login as admin

1.3.  Click "User Administration"

1.4.  Click "Create SYSTEM User"

1.5.  Input UserID  (for example "content-writer")

1.6.  Click green tick to create System User

Repeat above process for Publish server (http://localhost:4543/crx/explorer/index.jsp)

2.1.  Goto http://localhost:4542/system/console/configMgr

2.2.  Search for "Apache Sling Service User Mapper Service"

2.3.  Click icon to "Edit the configuration values"

2.4.  Click plus ('+') button to add Service Mappings

2.5.  Input new Service Mappings  (for example "org.apache.sling.models.impl=content-writer"  or  "org.apache.sling.models.impl:content-writer=content-writer")

Repeat above process for Publish server (http://localhost:4543/system/console/configMgr)

After completing above steps , it should be possible to getServiceResourceResolver() using the following Java code :-

    final Map<String, Object> param = new HashMap<>();

    param.put(ResourceResolverFactory.SUBSERVICE, "content-writer");

    final ResourceResolver rr = resourceResolverFactory.getServiceResourceResolver(param);

12 replies

Jitendra_S_Toma
New Participant
July 31, 2018

Hi,

it works in author because in the author you always log in with the user who has correct access to modify/read the content. And I believe you are getting resourceResolver object from the Request object. In author, Request object gets the correct user. However, In the publish environment, Request object will have an anonymous user. And you know, the anonymous user will not have access to update the content of your pages.

The solution is that we should try with the user who can enough access in publish too. if no user exists then you need to create in publishing too.

I hope this helps.

arunpatidar
New Participant
July 31, 2018

Hi,

How you are getting resourceResolver?

The user should have permission to persist all the pending changes.

Can you check users permisisons?

Thanks

Arun

Arun Patidar