authenticate to jcr Repository fails ? jaas ? - javax.jcr.AccessDeniedException: Access denied

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

authenticate to jcr Repository fails ? jaas ? - javax.jcr.AccessDeniedException: Access denied

Eugen Stan-2
Hello,

I've deployed an application inside Apache Karaf using a Sling feature 
[1]. I have also installed karaf commands that import some content in
JCR Repository.

The commands work well, except when having to write to JCR Repository.
That part fails to login/logout properly from the repository.

Oak inside Karaf uses jaas authentification and I think that is where it
fails but I don't how to make it work. Any ideas?

Regards,

Eugen 

----

JcrTemplateImpl                  | 303 - itembank-jcr - 1.22.0.SNAPSHOT
| Failed to save session
java.lang.RuntimeException: java.lang.RuntimeException:
javax.jcr.AccessDeniedException: Access denied.
    at
gr8pi.itembank.jcr.repo.ItemBankHelperImpl.getOrCreateTranslation(ItemBankHelperImpl.java:191)
~[303:itembank-jcr:1.22.0.SNAPSHOT]
    at
gr8pi.itembank.migrate.AssessmentToJcrMigrator.migrateAssessmentBehaviorSectionTranslation(AssessmentToJcrMigrator.java:668)
~[?:?]
    at
gr8pi.itembank.migrate.AssessmentToJcrMigrator.lambda$null$34(AssessmentToJcrMigrator.java:651)
~[?:?]
    at java.lang.Iterable.forEach(Iterable.java:75) ~[?:?]
    at
gr8pi.itembank.migrate.AssessmentToJcrMigrator.lambda$migrateAssessmentBehaviorSection$35(AssessmentToJcrMigrator.java:647)
~[?:?]
    at
gr8pi.itembank.jcr.repo.JcrTemplateImpl.doInSession(JcrTemplateImpl.java:58)
[303:itembank-jcr:1.22.0.SNAPSHOT]
    at
gr8pi.itembank.migrate.AssessmentToJcrMigrator.migrateAssessmentBehaviorSection(AssessmentToJcrMigrator.java:634)
[302:itembank-emf-jcr:1.22.0.SNAPSHOT]
    at
gr8pi.itembank.migrate.AssessmentToJcrMigrator.migrateAssessmentSections(AssessmentToJcrMigrator.java:626)
[302:itembank-emf-jcr:1.22.0.SNAPSHOT]
    at
gr8pi.itembank.migrate.AssessmentToJcrMigrator.migrate(AssessmentToJcrMigrator.java:619)
[302:itembank-emf-jcr:1.22.0.SNAPSHOT]
    at
gr8pi.itembank.migrate.EmfToJcrMigrator.migrate(EmfToJcrMigrator.java:44)
[302:itembank-emf-jcr:1.22.0.SNAPSHOT]
    at
gr8pi.itembank.jcr.karaf.commands.EmfToJcrCommand.execute(EmfToJcrCommand.java:52)
[312:shell-commands:1.22.0.SNAPSHOT]
    at
org.apache.karaf.shell.impl.action.command.ActionCommand.execute(ActionCommand.java:84)
[33:org.apache.karaf.shell.core:4.2.0]
    at
org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:68)
[33:org.apache.karaf.shell.core:4.2.0]
    at
org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:86)
[33:org.apache.karaf.shell.core:4.2.0]
    at
org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:571)
[33:org.apache.karaf.shell.core:4.2.0]
    at
org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:497)
[33:org.apache.karaf.shell.core:4.2.0]
    at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:386)
[33:org.apache.karaf.shell.core:4.2.0]
    at org.apache.felix.gogo.runtime.Pipe.doCall(Pipe.java:417)
[33:org.apache.karaf.shell.core:4.2.0]
    at org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:229)
[33:org.apache.karaf.shell.core:4.2.0]
    at org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:59)
[33:org.apache.karaf.shell.core:4.2.0]
    at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?]
    at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
[?:?]
    at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
[?:?]
    at java.lang.Thread.run(Thread.java:748) [?:?]
Caused by: java.lang.RuntimeException: javax.jcr.AccessDeniedException:
Access denied.
    at
gr8pi.itembank.jcr.repo.ItemBankHelperImpl.findTranslationNode(ItemBankHelperImpl.java:226)
~[?:?]
    at
gr8pi.itembank.jcr.repo.ItemBankHelperImpl.getOrCreateTranslation(ItemBankHelperImpl.java:163)
~[?:?]
    at
gr8pi.itembank.jcr.repo.ItemBankHelperImpl.getOrCreateTranslation(ItemBankHelperImpl.java:187)
~[?:?]
    ... 23 more
Caused by: javax.jcr.AccessDeniedException: Access denied.
    at
org.apache.jackrabbit.oak.jcr.security.AccessManager.checkPermissions(AccessManager.java:71)
~[?:?]
    at
org.apache.jackrabbit.oak.jcr.session.NodeImpl$5.perform(NodeImpl.java:296)
~[?:?]
    at
org.apache.jackrabbit.oak.jcr.session.NodeImpl$5.perform(NodeImpl.java:265)
~[?:?]
    at
org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate.perform(SessionDelegate.java:208)
~[?:?]
    at
org.apache.jackrabbit.oak.jcr.session.ItemImpl.perform(ItemImpl.java:112)
~[?:?]
    at
org.apache.jackrabbit.oak.jcr.session.NodeImpl.addNode(NodeImpl.java:265)
~[?:?]
    at
org.apache.jackrabbit.commons.JcrUtils.getOrAddNode(JcrUtils.java:955)
~[?:?]
    at
gr8pi.itembank.jcr.repo.ItemBankHelperImpl.findTranslationNode(ItemBankHelperImpl.java:219)
~[?:?]
    at
gr8pi.itembank.jcr.repo.ItemBankHelperImpl.getOrCreateTranslation(ItemBankHelperImpl.java:163)
~[?:?]
    at
gr8pi.itembank.jcr.repo.ItemBankHelperImpl.getOrCreateTranslation(ItemBankHelperImpl.java:187)
~[?:?]
    ... 23 more
----

My JcrTemplate class looks like this. As you can see I'm trying to login
with admin/admin credentials of the repository but it fails.

@Slf4j
@FieldDefaults(level = AccessLevel.PRIVATE)
@Data
@NoArgsConstructor
@AllArgsConstructor
@Component(
    immediate = true,
    property = {"user=admin", "password=admin"},
    service = {JcrTemplate.class, JcrSessionFactory.class})
public class JcrTemplateImpl implements JcrTemplate, JcrSessionFactory {

  @Reference Repository repository;

  Credentials credentials;

