cancel
Showing results for 
Search instead for 
Did you mean: 

org.activiti.engine.impl.interceptor.CommandContext close

sonam
Champ in-the-making
Champ in-the-making
I am working on BookOrderTest.java with a connection to localhost database. The following is my code:

public class BookOrderTest {
   private Logger logger = LoggerFactory.getLogger(getClass());
   
   
   @Test
   public void startBookOrder() {
      logger.info("creating processEngine");
      ProcessEngine processEngine = ProcessEngineConfiguration
            .createStandaloneProcessEngineConfiguration().setJdbcDriver("org.h2.Driver").setDatabaseType("h2").
            setJdbcUrl("jdbc:h2:tcp://localhost/activiti")
            .setJdbcUsername("sa").setJdbcPassword("")            
            .buildProcessEngine();

   }
}


However, I keep getting the following error:

09 Oct 2014 09:59:54,589 [main] DEBUG org.apache.ibatis.logging.slf4j.Slf4jImpl:28 - PooledDataSource forcefully closed/removed all connections.
Oct 09, 2014 9:59:55 AM org.activiti.engine.impl.interceptor.CommandContext close
SEVERE: Error while closing command context
org.apache.ibatis.exceptions.PersistenceException:
### Error opening session.  Cause: org.h2.jdbc.JdbcSQLException: Database is already closed (to disable automatic closing at VM shutdown, add ";DB_CLOSE_ON_EXIT=FALSE" to the db URL) [90121-132]
### The error may exist in org/activiti/db/mapping/entity/EventSubscription.xml
### The error occurred while processing mapper_resultMap[compensateResultMap]
### Cause: org.h2.jdbc.JdbcSQLException: Database is already closed (to disable automatic closing at VM shutdown, add ";DB_CLOSE_ON_EXIT=FALSE" to the db URL) [90121-132]
   at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:8)
   at org.apache.ibatis.session.defaults.DefaultSqlSessionFactory.openSessionFromDataSource(DefaultSqlSessionFactory.java:83)
   at org.apache.ibatis.session.defaults.DefaultSqlSessionFactory.openSession(DefaultSqlSessionFactory.java:32)
   at org.activiti.engine.impl.db.DbSqlSession.<init>(DbSqlSession.java:86)
   at org.activiti.engine.impl.db.DbSqlSessionFactory.openSession(DbSqlSessionFactory.java:80)
   at org.activiti.engine.impl.interceptor.CommandContext.getSession(CommandContext.java:179)
   at org.activiti.engine.impl.SchemaOperationsProcessEngineBuild.execute(SchemaOperationsProcessEngineBuild.java:25)
   at org.activiti.engine.impl.interceptor.CommandExecutorImpl.execute(CommandExecutorImpl.java:24)
   at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:42)
   at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:33)
   at org.activiti.engine.impl.ProcessEngineImpl.<init>(ProcessEngineImpl.java:77)
   at org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl.buildProcessEngine(ProcessEngineConfigurationImpl.java:283)
   at org.bpmnwithactiviti.chapter1.BookOrderTest.startBookOrder(BookOrderTest.java:35)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
   at java.lang.reflect.Method.invoke(Unknown Source)
   at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
   at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
   at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
   at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
   at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)
   at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
   at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
   at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
   at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
   at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
   at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
   at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
   at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
   at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Caused by: org.h2.jdbc.JdbcSQLException: Database is already closed (to disable automatic closing at VM shutdown, add ";DB_CLOSE_ON_EXIT=FALSE" to the db URL) [90121-132]
   at org.h2.message.DbException.getJdbcSQLException(DbException.java:316)
   at org.h2.message.DbException.get(DbException.java:167)
   at org.h2.message.DbException.get(DbException.java:144)
   at org.h2.message.DbException.get(DbException.java:133)
   at org.h2.jdbc.JdbcConnection.checkClosed(JdbcConnection.java:1347)
   at org.h2.jdbc.JdbcConnection.checkClosed(JdbcConnection.java:1322)
   at org.h2.jdbc.JdbcConnection.getAutoCommit(JdbcConnection.java:385)
   at org.apache.ibatis.datasource.unpooled.UnpooledDataSource.configureConnection(UnpooledDataSource.java:159)
   at org.apache.ibatis.datasource.unpooled.UnpooledDataSource.getConnection(UnpooledDataSource.java:66)
   at org.apache.ibatis.datasource.pooled.PooledDataSource.popConnection(PooledDataSource.java:349)
   at org.apache.ibatis.datasource.pooled.PooledDataSource.getConnection(PooledDataSource.java:55)
   at org.apache.ibatis.session.defaults.DefaultSqlSessionFactory.openSessionFromDataSource(DefaultSqlSessionFactory.java:73)
   … 33 more

