Expand my Community achievements bar.

SOLVED

javax.jcr.UnsupportedRepositoryOperationException: JCR-1104

Avatar

Level 6

I'm trying to add ACL pragmatically. I've added jackrabbit-standalone-2.6.3.jar in classpath, and I'm using CQ 5.6

Code: 

Repository repository = JcrUtils.getRepository("http://11.11.11.64:4502/crx/server");
Session session = repository.login(new SimpleCredentials("admin", "admin".toCharArray()),"crx.default");  

AccessControlManager aMgr = session.getAccessControlManager(); // Error is coming from here

 

Error: Exception in thread "main" javax.jcr.UnsupportedRepositoryOperationException: JCR-1104
    at org.apache.jackrabbit.jcr2spi.SessionImpl.getAccessControlManager(SessionImpl.java:501)

 

Repository.xml :

<Security appName="com.day.crx">
         <SecurityManager class="com.day.crx.core.CRXSecurityManager">
             <UserManager class="com.day.crx.core.CRXUserManagerImpl">
                <param name="usersPath" value="/home/users"/>
                <param name="groupsPath" value="/home/groups"/>
                <param name="defaultDepth" value="1"/>
                <param name="autoExpandTree" value="true"/>
            </UserManager>
         </SecurityManager>
        <AccessManager class="org.apache.jackrabbit.core.security.DefaultAccessManager"></AccessManager>
        <LoginModule class="com.day.crx.core.CRXLoginModule">
            <param name="anonymousId" value="anonymous"/>
            <param name="adminId" value="admin"/>
            <param name="tokenExpiration" value="43200000"/>
            <!-- param name="trust_credentials_attribute" value="d5b9167e95dad6e7d3b5d6fa8df48af8"/ -->
        </LoginModule>
    </Security>

 

 

I found the exact same issue here: http://mail-archives.apache.org/mod_mbox/jackrabbit-users/201307.mbox/%3CDD9A8DB7-3D84-464F-A14F-75D...krabbit-users/201307.mbox/%3CDD9A8DB7-3D84-464F-A14F-75DFAAAE570B@adobe.com%3E

but could not find any solution. Please advice. 

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

A number of operations are not supported when you connect via RMI or DAVEX. Setting ACLs might be one of these.

Jörg

View solution in original post

5 Replies

Avatar

Level 10

You are trying to create this object from a standalone Java app. Try creating this object from within an OSGi bunlde. For example:

//Inject a Sling ResourceResolverFactory

@Reference
private ResourceResolverFactory resolverFactory;
 
//Queries the AEM JCR for customer data and returns
//the data within an XML schema   
public String getCustomerData(String filter) {
 
Customer cust = null;
 
List<Customer> custList = new ArrayList<Customer>();
try {
           
    //Invoke the adaptTo method to create a Session
    ResourceResolver resourceResolver = resolverFactory.getAdministrativeResourceResolver(null);
    session = resourceResolver.adaptTo(Session.class);
 

     //Create an AccessControlManager instance
    AccessControlManager aMgr = session.getAccessControlManager();

 

TO learn how to work with the JCR API from within a CQ OSGi bundle, see this community article. 

http://helpx.adobe.com/experience-manager/using/querying-experience-manager-data-using1.html

Hope this helps

Avatar

Level 6

Thanks Sam, is it really not possible to apply ACL from standalone java code?

Avatar

Correct answer by
Employee Advisor

A number of operations are not supported when you connect via RMI or DAVEX. Setting ACLs might be one of these.

Jörg

Avatar

Level 10

I confirmed that the code does not run from a standalone Java app -- I got the same exception. 

Avatar

Level 6

Thanks Sam and Jorg for your help!