  @Activate
  public void activate(Map<String, Object> properties) {
    String user = (String) properties.getOrDefault("user", "admin");
    String pass = (String) properties.getOrDefault("password", "admin");

    credentials = new SimpleCredentials(user, pass.toCharArray());
  }

  /** Run code in session. Handles session save and closing. */
  @Override
  public <T> T doInSession(CheckedFunction<T> callback) {
    Session session = getSession();
    try {
      T result = callback.apply(session);
      if (session.hasPendingChanges()) {
        session.save();
      }
      return result;
    } catch (Exception e) {
      log.error("Failed to save session ", e);
      throw new RuntimeException(e);
    } finally {
      session.logout();
    }
  }

  @Override
  public Session getSession() {
    try {
      return repository.login(getCredentials());
    } catch (Exception e) {
      log.error("Failed to create JCR session {}", e);
      throw new RuntimeException(e);
    }
  }
}

NOTE: The feature at [1] is nearly identical to upstream sling feature
except: I'm using only releases - no snapshots. I've added capabilities
to make the app install and start in Karaf 4.2.0.

[1]
https://bintray.com/netdava/maven/download_file?file_path=org%2Fapache%2Fsling%2Forg.apache.sling.karaf-features%2F0.1.1-netdava7%2Forg.apache.sling.karaf-features-0.1.1-netdava7-features.xml