Oct 09, 2014 9:59:55 AM org.activiti.engine.impl.cfg.standalone.StandaloneMybatisTransactionContext rollback
INFO: Exception during transaction:
### Error opening session.  Cause: org.h2.jdbc.JdbcSQLException: Connection is broken: "session closed" [90067-132]
### Cause: org.h2.jdbc.JdbcSQLException: Connection is broken: "session closed" [90067-132]
Oct 09, 2014 9:59:55 AM org.activiti.engine.impl.interceptor.CommandContext exception
SEVERE: masked exception in command context. for root cause, see below as it will be rethrown later.
org.apache.ibatis.exceptions.PersistenceException:
### Error opening session.  Cause: org.h2.jdbc.JdbcSQLException: Connection is broken: "session closed" [90067-132]
### Cause: org.h2.jdbc.JdbcSQLException: Connection is broken: "session closed" [90067-132]
   at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:8)
   at org.apache.ibatis.session.defaults.DefaultSqlSessionFactory.openSessionFromDataSource(DefaultSqlSessionFactory.java:83)
   at org.apache.ibatis.session.defaults.DefaultSqlSessionFactory.openSession(DefaultSqlSessionFactory.java:32)
   at org.activiti.engine.impl.db.DbSqlSession.<init>(DbSqlSession.java:86)
   at org.activiti.engine.impl.db.DbSqlSessionFactory.openSession(DbSqlSessionFactory.java:80)
   at org.activiti.engine.impl.interceptor.CommandContext.getSession(CommandContext.java:179)
   at org.activiti.engine.impl.cfg.standalone.StandaloneMybatisTransactionContext.getDbSqlSession(StandaloneMybatisTransactionContext.java:77)
   at org.activiti.engine.impl.cfg.standalone.StandaloneMybatisTransactionContext.rollback(StandaloneMybatisTransactionContext.java:91)
   at org.activiti.engine.impl.interceptor.CommandContext.close(CommandContext.java:122)
   at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:49)
   at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:33)
   at org.activiti.engine.impl.ProcessEngineImpl.<init>(ProcessEngineImpl.java:77)
   at org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl.buildProcessEngine(ProcessEngineConfigurationImpl.java:283)
   at org.bpmnwithactiviti.chapter1.BookOrderTest.startBookOrder(BookOrderTest.java:35)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
   at java.lang.reflect.Method.invoke(Unknown Source)
   at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
   at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
   at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
   at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
   at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)
   at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
   at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
   at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
   at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
   at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
   at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
   at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
   at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
   at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Caused by: org.h2.jdbc.JdbcSQLException: Connection is broken: "session closed" [90067-132]
   at org.h2.message.DbException.getJdbcSQLException(DbException.java:316)
   at org.h2.message.DbException.get(DbException.java:167)
   at org.h2.message.DbException.get(DbException.java:144)
   at org.h2.engine.SessionRemote.checkClosed(SessionRemote.java:447)
   at org.h2.engine.SessionRemote.removeServer(SessionRemote.java:394)
   at org.h2.command.CommandRemote.prepare(CommandRemote.java:87)
   at org.h2.command.CommandRemote.<init>(CommandRemote.java:48)
   at org.h2.engine.SessionRemote.prepareCommand(SessionRemote.java:401)
   at org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:1074)
   at org.h2.jdbc.JdbcConnection.getInternalAutoCommit(JdbcConnection.java:394)
   at org.h2.jdbc.JdbcConnection.getAutoCommit(JdbcConnection.java:387)
   at org.apache.ibatis.datasource.unpooled.UnpooledDataSource.configureConnection(UnpooledDataSource.java:159)
   at org.apache.ibatis.datasource.unpooled.UnpooledDataSource.getConnection(UnpooledDataSource.java:66)
   at org.apache.ibatis.datasource.pooled.PooledDataSource.popConnection(PooledDataSource.java:349)
   at org.apache.ibatis.datasource.pooled.PooledDataSource.getConnection(PooledDataSource.java:55)
   at org.apache.ibatis.session.defaults.DefaultSqlSessionFactory.openSessionFromDataSource(DefaultSqlSessionFactory.java:73)
   … 34 more


