org.springframework.transaction.CannotCreateTransactionException: Could not open JCR session for transaction; nested exception is java.lang.IllegalStateException: StandaloneSession.ERROR_0001 - !StandaloneSession.ERROR_0001_ACCESSING_DESTROYED_SESSION!

Pentaho BI Platform Tracking | Tatsiana Kasiankova | 3 years ago
tip
Your exception is missing from the Samebug knowledge base.
Here are the best solutions we found on the Internet.
Click on the to mark the helpful solution and get rewards for you help.
  1. 0

    During investigation of the issue http://jira.pentaho.com/browse/PDI-10665 I faced up with the one more issue in AutoDoc.processRow() method. We are trying to load repository directory tree: ------------------------------------------------------------------------------------------------ data.repository = getTrans().getRepository(); if ( data.repository != null ) { data.tree = data.repository.loadRepositoryDirectoryTree(); } ------------------------------------------------------------------------------------------------ And as result there is an attempt to call StandaloneSession.getAttribute(StandaloneSession.java:75) for already destroyed session. See log below: org.springframework.transaction.CannotCreateTransactionException: Could not open JCR session for transaction; nested exception is java.lang.IllegalStateException: StandaloneSession.ERROR_0001 - !StandaloneSession.ERROR_0001_ACCESSING_DESTROYED_SESSION! at org.springframework.extensions.jcr.jackrabbit.LocalTransactionManager.doBegin(LocalTransactionManager.java:160) at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:374) at org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:263) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:101) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204) at com.sun.proxy.$Proxy28.getTree(Unknown Source) at org.pentaho.platform.repository2.unified.ExceptionLoggingDecorator$41.call(ExceptionLoggingDecorator.java:445) at org.pentaho.platform.repository2.unified.ExceptionLoggingDecorator$41.call(ExceptionLoggingDecorator.java:443) at org.pentaho.platform.repository2.unified.ExceptionLoggingDecorator.callLogThrow(ExceptionLoggingDecorator.java:489) at org.pentaho.platform.repository2.unified.ExceptionLoggingDecorator.getTree(ExceptionLoggingDecorator.java:443) at org.pentaho.platform.repository2.unified.ExceptionLoggingDecorator.getTree(ExceptionLoggingDecorator.java:454) at org.pentaho.di.repository.pur.PurRepository.loadRepositoryFileTree(PurRepository.java:520) at org.pentaho.di.repository.pur.PurRepository.loadRepositoryDirectoryTree(PurRepository.java:528) at org.pentaho.di.trans.steps.autodoc.AutoDoc.processRow(AutoDoc.java:163) at org.pentaho.di.trans.step.RunThread.run(RunThread.java:62) at java.lang.Thread.run(Thread.java:744) Caused by: java.lang.IllegalStateException: StandaloneSession.ERROR_0001 - !StandaloneSession.ERROR_0001_ACCESSING_DESTROYED_SESSION! at org.pentaho.platform.engine.core.system.StandaloneSession.getAttribute(StandaloneSession.java:75) at org.pentaho.platform.repository2.unified.jcr.JcrTenantUtils.getTenantedUser(JcrTenantUtils.java:96) at org.pentaho.platform.repository2.unified.jcr.sejcr.PentahoSessionCredentialsStrategy.getUserId(PentahoSessionCredentialsStrategy.java:74) at org.pentaho.platform.repository2.unified.jcr.sejcr.PentahoSessionCredentialsStrategy.getCredentials(PentahoSessionCredentialsStrategy.java:65) at org.pentaho.platform.repository2.unified.jcr.sejcr.CredentialsStrategySessionFactory.getSession(CredentialsStrategySessionFactory.java:337) at org.springframework.extensions.jcr.jackrabbit.LocalTransactionManager.doBegin(LocalTransactionManager.java:120) ... 16 more This occurs because in StartExecutionTransAsUserServlet we switch PentahoHttpSession to a Standalone Session: ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- public void transStarted(Trans trans) throws KettleException { // Switches my PentahoHttpSession to a Standalone Session if (log.isDebug()) { log.logDebug(BaseMessages.getString(SUBCLASS_PKG, "StartExecutionTransAsUserServlet.Log.CallbackReceived")); } SecurityHelper.getInstance().becomeUser(PentahoSessionHolder.getSession().getName()); } ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- So now we have UserSession in PentahoSessionStore and in HttpSessionPentahoSessionIntegrationFilter we destroy this one: // Crucial removal of PentahoSessionHolder contents - do this before anything else. PentahoSessionHolder.removeSession(); At the same time the steps of our transformation are executing in several separate threads and when one of them (in this case it AutoDoc ) is trying to load DI repository tree, on jackrabbit level there is attempt to work with this destroyed UserSession. As result - ava.lang.IllegalStateException: StandaloneSession.ERROR_0001 - !StandaloneSession.ERROR_0001_ACCESSING_DESTROYED_SESSION! The steps to reproduce are the same as in http://jira.pentaho.com/browse/PDI-10665

    Pentaho BI Platform Tracking | 3 years ago | Tatsiana Kasiankova
    org.springframework.transaction.CannotCreateTransactionException: Could not open JCR session for transaction; nested exception is java.lang.IllegalStateException: StandaloneSession.ERROR_0001 - !StandaloneSession.ERROR_0001_ACCESSING_DESTROYED_SESSION!
  2. 0

    During investigation of the issue http://jira.pentaho.com/browse/PDI-10665 I faced up with the one more issue in AutoDoc.processRow() method. We are trying to load repository directory tree: ------------------------------------------------------------------------------------------------ data.repository = getTrans().getRepository(); if ( data.repository != null ) { data.tree = data.repository.loadRepositoryDirectoryTree(); } ------------------------------------------------------------------------------------------------ And as result there is an attempt to call StandaloneSession.getAttribute(StandaloneSession.java:75) for already destroyed session. See log below: org.springframework.transaction.CannotCreateTransactionException: Could not open JCR session for transaction; nested exception is java.lang.IllegalStateException: StandaloneSession.ERROR_0001 - !StandaloneSession.ERROR_0001_ACCESSING_DESTROYED_SESSION! at org.springframework.extensions.jcr.jackrabbit.LocalTransactionManager.doBegin(LocalTransactionManager.java:160) at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:374) at org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:263) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:101) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204) at com.sun.proxy.$Proxy28.getTree(Unknown Source) at org.pentaho.platform.repository2.unified.ExceptionLoggingDecorator$41.call(ExceptionLoggingDecorator.java:445) at org.pentaho.platform.repository2.unified.ExceptionLoggingDecorator$41.call(ExceptionLoggingDecorator.java:443) at org.pentaho.platform.repository2.unified.ExceptionLoggingDecorator.callLogThrow(ExceptionLoggingDecorator.java:489) at org.pentaho.platform.repository2.unified.ExceptionLoggingDecorator.getTree(ExceptionLoggingDecorator.java:443) at org.pentaho.platform.repository2.unified.ExceptionLoggingDecorator.getTree(ExceptionLoggingDecorator.java:454) at org.pentaho.di.repository.pur.PurRepository.loadRepositoryFileTree(PurRepository.java:520) at org.pentaho.di.repository.pur.PurRepository.loadRepositoryDirectoryTree(PurRepository.java:528) at org.pentaho.di.trans.steps.autodoc.AutoDoc.processRow(AutoDoc.java:163) at org.pentaho.di.trans.step.RunThread.run(RunThread.java:62) at java.lang.Thread.run(Thread.java:744) Caused by: java.lang.IllegalStateException: StandaloneSession.ERROR_0001 - !StandaloneSession.ERROR_0001_ACCESSING_DESTROYED_SESSION! at org.pentaho.platform.engine.core.system.StandaloneSession.getAttribute(StandaloneSession.java:75) at org.pentaho.platform.repository2.unified.jcr.JcrTenantUtils.getTenantedUser(JcrTenantUtils.java:96) at org.pentaho.platform.repository2.unified.jcr.sejcr.PentahoSessionCredentialsStrategy.getUserId(PentahoSessionCredentialsStrategy.java:74) at org.pentaho.platform.repository2.unified.jcr.sejcr.PentahoSessionCredentialsStrategy.getCredentials(PentahoSessionCredentialsStrategy.java:65) at org.pentaho.platform.repository2.unified.jcr.sejcr.CredentialsStrategySessionFactory.getSession(CredentialsStrategySessionFactory.java:337) at org.springframework.extensions.jcr.jackrabbit.LocalTransactionManager.doBegin(LocalTransactionManager.java:120) ... 16 more This occurs because in StartExecutionTransAsUserServlet we switch PentahoHttpSession to a Standalone Session: ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- public void transStarted(Trans trans) throws KettleException { // Switches my PentahoHttpSession to a Standalone Session if (log.isDebug()) { log.logDebug(BaseMessages.getString(SUBCLASS_PKG, "StartExecutionTransAsUserServlet.Log.CallbackReceived")); } SecurityHelper.getInstance().becomeUser(PentahoSessionHolder.getSession().getName()); } ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- So now we have UserSession in PentahoSessionStore and in HttpSessionPentahoSessionIntegrationFilter we destroy this one: // Crucial removal of PentahoSessionHolder contents - do this before anything else. PentahoSessionHolder.removeSession(); At the same time the steps of our transformation are executing in several separate threads and when one of them (in this case it AutoDoc ) is trying to load DI repository tree, on jackrabbit level there is attempt to work with this destroyed UserSession. As result - ava.lang.IllegalStateException: StandaloneSession.ERROR_0001 - !StandaloneSession.ERROR_0001_ACCESSING_DESTROYED_SESSION! The steps to reproduce are the same as in http://jira.pentaho.com/browse/PDI-10665

    Pentaho BI Platform Tracking | 3 years ago | Tatsiana Kasiankova
    org.springframework.transaction.CannotCreateTransactionException: Could not open JCR session for transaction; nested exception is java.lang.IllegalStateException: StandaloneSession.ERROR_0001 - !StandaloneSession.ERROR_0001_ACCESSING_DESTROYED_SESSION!

    Root Cause Analysis

    1. java.lang.IllegalStateException

      StandaloneSession.ERROR_0001 - !StandaloneSession.ERROR_0001_ACCESSING_DESTROYED_SESSION!

      at org.pentaho.platform.engine.core.system.StandaloneSession.getAttribute()
    2. org.pentaho.platform
      CredentialsStrategySessionFactory.getSession
      1. org.pentaho.platform.engine.core.system.StandaloneSession.getAttribute(StandaloneSession.java:75)
      2. org.pentaho.platform.repository2.unified.jcr.JcrTenantUtils.getTenantedUser(JcrTenantUtils.java:96)
      3. org.pentaho.platform.repository2.unified.jcr.sejcr.PentahoSessionCredentialsStrategy.getUserId(PentahoSessionCredentialsStrategy.java:74)
      4. org.pentaho.platform.repository2.unified.jcr.sejcr.PentahoSessionCredentialsStrategy.getCredentials(PentahoSessionCredentialsStrategy.java:65)
      5. org.pentaho.platform.repository2.unified.jcr.sejcr.CredentialsStrategySessionFactory.getSession(CredentialsStrategySessionFactory.java:337)
      5 frames
    3. org.springframework.extensions
      LocalTransactionManager.doBegin
      1. org.springframework.extensions.jcr.jackrabbit.LocalTransactionManager.doBegin(LocalTransactionManager.java:120)
      1 frame
    4. Spring Tx
      TransactionInterceptor.invoke
      1. org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:374)
      2. org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:263)
      3. org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:101)
      3 frames
    5. Spring AOP
      JdkDynamicAopProxy.invoke
      1. org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
      2. org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
      2 frames
    6. com.sun.proxy
      $Proxy28.getTree
      1. com.sun.proxy.$Proxy28.getTree(Unknown Source)
      1 frame
    7. org.pentaho.platform
      ExceptionLoggingDecorator.getTree
      1. org.pentaho.platform.repository2.unified.ExceptionLoggingDecorator$41.call(ExceptionLoggingDecorator.java:445)
      2. org.pentaho.platform.repository2.unified.ExceptionLoggingDecorator$41.call(ExceptionLoggingDecorator.java:443)
      3. org.pentaho.platform.repository2.unified.ExceptionLoggingDecorator.callLogThrow(ExceptionLoggingDecorator.java:489)
      4. org.pentaho.platform.repository2.unified.ExceptionLoggingDecorator.getTree(ExceptionLoggingDecorator.java:443)
      5. org.pentaho.platform.repository2.unified.ExceptionLoggingDecorator.getTree(ExceptionLoggingDecorator.java:454)
      5 frames
    8. org.pentaho.di
      RunThread.run
      1. org.pentaho.di.repository.pur.PurRepository.loadRepositoryFileTree(PurRepository.java:520)
      2. org.pentaho.di.repository.pur.PurRepository.loadRepositoryDirectoryTree(PurRepository.java:528)
      3. org.pentaho.di.trans.steps.autodoc.AutoDoc.processRow(AutoDoc.java:163)
      4. org.pentaho.di.trans.step.RunThread.run(RunThread.java:62)
      4 frames
    9. Java RT
      Thread.run
      1. java.lang.Thread.run(Thread.java:744)
      1 frame