signature.asc (499 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

sling + oak mongo - error during logout

Eugen Stan-2
Hello again,

So it seems I was wrong and I can authenticate and write to the repository.

However the error still appears and I think the issue is a performance one.

I get "Error during logout" messages. I'm still not sure what is causing
this since we just started investigating this behavior.

This seems more Oak than Sling related but I am a bit confused.

It seems the issue appears when multiple nodes are created at once but
I'm not sure on the number. I think it is somewhere in the range of
20-50+ nodes / single session. 

Any insight is appreciated.

Regards,


```

   | 84 - org.apache.jackrabbit.oak-core - 1.8.6 | Error during logout.
javax.security.auth.login.LoginException: Login Failure: all modules ignored
    at
javax.security.auth.login.LoginContext.invoke(LoginContext.java:906) ~[?:?]
    at
javax.security.auth.login.LoginContext.access$000(LoginContext.java:195)
~[?:?]
    at
javax.security.auth.login.LoginContext$4.run(LoginContext.java:682) ~[?:?]
    at
javax.security.auth.login.LoginContext$4.run(LoginContext.java:680) ~[?:?]
    at java.security.AccessController.doPrivileged(Native Method) ~[?:?]
    at
javax.security.auth.login.LoginContext.invokePriv(LoginContext.java:680)
~[?:?]
    at
javax.security.auth.login.LoginContext.logout(LoginContext.java:628) ~[?:?]
    at
org.apache.jackrabbit.oak.core.ContentSessionImpl.close(ContentSessionImpl.java:114)
~[?:?]
    at
org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate.logout(SessionDelegate.java:402)
~[?:?]
    at
org.apache.jackrabbit.oak.jcr.repository.RepositoryImpl$1.logout(RepositoryImpl.java:322)
~[?:?]
    at
org.apache.jackrabbit.oak.jcr.session.SessionImpl$10.performVoid(SessionImpl.java:466)
~[?:?]
    at
org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate.performVoid(SessionDelegate.java:274)
~[?:?]
    at
org.apache.jackrabbit.oak.jcr.session.SessionImpl.logout(SessionImpl.java:462)
~[?:?]
    at
org.apache.sling.jcr.oak.server.internal.TcclWrappingJackrabbitSession.logout(TcclWrappingJackrabbitSession.java:304)
~[?:?]
    at
gr8pi.itembank.jcr.repo.JcrTemplateImpl.doInSession(JcrTemplateImpl.java:67)
~[?:?]
    at
gr8pi.itembank.migrate.AssessmentToJcrMigrator.migrateAssessmentItems(AssessmentToJcrMigrator.java:250)
~[?:?]
    at
gr8pi.itembank.migrate.AssessmentToJcrMigrator.migrateAssessmentDimension(AssessmentToJcrMigrator.java:418)
~[?:?]
    at
gr8pi.itembank.migrate.AssessmentToJcrMigrator.lambda$migrateAssessmentDimensions$29(AssessmentToJcrMigrator.java:505)
~[?:?]
    at java.util.ArrayList.forEach(ArrayList.java:1257) [?:?]
    at
gr8pi.itembank.migrate.AssessmentToJcrMigrator.migrateAssessmentDimensions(AssessmentToJcrMigrator.java:505)
[393:itembank-emf-jcr:1.22.0.SNAPSHOT]
    at
gr8pi.itembank.migrate.AssessmentToJcrMigrator.migrate(AssessmentToJcrMigrator.java:620)
[393:itembank-emf-jcr:1.22.0.SNAPSHOT]
    at
gr8pi.itembank.migrate.EmfToJcrMigrator.migrate(EmfToJcrMigrator.java:44)
[393:itembank-emf-jcr:1.22.0.SNAPSHOT]
    at
gr8pi.itembank.jcr.karaf.commands.EmfToJcrCommand.execute(EmfToJcrCommand.java:52)
[392:itembank-commands:1.22.0.SNAPSHOT]
    at
org.apache.karaf.shell.impl.action.command.ActionCommand.execute(ActionCommand.java:84)
[33:org.apache.karaf.shell.core:4.2.0]
    at
org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:68)
[33:org.apache.karaf.shell.core:4.2.0]
    at
org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:86)
[33:org.apache.karaf.shell.core:4.2.0]
    at
org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:571)
[33:org.apache.karaf.shell.core:4.2.0]
    at
org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:497)
[33:org.apache.karaf.shell.core:4.2.0]
    at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:386)
[33:org.apache.karaf.shell.core:4.2.0]
    at org.apache.felix.gogo.runtime.Pipe.doCall(Pipe.java:417)
[33:org.apache.karaf.shell.core:4.2.0]
    at org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:229)
[33:org.apache.karaf.shell.core:4.2.0]
    at org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:59)
[33:org.apache.karaf.shell.core:4.2.0]
    at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?]
    at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
[?:?]
    at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
[?:?]
    at java.lang.Thread.run(Thread.java:748) [?:?]

```


On 12.08.2018 13:53, Eugen Stan wrote:

> Hello,
>
> I've deployed an application inside Apache Karaf using a Sling feature 
> [1]. I have also installed karaf commands that import some content in
> JCR Repository.
>
> The commands work well, except when having to write to JCR Repository.
> That part fails to login/logout properly from the repository.
>
> Oak inside Karaf uses jaas authentification and I think that is where it
> fails but I don't how to make it work. Any ideas?
>
> Regards,
>
> Eugen 
>
> ----
>
> JcrTemplateImpl                  | 303 - itembank-jcr - 1.22.0.SNAPSHOT
> | Failed to save session
> java.lang.RuntimeException: java.lang.RuntimeException:
> javax.jcr.AccessDeniedException: Access denied.
>     at
> gr8pi.itembank.jcr.repo.ItemBankHelperImpl.getOrCreateTranslation(ItemBankHelperImpl.java:191)
> ~[303:itembank-jcr:1.22.0.SNAPSHOT]
>     at
> gr8pi.itembank.migrate.AssessmentToJcrMigrator.migrateAssessmentBehaviorSectionTranslation(AssessmentToJcrMigrator.java:668)
> ~[?:?]
>     at
> gr8pi.itembank.migrate.AssessmentToJcrMigrator.lambda$null$34(AssessmentToJcrMigrator.java:651)
> ~[?:?]
>     at java.lang.Iterable.forEach(Iterable.java:75) ~[?:?]
>     at
> gr8pi.itembank.migrate.AssessmentToJcrMigrator.lambda$migrateAssessmentBehaviorSection$35(AssessmentToJcrMigrator.java:647)
> ~[?:?]
>     at
> gr8pi.itembank.jcr.repo.JcrTemplateImpl.doInSession(JcrTemplateImpl.java:58)
> [303:itembank-jcr:1.22.0.SNAPSHOT]
>     at
> gr8pi.itembank.migrate.AssessmentToJcrMigrator.migrateAssessmentBehaviorSection(AssessmentToJcrMigrator.java:634)
> [302:itembank-emf-jcr:1.22.0.SNAPSHOT]
>     at
> gr8pi.itembank.migrate.AssessmentToJcrMigrator.migrateAssessmentSections(AssessmentToJcrMigrator.java:626)
> [302:itembank-emf-jcr:1.22.0.SNAPSHOT]
>     at
> gr8pi.itembank.migrate.AssessmentToJcrMigrator.migrate(AssessmentToJcrMigrator.java:619)
> [302:itembank-emf-jcr:1.22.0.SNAPSHOT]
>     at
> gr8pi.itembank.migrate.EmfToJcrMigrator.migrate(EmfToJcrMigrator.java:44)
> [302:itembank-emf-jcr:1.22.0.SNAPSHOT]
>     at
> gr8pi.itembank.jcr.karaf.commands.EmfToJcrCommand.execute(EmfToJcrCommand.java:52)
> [312:shell-commands:1.22.0.SNAPSHOT]
>     at
> org.apache.karaf.shell.impl.action.command.ActionCommand.execute(ActionCommand.java:84)
> [33:org.apache.karaf.shell.core:4.2.0]
>     at
> org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:68)
> [33:org.apache.karaf.shell.core:4.2.0]
>     at
> org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:86)
> [33:org.apache.karaf.shell.core:4.2.0]
>     at
> org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:571)
> [33:org.apache.karaf.shell.core:4.2.0]
>     at
> org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:497)
> [33:org.apache.karaf.shell.core:4.2.0]
>     at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:386)
> [33:org.apache.karaf.shell.core:4.2.0]
>     at org.apache.felix.gogo.runtime.Pipe.doCall(Pipe.java:417)
> [33:org.apache.karaf.shell.core:4.2.0]
>     at org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:229)
> [33:org.apache.karaf.shell.core:4.2.0]
>     at org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:59)
> [33:org.apache.karaf.shell.core:4.2.0]
>     at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?]
>     at
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
> [?:?]
>     at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
> [?:?]
>     at java.lang.Thread.run(Thread.java:748) [?:?]
> Caused by: java.lang.RuntimeException: javax.jcr.AccessDeniedException:
> Access denied.
>     at
> gr8pi.itembank.jcr.repo.ItemBankHelperImpl.findTranslationNode(ItemBankHelperImpl.java:226)
> ~[?:?]
>     at
> gr8pi.itembank.jcr.repo.ItemBankHelperImpl.getOrCreateTranslation(ItemBankHelperImpl.java:163)
> ~[?:?]
>     at
> gr8pi.itembank.jcr.repo.ItemBankHelperImpl.getOrCreateTranslation(ItemBankHelperImpl.java:187)
> ~[?:?]
>     ... 23 more
> Caused by: javax.jcr.AccessDeniedException: Access denied.
>     at
> org.apache.jackrabbit.oak.jcr.security.AccessManager.checkPermissions(AccessManager.java:71)
> ~[?:?]
>     at
> org.apache.jackrabbit.oak.jcr.session.NodeImpl$5.perform(NodeImpl.java:296)
> ~[?:?]
>     at
> org.apache.jackrabbit.oak.jcr.session.NodeImpl$5.perform(NodeImpl.java:265)
> ~[?:?]
>     at
> org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate.perform(SessionDelegate.java:208)
> ~[?:?]
>     at
> org.apache.jackrabbit.oak.jcr.session.ItemImpl.perform(ItemImpl.java:112)
> ~[?:?]
>     at
> org.apache.jackrabbit.oak.jcr.session.NodeImpl.addNode(NodeImpl.java:265)
> ~[?:?]
>     at
> org.apache.jackrabbit.commons.JcrUtils.getOrAddNode(JcrUtils.java:955)
> ~[?:?]
>     at
> gr8pi.itembank.jcr.repo.ItemBankHelperImpl.findTranslationNode(ItemBankHelperImpl.java:219)
> ~[?:?]
>     at
> gr8pi.itembank.jcr.repo.ItemBankHelperImpl.getOrCreateTranslation(ItemBankHelperImpl.java:163)
> ~[?:?]
>     at
> gr8pi.itembank.jcr.repo.ItemBankHelperImpl.getOrCreateTranslation(ItemBankHelperImpl.java:187)
> ~[?:?]
>     ... 23 more
> ----
>
> My JcrTemplate class looks like this. As you can see I'm trying to login
> with admin/admin credentials of the repository but it fails.
>
> @Slf4j
> @FieldDefaults(level = AccessLevel.PRIVATE)
> @Data
> @NoArgsConstructor
> @AllArgsConstructor
> @Component(
>     immediate = true,
>     property = {"user=admin", "password=admin"},
>     service = {JcrTemplate.class, JcrSessionFactory.class})
> public class JcrTemplateImpl implements JcrTemplate, JcrSessionFactory {
>
>   @Reference Repository repository;
>
>   Credentials credentials;
>
>   @Activate
>   public void activate(Map<String, Object> properties) {
>     String user = (String) properties.getOrDefault("user", "admin");
>     String pass = (String) properties.getOrDefault("password", "admin");
>
>     credentials = new SimpleCredentials(user, pass.toCharArray());
>   }
>
>   /** Run code in session. Handles session save and closing. */
>   @Override
>   public <T> T doInSession(CheckedFunction<T> callback) {
>     Session session = getSession();
>     try {
>       T result = callback.apply(session);
>       if (session.hasPendingChanges()) {
>         session.save();
>       }
>       return result;
>     } catch (Exception e) {
>       log.error("Failed to save session ", e);
>       throw new RuntimeException(e);
>     } finally {
>       session.logout();
>     }
>   }
>
>   @Override
>   public Session getSession() {
>     try {
>       return repository.login(getCredentials());
>     } catch (Exception e) {
>       log.error("Failed to create JCR session {}", e);
>       throw new RuntimeException(e);
>     }
>   }
> }
>
> NOTE: The feature at [1] is nearly identical to upstream sling feature
> except: I'm using only releases - no snapshots. I've added capabilities
> to make the app install and start in Karaf 4.2.0.
>
> [1]
> https://bintray.com/netdava/maven/download_file?file_path=org%2Fapache%2Fsling%2Forg.apache.sling.karaf-features%2F0.1.1-netdava7%2Forg.apache.sling.karaf-features-0.1.1-netdava7-features.xml
>
>