I checked to ensure my H2 database is running locally.

How can I manually create a ProcessEngineConfiguration that connects to a remote H2 database?

I am using activiti-engine 5.9 version of jar.

thanks

-Sonam
10 REPLIES 10

trademak
Star Contributor
Star Contributor
The error already shows the solution:

### Error opening session. Cause: org.h2.jdbc.JdbcSQLException: Database is already closed (to disable automatic closing at VM shutdown, add ";DB_CLOSE_ON_EXIT=FALSE" to the db URL) [90121-132]

Best regards,

sonam
Champ in-the-making
Champ in-the-making
Yes, I have tried the solution as stated in the error by appending it to the jdbc-url (setJdbcUrl("jdbc:h2:tcp://localhost/activiti;DB_CLOSE_ON_EXIT=FALSE")) .  However, I still see the similar error with the following stacktrace:

Oct 10, 2014 9:36:01 AM org.activiti.engine.impl.interceptor.CommandContext close
SEVERE: Error while closing command context
org.apache.ibatis.exceptions.PersistenceException:
### Error opening session.  Cause: org.h2.jdbc.JdbcSQLException: Database is already closed (to disable automatic closing at VM shutdown, add ";DB_CLOSE_ON_EXIT=FALSE" to the db URL) [90121-132]
### The error may exist in org/activiti/db/mapping/entity/EventSubscription.xml
### The error occurred while processing mapper_resultMap[compensateResultMap]
### Cause: org.h2.jdbc.JdbcSQLException: Database is already closed (to disable automatic closing at VM shutdown, add ";DB_CLOSE_ON_EXIT=FALSE" to the db URL) [90121-132]
at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:8)
at org.apache.ibatis.session.defaults.DefaultSqlSessionFactory.openSessionFromDataSource(DefaultSqlSessionFactory.java:83)

thanks

-Sonam

jbarrez
Star Contributor
Star Contributor
See http://www.h2database.com/html/features.html :

By default, closing the last connection to a database closes the database. For an in-memory database, this means the content is lost. To keep the database open, add ;DB_CLOSE_DELAY=-1 to the database URL. To keep the content of an in-memory database as long as the virtual machine is alive, use jdbc:h2:mem:test;DB_CLOSE_DELAY=-1.

sonam
Champ in-the-making
Champ in-the-making
I am connecting to a standalone database not a in-memory one.   I am not able to connect to a standalone database in my test case.

jbarrez
Star Contributor
Star Contributor
hmm ok, sorry didn't read that bit.

So, are your sure the H2 standalone is running? Can you connect to it with the H2 webap tool?

Which H2 version are you using? More recent versions of H2 have a different url (see https://github.com/Activiti/Activiti/commit/5f6cee1b55ac6e8a0ce16b7698e9bc19297a73cc)

sonam
Champ in-the-making
Champ in-the-making
Yes, my H2 Console webapp requires "jdbc:h2:tcp://localhost/~/activiti" which is as same as in the GitHub file.  I still run into the same error.  When I log-in to the H2 Console  I see tables such as "CATALOGS, COLLATIONS,.." and so on.  Do I need to manually run some external command for database setup?

I have also tried to switch within the Activiti-explorer weabpp to a standalone database and it runs into error too.  For the activitii-explorer webapp I see the following:

Caused by: org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Connection is broken: "unexpected status 16777216" [90067-170])
        at org.apache.commons.dbcp.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:1549)
        at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1388)
  
I can start a separate thread for the activiti-explorer webapp if you want.

thanks
-Sonam
-Sonam

jbarrez
Star Contributor
Star Contributor
If you don't see the Activiti tables in the H2 web console, then something has gone wrong.

How do you boot up your H2? Should just starting the H2 using the jar.

After that, you need to change the jdbc url in the config of Explorer to use that database.

The exception you get does point to the fact it can't reach the database, either because the db isnt up and running or if the url is wrong.

sonam
Champ in-the-making
Champ in-the-making
I downloaded another copy of H2 (Version 1.3.176 (2014-04-05), Last Stable) and it worked.  I had H2 Version 1.4.182 (2014-10-17), Beta which does not work with current Activiti 5.16.3. 

-thanks

jbarrez
Star Contributor
Star Contributor
Hmm odd. We'll double check it in our QA