title: Exception while trying to connect to H2 database setup for Activiti
body: <p>I am trying to setup standalone H2 DB to tryout some basic Activiti stuff.
  But whenever I try to start tomcat I get an exception:</p>
  
  <pre><code>    09:32:57,270 [localhost-startStop-1] ERROR org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl  - Exception while initializing Database connection
  org.h2.jdbc.JdbcSQLException: Wrong user name or password [28000-191]
      at org.h2.message.DbException.getJdbcSQLException(DbException.java:345)
      at org.h2.message.DbException.get(DbException.java:179)
      at org.h2.message.DbException.get(DbException.java:155)
      at org.h2.message.DbException.get(DbException.java:144)
      at org.h2.engine.Engine.validateUserAndPassword(Engine.java:333)
      at org.h2.engine.Engine.createSessionAndValidate(Engine.java:161)
      at org.h2.engine.Engine.createSession(Engine.java:136)
      at org.h2.server.TcpServerThread.run(TcpServerThread.java:149)
      at java.lang.Thread.run(Thread.java:745)
  
      at org.h2.engine.SessionRemote.done(SessionRemote.java:606)
      at org.h2.engine.SessionRemote.initTransfer(SessionRemote.java:129)
      at org.h2.engine.SessionRemote.connectServer(SessionRemote.java:430)
      at org.h2.engine.SessionRemote.connectEmbeddedOrServer(SessionRemote.java:311)
      at org.h2.jdbc.JdbcConnection.&lt;init&gt;(JdbcConnection.java:107)
      at org.h2.jdbc.JdbcConnection.&lt;init&gt;(JdbcConnection.java:91)
      at org.h2.Driver.connect(Driver.java:74)
      at org.springframework.jdbc.datasource.SimpleDriverDataSource.getConnectionFromDriver(SimpleDriverDataSource.java:140)
      at org.springframework.jdbc.datasource.AbstractDriverBasedDataSource.getConnectionFromDriver(AbstractDriverBasedDataSource.java:155)
      at org.springframework.jdbc.datasource.AbstractDriverBasedDataSource.getConnection(AbstractDriverBasedDataSource.java:120)
      at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:111)
      at org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy$TransactionAwareInvocationHandler.invoke(TransactionAwareDataSourceProxy.java:225)
      at com.sun.proxy.$Proxy17.getMetaData(Unknown Source)
      at org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl.initDatabaseType(ProcessEngineConfigurationImpl.java:836)
      at org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl.initDataSource(ProcessEngineConfigurationImpl.java:786)
      at org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl.init(ProcessEngineConfigurationImpl.java:602)
      at org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl.buildProcessEngine(ProcessEngineConfigurationImpl.java:590)
      at org.activiti.spring.SpringProcessEngineConfiguration.buildProcessEngine(SpringProcessEngineConfiguration.java:65)
      at org.activiti.spring.ProcessEngineFactoryBean.getObject(ProcessEngineFactoryBean.java:60)
      at org.activiti.spring.ProcessEngineFactoryBean.getObject(ProcessEngineFactoryBean.java:32)
      at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:168)
      at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:103)
      at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1517)
      at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:251)
      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
      at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor$1.intercept(ConfigurationClassEnhancer.java:379)
      at org.activiti.spring.ProcessEngineFactoryBean$$EnhancerBySpringCGLIB$$fe4dada2.getObject(&lt;generated&gt;)
      at org.activiti.explorer.conf.ActivitiEngineConfiguration.processEngine(ActivitiEngineConfiguration.java:83)
      at org.activiti.explorer.conf.ActivitiEngineConfiguration$$EnhancerBySpringCGLIB$$4bdf3172.CGLIB$processEngine$3(&lt;generated&gt;)
      at org.activiti.explorer.conf.ActivitiEngineConfiguration$$EnhancerBySpringCGLIB$$4bdf3172$$FastClassBySpringCGLIB$$a52c8ed.invoke(&lt;generated&gt;)
      at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
      at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:309)
      at org.activiti.explorer.conf.ActivitiEngineConfiguration$$EnhancerBySpringCGLIB$$4bdf3172.processEngine(&lt;generated&gt;)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:497)
      at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162)
      at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1111)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1006)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:504)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
      at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
      at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
      at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
      at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:322)
      at org.activiti.explorer.conf.ActivitiEngineConfiguration$$EnhancerBySpringCGLIB$$4bdf3172.processEngine(&lt;generated&gt;)
      at org.activiti.explorer.conf.ActivitiEngineConfiguration.identityService(ActivitiEngineConfiguration.java:159)
      at org.activiti.explorer.conf.ActivitiEngineConfiguration$$EnhancerBySpringCGLIB$$4bdf3172.CGLIB$identityService$10(&lt;generated&gt;)
      at org.activiti.explorer.conf.ActivitiEngineConfiguration$$EnhancerBySpringCGLIB$$4bdf3172$$FastClassBySpringCGLIB$$a52c8ed.invoke(&lt;generated&gt;)
      at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
      at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:309)
      at org.activiti.explorer.conf.ActivitiEngineConfiguration$$EnhancerBySpringCGLIB$$4bdf3172.identityService(&lt;generated&gt;)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:497)
      at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162)
      at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1111)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1006)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:504)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
      at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
      at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
      at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1120)
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1044)
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:942)
      at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:533)
      at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
      at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1202)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
      at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
      at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
      at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:755)
      at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757)
      at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)
      at org.activiti.explorer.servlet.WebConfigurer.contextInitialized(WebConfigurer.java:40)
      at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4812)
      at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5255)
      at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
      at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725)
      at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701)
      at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
      at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:945)
      at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1795)
      at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
      at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      at java.lang.Thread.run(Thread.java:745)
  </code></pre>
  
  <p>My tomcat/webapps/WEB_INF/classes/db.properties is:</p>
  
  <pre><code>db=h2
  jdbc.driver=org.h2.Driver
  jdbc.url=jdbc:h2:tcp://localhost/~/test
  jdbc.username=sa
  jdbc.password=
  </code></pre>
  
  <p>And my activiti.cfg.xml is:</p>
  
  <pre><code> &lt;beans xmlns="http://www.springframework.org/schema/beans"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://www.springframework.org/schema/beans   http://www.springframework.org/schema/beans/spring-beans.xsd"&gt;
  
    &lt;bean id="processEngineConfiguration" class="org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration"&gt;
  
      &lt;property name="jdbcUrl" value="jdbc:h2:tcp://localhost/~/test" /&gt;
     &lt;!-- &lt;property name="jdbcUrl" value="jdbc:h2:mem:activiti;DB_CLOSE_DELAY=1000" /&gt; --&gt;
      &lt;property name="jdbcDriver" value="org.h2.Driver" /&gt;
      &lt;property name="jdbcUsername" value="sa" /&gt;
      &lt;property name="jdbcPassword" value="" /&gt;
      &lt;property name="databaseSchemaUpdate" value="true" /&gt;
  
      &lt;property name="jobExecutorActivate" value="false" /&gt;
      &lt;property name="asyncExecutorEnabled" value="true" /&gt;
      &lt;property name="asyncExecutorActivate" value="false" /&gt;
  
      &lt;property name="mailServerHost" value="mail.my-corp.com" /&gt;
      &lt;property name="mailServerPort" value="5025" /&gt;
    &lt;/bean&gt;
  &lt;/beans&gt;
  </code></pre>
  
  <p>My project hierarchy is:</p>
  
  <p><a href="https://i.stack.imgur.com/0hwQ2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0hwQ2.png" alt="enter image description here"></a></p>
  
  <p>and I am able to log into H2 console using credentials sa/sa:</p>
  
  <p><a href="https://i.stack.imgur.com/H3vLW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/H3vLW.png" alt="enter image description here"></a></p>
  
  <p><strong>EDIT#1</strong></p>
  
  <p>I am not sure how to set username/password. I am using the default settings only.</p>
  
  <p>I managed to log into H2 console using credentials sa/sa.</p>
  
  <p>in my tomcat/webapps..../db.properties and activiti.cfg.xml I have:</p>
  
  <pre><code>jdbc.username=sa
  jdbc.password=
  </code></pre>
  
  <p>&amp;</p>
  
  <pre><code>&lt;property name="jdbcUsername" value="sa" /&gt;
  &lt;property name="jdbcPassword" value="" /&gt;
  </code></pre>
  
  <p>respectively.</p>
  
  <p>I had also tried by setting password value as "sa" in these two files. But in that case I get a different error:</p>
  
  <pre><code>01:36:27,467 [localhost-startStop-1] ERROR org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl  - Exception while closing the Database connection
  org.h2.jdbc.JdbcSQLException: Connection is broken: "unexpected status 16777216" [90067-176]
      at org.h2.message.DbException.getJdbcSQLException(DbException.java:344)
      at org.h2.message.DbException.get(DbException.java:178)
      at org.h2.message.DbException.get(DbException.java:154)
      at org.h2.engine.SessionRemote.done(SessionRemote.java:621)
      at org.h2.engine.SessionRemote.close(SessionRemote.java:552)
      at org.h2.jdbc.JdbcConnection.close(JdbcConnection.java:383)
      at org.springframework.jdbc.datasource.DataSourceUtils.doCloseConnection(DataSourceUtils.java:341)
      at org.springframework.jdbc.datasource.DataSourceUtils.doReleaseConnection(DataSourceUtils.java:328)
      at org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy$TransactionAwareInvocationHandler.invoke(TransactionAwareDataSourceProxy.java:212)
      at com.sun.proxy.$Proxy17.close(Unknown Source)
      at org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl.initDatabaseType(ProcessEngineConfigurationImpl.java:850)
      at org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl.initDataSource(ProcessEngineConfigurationImpl.java:786)
      at org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl.init(ProcessEngineConfigurationImpl.java:602)
      at org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl.buildProcessEngine(ProcessEngineConfigurationImpl.java:590)
      at org.activiti.spring.SpringProcessEngineConfiguration.buildProcessEngine(SpringProcessEngineConfiguration.java:65)
      at org.activiti.spring.ProcessEngineFactoryBean.getObject(ProcessEngineFactoryBean.java:60)
      at org.activiti.spring.ProcessEngineFactoryBean.getObject(ProcessEngineFactoryBean.java:32)
      at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:168)
      at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:103)
      at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1517)
      at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:251)
      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
      at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor$1.intercept(ConfigurationClassEnhancer.java:379)
      at org.activiti.spring.ProcessEngineFactoryBean$$EnhancerBySpringCGLIB$$8028cc4c.getObject(&lt;generated&gt;)
      at org.activiti.explorer.conf.ActivitiEngineConfiguration.processEngine(ActivitiEngineConfiguration.java:83)
      at org.activiti.explorer.conf.ActivitiEngineConfiguration$$EnhancerBySpringCGLIB$$fa2b185e.CGLIB$processEngine$3(&lt;generated&gt;)
      at org.activiti.explorer.conf.ActivitiEngineConfiguration$$EnhancerBySpringCGLIB$$fa2b185e$$FastClassBySpringCGLIB$$c9dbd5a6.invoke(&lt;generated&gt;)
      at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
      at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:309)
      at org.activiti.explorer.conf.ActivitiEngineConfiguration$$EnhancerBySpringCGLIB$$fa2b185e.processEngine(&lt;generated&gt;)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:497)
      at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162)
      at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1111)
  </code></pre>
  
  <p><strong>EDIT#2</strong></p>
  
  <p>Ok, I just replaced the JdbcUrl in activiti.cfg.xml from <code>jdbc:h2:tcp://localhost/~/test</code> to <code>jdbc:h2:tcp://localhost/~/activiti</code>
  and tomcat is now starting fine, without errors. Not sure what happened.
  I now log into H2 console without password just sa/"", works</p>
  
  <p>I can now execute my BookOrderTest(the test case that uses H2 standalone DB) successfully BUT I still can't see a new queued task being created due to this test run at <code>localhost/activiti-explorer</code> web-app.
  Any thoughts?</p>
  
  <p>Thanks</p>