signature.asc (499 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: sling + oak mongo - error during logout

Robert Munteanu-2
Hi Eugen,

On Mon, 2018-08-13 at 05:39 +0300, Eugen Stan wrote:

> Hello again,
>
> So it seems I was wrong and I can authenticate and write to the
> repository.
>
> However the error still appears and I think the issue is a
> performance one.
>
> I get "Error during logout" messages. I'm still not sure what is
> causing
> this since we just started investigating this behavior.
>
> This seems more Oak than Sling related but I am a bit confused.
>
> It seems the issue appears when multiple nodes are created at once
> but
> I'm not sure on the number. I think it is somewhere in the range of
> 20-50+ nodes / single session.

Does this error only appear on logout and not on login? I would anyway
suggest that you apply debugging using the JAAS mechanisms ( which can
be a bit opaque - I remember for trying the last time ).

If you can get a reproducible test case it might be worth asking on the
oak-dev list.

Hope this helps,

Robert

>
> Any insight is appreciated.
>
> Regards,
>
>
> ```
>
>    | 84 - org.apache.jackrabbit.oak-core - 1.8.6 | Error during
> logout.
> javax.security.auth.login.LoginException: Login Failure: all modules
> ignored
>     at
> javax.security.auth.login.LoginContext.invoke(LoginContext.java:906)
> ~[?:?]
>     at
> javax.security.auth.login.LoginContext.access$000(LoginContext.java:1
> 95)
> ~[?:?]
>     at
> javax.security.auth.login.LoginContext$4.run(LoginContext.java:682)
> ~[?:?]
>     at
> javax.security.auth.login.LoginContext$4.run(LoginContext.java:680)
> ~[?:?]
>     at java.security.AccessController.doPrivileged(Native Method)
> ~[?:?]
>     at
> javax.security.auth.login.LoginContext.invokePriv(LoginContext.java:6
> 80)
> ~[?:?]
>     at
> javax.security.auth.login.LoginContext.logout(LoginContext.java:628)
> ~[?:?]
>     at
> org.apache.jackrabbit.oak.core.ContentSessionImpl.close(ContentSessio
> nImpl.java:114)
> ~[?:?]
>     at
> org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate.logout(Session
> Delegate.java:402)
> ~[?:?]
>     at
> org.apache.jackrabbit.oak.jcr.repository.RepositoryImpl$1.logout(Repo
> sitoryImpl.java:322)
> ~[?:?]
>     at
> org.apache.jackrabbit.oak.jcr.session.SessionImpl$10.performVoid(Sess
> ionImpl.java:466)
> ~[?:?]
>     at
> org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate.performVoid(Se
> ssionDelegate.java:274)
> ~[?:?]
>     at
> org.apache.jackrabbit.oak.jcr.session.SessionImpl.logout(SessionImpl.
> java:462)
> ~[?:?]
>     at
> org.apache.sling.jcr.oak.server.internal.TcclWrappingJackrabbitSessio
> n.logout(TcclWrappingJackrabbitSession.java:304)
> ~[?:?]
>     at
> gr8pi.itembank.jcr.repo.JcrTemplateImpl.doInSession(JcrTemplateImpl.j
> ava:67)
> ~[?:?]
>     at
> gr8pi.itembank.migrate.AssessmentToJcrMigrator.migrateAssessmentItems
> (AssessmentToJcrMigrator.java:250)
> ~[?:?]
>     at
> gr8pi.itembank.migrate.AssessmentToJcrMigrator.migrateAssessmentDimen
> sion(AssessmentToJcrMigrator.java:418)
> ~[?:?]
>     at
> gr8pi.itembank.migrate.AssessmentToJcrMigrator.lambda$migrateAssessme
> ntDimensions$29(AssessmentToJcrMigrator.java:505)
> ~[?:?]
>     at java.util.ArrayList.forEach(ArrayList.java:1257) [?:?]
>     at
> gr8pi.itembank.migrate.AssessmentToJcrMigrator.migrateAssessmentDimen
> sions(AssessmentToJcrMigrator.java:505)
> [393:itembank-emf-jcr:1.22.0.SNAPSHOT]
>     at
> gr8pi.itembank.migrate.AssessmentToJcrMigrator.migrate(AssessmentToJc
> rMigrator.java:620)
> [393:itembank-emf-jcr:1.22.0.SNAPSHOT]
>     at
> gr8pi.itembank.migrate.EmfToJcrMigrator.migrate(EmfToJcrMigrator.java
> :44)
> [393:itembank-emf-jcr:1.22.0.SNAPSHOT]
>     at
> gr8pi.itembank.jcr.karaf.commands.EmfToJcrCommand.execute(EmfToJcrCom
> mand.java:52)
> [392:itembank-commands:1.22.0.SNAPSHOT]
>     at
> org.apache.karaf.shell.impl.action.command.ActionCommand.execute(Acti
> onCommand.java:84)
> [33:org.apache.karaf.shell.core:4.2.0]
>     at
> org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execu
> te(SecuredCommand.java:68)
> [33:org.apache.karaf.shell.core:4.2.0]
>     at
> org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execu
> te(SecuredCommand.java:86)
> [33:org.apache.karaf.shell.core:4.2.0]
>     at
> org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:571)
> [33:org.apache.karaf.shell.core:4.2.0]
>     at
> org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:4
> 97)
> [33:org.apache.karaf.shell.core:4.2.0]
>     at
> org.apache.felix.gogo.runtime.Closure.execute(Closure.java:386)
> [33:org.apache.karaf.shell.core:4.2.0]
>     at org.apache.felix.gogo.runtime.Pipe.doCall(Pipe.java:417)
> [33:org.apache.karaf.shell.core:4.2.0]
>     at org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:229)
> [33:org.apache.karaf.shell.core:4.2.0]
>     at org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:59)
> [33:org.apache.karaf.shell.core:4.2.0]
>     at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?]
>     at
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.
> java:1149)
> [?:?]
>     at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor
> .java:624)
> [?:?]
>     at java.lang.Thread.run(Thread.java:748) [?:?]
>
> ```
>
>
> On 12.08.2018 13:53, Eugen Stan wrote:
> > Hello,
> >
> > I've deployed an application inside Apache Karaf using a Sling
> > feature
> > [1]. I have also installed karaf commands that import some content
> > in
> > JCR Repository.
> >
> > The commands work well, except when having to write to JCR
> > Repository.
> > That part fails to login/logout properly from the repository.
> >
> > Oak inside Karaf uses jaas authentification and I think that is
> > where it
> > fails but I don't how to make it work. Any ideas?
> >
> > Regards,
> >
> > Eugen
> >
> > ----
> >
> > JcrTemplateImpl                  | 303 - itembank-jcr -
> > 1.22.0.SNAPSHOT
> > > Failed to save session
> >
> > java.lang.RuntimeException: java.lang.RuntimeException:
> > javax.jcr.AccessDeniedException: Access denied.
> >     at
> > gr8pi.itembank.jcr.repo.ItemBankHelperImpl.getOrCreateTranslation(I
> > temBankHelperImpl.java:191)
> > ~[303:itembank-jcr:1.22.0.SNAPSHOT]
> >     at
> > gr8pi.itembank.migrate.AssessmentToJcrMigrator.migrateAssessmentBeh
> > aviorSectionTranslation(AssessmentToJcrMigrator.java:668)
> > ~[?:?]
> >     at
> > gr8pi.itembank.migrate.AssessmentToJcrMigrator.lambda$null$34(Asses
> > smentToJcrMigrator.java:651)
> > ~[?:?]
> >     at java.lang.Iterable.forEach(Iterable.java:75) ~[?:?]
> >     at
> > gr8pi.itembank.migrate.AssessmentToJcrMigrator.lambda$migrateAssess
> > mentBehaviorSection$35(AssessmentToJcrMigrator.java:647)
> > ~[?:?]
> >     at
> > gr8pi.itembank.jcr.repo.JcrTemplateImpl.doInSession(JcrTemplateImpl
> > .java:58)
> > [303:itembank-jcr:1.22.0.SNAPSHOT]
> >     at
> > gr8pi.itembank.migrate.AssessmentToJcrMigrator.migrateAssessmentBeh
> > aviorSection(AssessmentToJcrMigrator.java:634)
> > [302:itembank-emf-jcr:1.22.0.SNAPSHOT]
> >     at
> > gr8pi.itembank.migrate.AssessmentToJcrMigrator.migrateAssessmentSec
> > tions(AssessmentToJcrMigrator.java:626)
> > [302:itembank-emf-jcr:1.22.0.SNAPSHOT]
> >     at
> > gr8pi.itembank.migrate.AssessmentToJcrMigrator.migrate(AssessmentTo
> > JcrMigrator.java:619)
> > [302:itembank-emf-jcr:1.22.0.SNAPSHOT]
> >     at
> > gr8pi.itembank.migrate.EmfToJcrMigrator.migrate(EmfToJcrMigrator.ja
> > va:44)
> > [302:itembank-emf-jcr:1.22.0.SNAPSHOT]
> >     at
> > gr8pi.itembank.jcr.karaf.commands.EmfToJcrCommand.execute(EmfToJcrC
> > ommand.java:52)
> > [312:shell-commands:1.22.0.SNAPSHOT]
> >     at
> > org.apache.karaf.shell.impl.action.command.ActionCommand.execute(Ac
> > tionCommand.java:84)
> > [33:org.apache.karaf.shell.core:4.2.0]
> >     at
> > org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.exe
> > cute(SecuredCommand.java:68)
> > [33:org.apache.karaf.shell.core:4.2.0]
> >     at
> > org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.exe
> > cute(SecuredCommand.java:86)
> > [33:org.apache.karaf.shell.core:4.2.0]
> >     at
> > org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:571)
> > [33:org.apache.karaf.shell.core:4.2.0]
> >     at
> > org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java
> > :497)
> > [33:org.apache.karaf.shell.core:4.2.0]
> >     at
> > org.apache.felix.gogo.runtime.Closure.execute(Closure.java:386)
> > [33:org.apache.karaf.shell.core:4.2.0]
> >     at org.apache.felix.gogo.runtime.Pipe.doCall(Pipe.java:417)
> > [33:org.apache.karaf.shell.core:4.2.0]
> >     at org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:229)
> > [33:org.apache.karaf.shell.core:4.2.0]
> >     at org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:59)
> > [33:org.apache.karaf.shell.core:4.2.0]
> >     at java.util.concurrent.FutureTask.run(FutureTask.java:266)
> > [?:?]
> >     at
> > java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecuto
> > r.java:1149)
> > [?:?]
> >     at
> > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecut
> > or.java:624)
> > [?:?]
> >     at java.lang.Thread.run(Thread.java:748) [?:?]
> > Caused by: java.lang.RuntimeException:
> > javax.jcr.AccessDeniedException:
> > Access denied.
> >     at
> > gr8pi.itembank.jcr.repo.ItemBankHelperImpl.findTranslationNode(Item
> > BankHelperImpl.java:226)
> > ~[?:?]
> >     at
> > gr8pi.itembank.jcr.repo.ItemBankHelperImpl.getOrCreateTranslation(I
> > temBankHelperImpl.java:163)
> > ~[?:?]
> >     at
> > gr8pi.itembank.jcr.repo.ItemBankHelperImpl.getOrCreateTranslation(I
> > temBankHelperImpl.java:187)
> > ~[?:?]
> >     ... 23 more
> > Caused by: javax.jcr.AccessDeniedException: Access denied.
> >     at
> > org.apache.jackrabbit.oak.jcr.security.AccessManager.checkPermissio
> > ns(AccessManager.java:71)
> > ~[?:?]
> >     at
> > org.apache.jackrabbit.oak.jcr.session.NodeImpl$5.perform(NodeImpl.j
> > ava:296)
> > ~[?:?]
> >     at
> > org.apache.jackrabbit.oak.jcr.session.NodeImpl$5.perform(NodeImpl.j
> > ava:265)
> > ~[?:?]
> >     at
> > org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate.perform(Sess
> > ionDelegate.java:208)
> > ~[?:?]
> >     at
> > org.apache.jackrabbit.oak.jcr.session.ItemImpl.perform(ItemImpl.jav
> > a:112)
> > ~[?:?]
> >     at
> > org.apache.jackrabbit.oak.jcr.session.NodeImpl.addNode(NodeImpl.jav
> > a:265)
> > ~[?:?]
> >     at
> > org.apache.jackrabbit.commons.JcrUtils.getOrAddNode(JcrUtils.java:9
> > 55)
> > ~[?:?]
> >     at
> > gr8pi.itembank.jcr.repo.ItemBankHelperImpl.findTranslationNode(Item
> > BankHelperImpl.java:219)
> > ~[?:?]
> >     at
> > gr8pi.itembank.jcr.repo.ItemBankHelperImpl.getOrCreateTranslation(I
> > temBankHelperImpl.java:163)
> > ~[?:?]
> >     at
> > gr8pi.itembank.jcr.repo.ItemBankHelperImpl.getOrCreateTranslation(I
> > temBankHelperImpl.java:187)
> > ~[?:?]
> >     ... 23 more
> > ----
> >
> > My JcrTemplate class looks like this. As you can see I'm trying to
> > login
> > with admin/admin credentials of the repository but it fails.
> >
> > @Slf4j
> > @FieldDefaults(level = AccessLevel.PRIVATE)
> > @Data
> > @NoArgsConstructor
> > @AllArgsConstructor
> > @Component(
> >     immediate = true,
> >     property = {"user=admin", "password=admin"},
> >     service = {JcrTemplate.class, JcrSessionFactory.class})
> > public class JcrTemplateImpl implements JcrTemplate,
> > JcrSessionFactory {
> >
> >   @Reference Repository repository;
> >
> >   Credentials credentials;
> >
> >   @Activate
> >   public void activate(Map<String, Object> properties) {
> >     String user = (String) properties.getOrDefault("user",
> > "admin");
> >     String pass = (String) properties.getOrDefault("password",
> > "admin");
> >
> >     credentials = new SimpleCredentials(user, pass.toCharArray());
> >   }
> >
> >   /** Run code in session. Handles session save and closing. */
> >   @Override
> >   public <T> T doInSession(CheckedFunction<T> callback) {
> >     Session session = getSession();
> >     try {
> >       T result = callback.apply(session);
> >       if (session.hasPendingChanges()) {
> >         session.save();
> >       }
> >       return result;
> >     } catch (Exception e) {
> >       log.error("Failed to save session ", e);
> >       throw new RuntimeException(e);
> >     } finally {
> >       session.logout();
> >     }
> >   }
> >
> >   @Override
> >   public Session getSession() {
> >     try {
> >       return repository.login(getCredentials());
> >     } catch (Exception e) {
> >       log.error("Failed to create JCR session {}", e);
> >       throw new RuntimeException(e);
> >     }
> >   }
> > }
> >
> > NOTE: The feature at [1] is nearly identical to upstream sling
> > feature
> > except: I'm using only releases - no snapshots. I've added
> > capabilities
> > to make the app install and start in Karaf 4.2.0.
> >
> > [1]
> >
https://bintray.com/netdava/maven/download_file?file_path=org%2Fapache%2Fsling%2Forg.apache.sling.karaf-features%2F0.1.1-netdava7%2Forg.apache.sling.karaf-features-0.1.1-netdava7-features.xml
> >
> >
>
>


