Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

java.lang.IllegalStateException: This tree does not exist


Level 2

I'm seeing many occurrences of the below error in my log files, Any pointers what could be the root cause?

POST /content/dam/collections.collection.html HTTP/1.1] com.day.cq.dam.core.impl.servlet.ResourceCollectionServlet Could not create/update collection java.lang.IllegalStateException: This tree does not exist at org.apache.jackrabbit.oak.core.MutableTree.beforeWrite(MutableTree.java:423) ... 13 lines omitted ... at com.day.cq.dam.core.impl.servlet.ResourceCollectionServlet.doPost(ResourceCollectionServlet.java:298) at org.apache.sling.api.servlets.SlingAllMethodsServlet.mayService(SlingAllMethodsServlet.java:148)




1 Reply




 Please have a look at these old posts:-

Link:- http://stackoverflow.com/questions/34969498/post-servlet-not-able-to-access-damor-anything-at-all


  1. By default "admin" account is used to access the resources. From 6.1 this is not the case. Are you using AEM 6.1?

  2. Check the permissions to the resource (Path) you are trying to access. Is it under "everyone" group? Or? This maybe one possibility the resource is working in your DEV. In higher environments this may not be the case.

    One way i came around this issue is to use a custom service-user. I posted a solution here see if it helps.

  3. If you do not have access to higher-environments, then ask AEM-Admin to (a) either assign permissions to a specific user to access that DAM resource, so you can use that user in the solution above, (b)Or have "everyone" group have access to that DAM resource.


In AEM 6.1, service users must be system users, which effectively means that their node in the JCR is of type rep:SystemUser. These users cannot be used to log in normally, only by background processes. The admin user is not a system user, so you cannot use the admin user in a service user mapping like this. You have to create a new system user and assign them the appropriate permissions.

If you would like to read more of the background on this change, take a look athttps://issues.apache.org/jira/browse/SLING-3854.


// Important

Goal: To write data/nodes to content (specifically to /etc/userdata) when a user logs in.

We can achieve this in 2 ways (either way, the user needs to be a 'system user')

Process 1:

Step 1: Use in-built system user in OSGI configuration. In OSGI select Apache Sling Service User Mapper Service

group.abc.commons-service:writeService=oauthservice (where 'oauthservice' is a system user)

Step 2: Assign that system user the permissions to access the content folder.

enter image description here

You see the system users in CRX at: /home/users/system

Process 2:

Step 1: Create a new system user. to do this

Open http://localhost:4502/crx/explorer/index.jsp

Login as admin > Open 'User Administration > Select 'Create System User' > Enter "user id" > Hit the Green button (you will not se a save button :)

I have created "abcwriteservice" user

Step 2: Go to Permissions, and for the user 'abcwriteservice' give Permissions to access the folder where you'd like to write. (In this example: /etc/userdata ) enter image description here

Step 3: Open OSGI console and go to "Apache Sling Service User Mapper Service" to define the service-user mapping. For example: 'group.commons-service:writeService=abcwriteservice'

enter image description here

Step 4: In code, i added extra parameter, as:

Map<String, Object> param = new HashMap<String, Object>(); param.put(ResourceResolverFactory.SUBSERVICE, "writeService"); try { resourceResolverWriter = factory.getServiceResourceResolver(param); if (resourceResolverWriter == null) throw new Exception("Could not obtain a CRX User for the Service:'writeService'"); Node usersRootNode = adminSession.getNode("/etc/userdata/users");


I hope something among these click for you.

Or else clarify when and how this exception is coming in bit more detail.


Thanks and Regards

Kautuk Sahni

Kautuk Sahni