Reply | Threaded
Open this post in threaded view
|

Re: sling + oak mongo - error during logout

Eugen Stan-2
Hello,

It seems the error disappeared after we refactored our code to create
just a handfull of nodes + properties.

I think if you create lots of nodes in one session and try to persist
you get those errors -> if you reach the memory limit.

So to us this got fixed in our code. Don't know the underlying issue :( .

Regards,

On 8/13/18 6:15 PM, Robert Munteanu wrote:

> Hi Eugen,
>
> On Mon, 2018-08-13 at 05:39 +0300, Eugen Stan wrote:
>> Hello again,
>>
>> So it seems I was wrong and I can authenticate and write to the
>> repository.
>>
>> However the error still appears and I think the issue is a
>> performance one.
>>
>> I get "Error during logout" messages. I'm still not sure what is
>> causing
>> this since we just started investigating this behavior.
>>
>> This seems more Oak than Sling related but I am a bit confused.
>>
>> It seems the issue appears when multiple nodes are created at once
>> but
>> I'm not sure on the number. I think it is somewhere in the range of
>> 20-50+ nodes / single session.
> Does this error only appear on logout and not on login? I would anyway
> suggest that you apply debugging using the JAAS mechanisms ( which can
> be a bit opaque - I remember for trying the last time ).
>
> If you can get a reproducible test case it might be worth asking on the
> oak-dev list.
>
> Hope this helps,
>
> Robert
>
>> Any insight is appreciated.
>>
>> Regards,
>>
>>
>> ```
>>
>>    | 84 - org.apache.jackrabbit.oak-core - 1.8.6 | Error during
>> logout.
>> javax.security.auth.login.LoginException: Login Failure: all modules
>> ignored
>>     at
>> javax.security.auth.login.LoginContext.invoke(LoginContext.java:906)
>> ~[?:?]
>>     at
>> javax.security.auth.login.LoginContext.access$000(LoginContext.java:1
>> 95)
>> ~[?:?]
>>     at
>> javax.security.auth.login.LoginContext$4.run(LoginContext.java:682)
>> ~[?:?]
>>     at
>> javax.security.auth.login.LoginContext$4.run(LoginContext.java:680)
>> ~[?:?]
>>     at java.security.AccessController.doPrivileged(Native Method)
>> ~[?:?]
>>     at
>> javax.security.auth.login.LoginContext.invokePriv(LoginContext.java:6
>> 80)
>> ~[?:?]
>>     at
>> javax.security.auth.login.LoginContext.logout(LoginContext.java:628)
>> ~[?:?]
>>     at
>> org.apache.jackrabbit.oak.core.ContentSessionImpl.close(ContentSessio
>> nImpl.java:114)
>> ~[?:?]
>>     at
>> org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate.logout(Session
>> Delegate.java:402)
>> ~[?:?]
>>     at
>> org.apache.jackrabbit.oak.jcr.repository.RepositoryImpl$1.logout(Repo
>> sitoryImpl.java:322)
>> ~[?:?]
>>     at
>> org.apache.jackrabbit.oak.jcr.session.SessionImpl$10.performVoid(Sess
>> ionImpl.java:466)
>> ~[?:?]
>>     at
>> org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate.performVoid(Se
>> ssionDelegate.java:274)
>> ~[?:?]
>>     at
>> org.apache.jackrabbit.oak.jcr.session.SessionImpl.logout(SessionImpl.
>> java:462)
>> ~[?:?]
>>     at
>> org.apache.sling.jcr.oak.server.internal.TcclWrappingJackrabbitSessio
>> n.logout(TcclWrappingJackrabbitSession.java:304)
>> ~[?:?]
>>     at
>> gr8pi.itembank.jcr.repo.JcrTemplateImpl.doInSession(JcrTemplateImpl.j
>> ava:67)
>> ~[?:?]
>>     at
>> gr8pi.itembank.migrate.AssessmentToJcrMigrator.migrateAssessmentItems
>> (AssessmentToJcrMigrator.java:250)
>> ~[?:?]
>>     at
>> gr8pi.itembank.migrate.AssessmentToJcrMigrator.migrateAssessmentDimen
>> sion(AssessmentToJcrMigrator.java:418)
>> ~[?:?]
>>     at
>> gr8pi.itembank.migrate.AssessmentToJcrMigrator.lambda$migrateAssessme
>> ntDimensions$29(AssessmentToJcrMigrator.java:505)
>> ~[?:?]
>>     at java.util.ArrayList.forEach(ArrayList.java:1257) [?:?]
>>     at
>> gr8pi.itembank.migrate.AssessmentToJcrMigrator.migrateAssessmentDimen
>> sions(AssessmentToJcrMigrator.java:505)
>> [393:itembank-emf-jcr:1.22.0.SNAPSHOT]
>>     at
>> gr8pi.itembank.migrate.AssessmentToJcrMigrator.migrate(AssessmentToJc
>> rMigrator.java:620)
>> [393:itembank-emf-jcr:1.22.0.SNAPSHOT]
>>     at
>> gr8pi.itembank.migrate.EmfToJcrMigrator.migrate(EmfToJcrMigrator.java
>> :44)
>> [393:itembank-emf-jcr:1.22.0.SNAPSHOT]
>>     at
>> gr8pi.itembank.jcr.karaf.commands.EmfToJcrCommand.execute(EmfToJcrCom
>> mand.java:52)
>> [392:itembank-commands:1.22.0.SNAPSHOT]
>>     at
>> org.apache.karaf.shell.impl.action.command.ActionCommand.execute(Acti
>> onCommand.java:84)
>> [33:org.apache.karaf.shell.core:4.2.0]
>>     at
>> org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execu
>> te(SecuredCommand.java:68)
>> [33:org.apache.karaf.shell.core:4.2.0]
>>     at
>> org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execu
>> te(SecuredCommand.java:86)
>> [33:org.apache.karaf.shell.core:4.2.0]
>>     at
>> org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:571)
>> [33:org.apache.karaf.shell.core:4.2.0]
>>     at
>> org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:4
>> 97)
>> [33:org.apache.karaf.shell.core:4.2.0]
>>     at
>> org.apache.felix.gogo.runtime.Closure.execute(Closure.java:386)
>> [33:org.apache.karaf.shell.core:4.2.0]
>>     at org.apache.felix.gogo.runtime.Pipe.doCall(Pipe.java:417)
>> [33:org.apache.karaf.shell.core:4.2.0]
>>     at org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:229)
>> [33:org.apache.karaf.shell.core:4.2.0]
>>     at org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:59)
>> [33:org.apache.karaf.shell.core:4.2.0]
>>     at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?]
>>     at
>> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.
>> java:1149)
>> [?:?]
>>     at
>> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor
>> .java:624)
>> [?:?]
>>     at java.lang.Thread.run(Thread.java:748) [?:?]
>>
>> ```
>>
>>
>> On 12.08.2018 13:53, Eugen Stan wrote:
>>> Hello,
>>>
>>> I've deployed an application inside Apache Karaf using a Sling
>>> feature
>>> [1]. I have also installed karaf commands that import some content
>>> in
>>> JCR Repository.
>>>
>>> The commands work well, except when having to write to JCR
>>> Repository.
>>> That part fails to login/logout properly from the repository.
>>>
>>> Oak inside Karaf uses jaas authentification and I think that is
>>> where it
>>> fails but I don't how to make it work. Any ideas?
>>>
>>> Regards,
>>>
>>> Eugen
>>>
>>> ----
>>>
>>> JcrTemplateImpl                  | 303 - itembank-jcr -
>>> 1.22.0.SNAPSHOT
>>>> Failed to save session
>>> java.lang.RuntimeException: java.lang.RuntimeException:
>>> javax.jcr.AccessDeniedException: Access denied.
>>>     at
>>> gr8pi.itembank.jcr.repo.ItemBankHelperImpl.getOrCreateTranslation(I
>>> temBankHelperImpl.java:191)
>>> ~[303:itembank-jcr:1.22.0.SNAPSHOT]
>>>     at
>>> gr8pi.itembank.migrate.AssessmentToJcrMigrator.migrateAssessmentBeh
>>> aviorSectionTranslation(AssessmentToJcrMigrator.java:668)
>>> ~[?:?]
>>>     at
>>> gr8pi.itembank.migrate.AssessmentToJcrMigrator.lambda$null$34(Asses
>>> smentToJcrMigrator.java:651)
>>> ~[?:?]
>>>     at java.lang.Iterable.forEach(Iterable.java:75) ~[?:?]
>>>     at
>>> gr8pi.itembank.migrate.AssessmentToJcrMigrator.lambda$migrateAssess
>>> mentBehaviorSection$35(AssessmentToJcrMigrator.java:647)
>>> ~[?:?]
>>>     at
>>> gr8pi.itembank.jcr.repo.JcrTemplateImpl.doInSession(JcrTemplateImpl
>>> .java:58)
>>> [303:itembank-jcr:1.22.0.SNAPSHOT]
>>>     at
>>> gr8pi.itembank.migrate.AssessmentToJcrMigrator.migrateAssessmentBeh
>>> aviorSection(AssessmentToJcrMigrator.java:634)
>>> [302:itembank-emf-jcr:1.22.0.SNAPSHOT]
>>>     at
>>> gr8pi.itembank.migrate.AssessmentToJcrMigrator.migrateAssessmentSec
>>> tions(AssessmentToJcrMigrator.java:626)
>>> [302:itembank-emf-jcr:1.22.0.SNAPSHOT]
>>>     at
>>> gr8pi.itembank.migrate.AssessmentToJcrMigrator.migrate(AssessmentTo
>>> JcrMigrator.java:619)
>>> [302:itembank-emf-jcr:1.22.0.SNAPSHOT]
>>>     at
>>> gr8pi.itembank.migrate.EmfToJcrMigrator.migrate(EmfToJcrMigrator.ja
>>> va:44)
>>> [302:itembank-emf-jcr:1.22.0.SNAPSHOT]
>>>     at
>>> gr8pi.itembank.jcr.karaf.commands.EmfToJcrCommand.execute(EmfToJcrC
>>> ommand.java:52)
>>> [312:shell-commands:1.22.0.SNAPSHOT]
>>>     at
>>> org.apache.karaf.shell.impl.action.command.ActionCommand.execute(Ac
>>> tionCommand.java:84)
>>> [33:org.apache.karaf.shell.core:4.2.0]
>>>     at
>>> org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.exe
>>> cute(SecuredCommand.java:68)
>>> [33:org.apache.karaf.shell.core:4.2.0]
>>>     at
>>> org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.exe
>>> cute(SecuredCommand.java:86)
>>> [33:org.apache.karaf.shell.core:4.2.0]
>>>     at
>>> org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:571)
>>> [33:org.apache.karaf.shell.core:4.2.0]
>>>     at
>>> org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java
>>> :497)
>>> [33:org.apache.karaf.shell.core:4.2.0]
>>>     at
>>> org.apache.felix.gogo.runtime.Closure.execute(Closure.java:386)
>>> [33:org.apache.karaf.shell.core:4.2.0]
>>>     at org.apache.felix.gogo.runtime.Pipe.doCall(Pipe.java:417)
>>> [33:org.apache.karaf.shell.core:4.2.0]
>>>     at org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:229)
>>> [33:org.apache.karaf.shell.core:4.2.0]
>>>     at org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:59)
>>> [33:org.apache.karaf.shell.core:4.2.0]
>>>     at java.util.concurrent.FutureTask.run(FutureTask.java:266)
>>> [?:?]
>>>     at
>>> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecuto
>>> r.java:1149)
>>> [?:?]
>>>     at
>>> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecut
>>> or.java:624)
>>> [?:?]
>>>     at java.lang.Thread.run(Thread.java:748) [?:?]
>>> Caused by: java.lang.RuntimeException:
>>> javax.jcr.AccessDeniedException:
>>> Access denied.
>>>     at
>>> gr8pi.itembank.jcr.repo.ItemBankHelperImpl.findTranslationNode(Item
>>> BankHelperImpl.java:226)
>>> ~[?:?]
>>>     at
>>> gr8pi.itembank.jcr.repo.ItemBankHelperImpl.getOrCreateTranslation(I
>>> temBankHelperImpl.java:163)
>>> ~[?:?]
>>>     at
>>> gr8pi.itembank.jcr.repo.ItemBankHelperImpl.getOrCreateTranslation(I
>>> temBankHelperImpl.java:187)
>>> ~[?:?]
>>>     ... 23 more
>>> Caused by: javax.jcr.AccessDeniedException: Access denied.
>>>     at
>>> org.apache.jackrabbit.oak.jcr.security.AccessManager.checkPermissio
>>> ns(AccessManager.java:71)
>>> ~[?:?]
>>>     at
>>> org.apache.jackrabbit.oak.jcr.session.NodeImpl$5.perform(NodeImpl.j
>>> ava:296)
>>> ~[?:?]
>>>     at
>>> org.apache.jackrabbit.oak.jcr.session.NodeImpl$5.perform(NodeImpl.j
>>> ava:265)
>>> ~[?:?]
>>>     at
>>> org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate.perform(Sess
>>> ionDelegate.java:208)
>>> ~[?:?]
>>>     at
>>> org.apache.jackrabbit.oak.jcr.session.ItemImpl.perform(ItemImpl.jav
>>> a:112)
>>> ~[?:?]
>>>     at
>>> org.apache.jackrabbit.oak.jcr.session.NodeImpl.addNode(NodeImpl.jav
>>> a:265)
>>> ~[?:?]
>>>     at
>>> org.apache.jackrabbit.commons.JcrUtils.getOrAddNode(JcrUtils.java:9
>>> 55)
>>> ~[?:?]
>>>     at
>>> gr8pi.itembank.jcr.repo.ItemBankHelperImpl.findTranslationNode(Item
>>> BankHelperImpl.java:219)
>>> ~[?:?]
>>>     at
>>> gr8pi.itembank.jcr.repo.ItemBankHelperImpl.getOrCreateTranslation(I
>>> temBankHelperImpl.java:163)
>>> ~[?:?]
>>>     at
>>> gr8pi.itembank.jcr.repo.ItemBankHelperImpl.getOrCreateTranslation(I
>>> temBankHelperImpl.java:187)
>>> ~[?:?]
>>>     ... 23 more
>>> ----
>>>
>>> My JcrTemplate class looks like this. As you can see I'm trying to
>>> login
>>> with admin/admin credentials of the repository but it fails.
>>>
>>> @Slf4j
>>> @FieldDefaults(level = AccessLevel.PRIVATE)
>>> @Data
>>> @NoArgsConstructor
>>> @AllArgsConstructor
>>> @Component(
>>>     immediate = true,
>>>     property = {"user=admin", "password=admin"},
>>>     service = {JcrTemplate.class, JcrSessionFactory.class})
>>> public class JcrTemplateImpl implements JcrTemplate,
>>> JcrSessionFactory {
>>>
>>>   @Reference Repository repository;
>>>
>>>   Credentials credentials;
>>>
>>>   @Activate
>>>   public void activate(Map<String, Object> properties) {
>>>     String user = (String) properties.getOrDefault("user",
>>> "admin");
>>>     String pass = (String) properties.getOrDefault("password",
>>> "admin");
>>>
>>>     credentials = new SimpleCredentials(user, pass.toCharArray());
>>>   }
>>>
>>>   /** Run code in session. Handles session save and closing. */
>>>   @Override
>>>   public <T> T doInSession(CheckedFunction<T> callback) {
>>>     Session session = getSession();
>>>     try {
>>>       T result = callback.apply(session);
>>>       if (session.hasPendingChanges()) {
>>>         session.save();
>>>       }
>>>       return result;
>>>     } catch (Exception e) {
>>>       log.error("Failed to save session ", e);
>>>       throw new RuntimeException(e);
>>>     } finally {
>>>       session.logout();
>>>     }
>>>   }
>>>
>>>   @Override
>>>   public Session getSession() {
>>>     try {
>>>       return repository.login(getCredentials());
>>>     } catch (Exception e) {
>>>       log.error("Failed to create JCR session {}", e);
>>>       throw new RuntimeException(e);
>>>     }
>>>   }
>>> }
>>>
>>> NOTE: The feature at [1] is nearly identical to upstream sling
>>> feature
>>> except: I'm using only releases - no snapshots. I've added
>>> capabilities
>>> to make the app install and start in Karaf 4.2.0.
>>>
>>> [1]
>>>
> https://bintray.com/netdava/maven/download_file?file_path=org%2Fapache%2Fsling%2Forg.apache.sling.karaf-features%2F0.1.1-netdava7%2Forg.apache.sling.karaf-features-0.1.1-netdava7-features.xml
>>>
>>
>


signature.asc (499 bytes) Download Attachment