H2 specific errors while connecting to Postgres DB

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-22-2016 10:44 PM
I am trying to configure activiti to use postgres DB.
My db.properties file is:
db=postgres
jdbc.driver=org.postgresql.Driver
jdbc.url=jdbc
ostgresql://localhost:5432/activiti
jdbc.username=activiti
jdbc.password=activiti
=======================================
My activiti.cfg.xml is something like :
property name="jdbcUrl" value="jdbc
ostgresql://localhost:5432/activiti"
property name="jdbcDriver" value="org.postgresql.Driver"
property name="jdbcUsername" value="activiti"
property name="jdbcPassword" value="activiti"
property name="databaseSchemaUpdate" value="true"
=======================================
The test case I am trying to run is:
public class BookOrderTest {
@Test
public void startBookOrder() {
ProcessEngine processEngine = ProcessEngineConfiguration
.createStandaloneProcessEngineConfiguration()
.buildProcessEngine();
RepositoryService repositoryService = processEngine.getRepositoryService();
RuntimeService runtimeService = processEngine.getRuntimeService();
IdentityService identityService = processEngine.getIdentityService();
TaskService taskService = processEngine.getTaskService();
repositoryService.createDeployment()
.addClasspathResource("bookorder.bpmn20.xml")
.deploy();
// remove tasks already present
List<Task> availableTaskList = taskService.createTaskQuery().taskName("Work on order").list();
for (Task task : availableTaskList) {
taskService.complete(task.getId());
}
Map<String, Object> variableMap = new HashMap<String, Object>();
variableMap.put("isbn", "123456");
identityService.setAuthenticatedUserId("kermit");
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(
"bookorder", variableMap);
assertNotNull(processInstance.getId());
List<Task> taskList = taskService.createTaskQuery().taskName("Work on order").list();
assertEquals(1, taskList.size());
System.out.println("found task " + taskList.get(0).getName());
}
}
=======================================
Now, when I start tomcat, I see my activiti database (the one I created in postgres, gets populated with 25 tables), but when I run the test case shown above I get the below error:
——————————————————
Feb 23, 2016 9:09:46 AM org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl initDatabaseType
SEVERE: Exception while initializing Database connection
org.h2.jdbc.JdbcSQLException: Connection is broken: "java.net.ConnectException: Connection refused: localhost" [90067-191]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:345)
at org.h2.message.DbException.get(DbException.java:168)
at org.h2.engine.SessionRemote.connectServer(SessionRemote.java:452)
at org.h2.engine.SessionRemote.connectEmbeddedOrServer(SessionRemote.java:329)
at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:107)
at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:91)
at org.h2.Driver.connect(Driver.java:72)
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:208)
at org.apache.ibatis.datasource.unpooled.UnpooledDataSource.doGetConnection(UnpooledDataSource.java:201)
at org.apache.ibatis.datasource.unpooled.UnpooledDataSource.doGetConnection(UnpooledDataSource.java:196)
at org.apache.ibatis.datasource.unpooled.UnpooledDataSource.getConnection(UnpooledDataSource.java:93)
at org.apache.ibatis.datasource.pooled.PooledDataSource.popConnection(PooledDataSource.java:385)
at org.apache.ibatis.datasource.pooled.PooledDataSource.getConnection(PooledDataSource.java:89)
at org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl.initDatabaseType(ProcessEngineConfigurationImpl.java:835)
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 BookOrderTest.startBookOrder(BookOrderTest.java:25)
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.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
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: java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at org.h2.util.NetUtils.createSocket(NetUtils.java:122)
at org.h2.util.NetUtils.createSocket(NetUtils.java:102)
at org.h2.engine.SessionRemote.initTransfer(SessionRemote.java:114)
at org.h2.engine.SessionRemote.connectServer(SessionRemote.java:448)
… 39 more
=======================================
I don't understand why I am getting this error and it sure looks like one related to H2 database.
Any pointers?
My db.properties file is:
db=postgres
jdbc.driver=org.postgresql.Driver
jdbc.url=jdbc

jdbc.username=activiti
jdbc.password=activiti
=======================================
My activiti.cfg.xml is something like :
property name="jdbcUrl" value="jdbc

property name="jdbcDriver" value="org.postgresql.Driver"
property name="jdbcUsername" value="activiti"
property name="jdbcPassword" value="activiti"
property name="databaseSchemaUpdate" value="true"
=======================================
The test case I am trying to run is:
public class BookOrderTest {
@Test
public void startBookOrder() {
ProcessEngine processEngine = ProcessEngineConfiguration
.createStandaloneProcessEngineConfiguration()
.buildProcessEngine();
RepositoryService repositoryService = processEngine.getRepositoryService();
RuntimeService runtimeService = processEngine.getRuntimeService();
IdentityService identityService = processEngine.getIdentityService();
TaskService taskService = processEngine.getTaskService();
repositoryService.createDeployment()
.addClasspathResource("bookorder.bpmn20.xml")
.deploy();
// remove tasks already present
List<Task> availableTaskList = taskService.createTaskQuery().taskName("Work on order").list();
for (Task task : availableTaskList) {
taskService.complete(task.getId());
}
Map<String, Object> variableMap = new HashMap<String, Object>();
variableMap.put("isbn", "123456");
identityService.setAuthenticatedUserId("kermit");
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(
"bookorder", variableMap);
assertNotNull(processInstance.getId());
List<Task> taskList = taskService.createTaskQuery().taskName("Work on order").list();
assertEquals(1, taskList.size());
System.out.println("found task " + taskList.get(0).getName());
}
}
=======================================
Now, when I start tomcat, I see my activiti database (the one I created in postgres, gets populated with 25 tables), but when I run the test case shown above I get the below error:
——————————————————
Feb 23, 2016 9:09:46 AM org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl initDatabaseType
SEVERE: Exception while initializing Database connection
org.h2.jdbc.JdbcSQLException: Connection is broken: "java.net.ConnectException: Connection refused: localhost" [90067-191]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:345)
at org.h2.message.DbException.get(DbException.java:168)
at org.h2.engine.SessionRemote.connectServer(SessionRemote.java:452)
at org.h2.engine.SessionRemote.connectEmbeddedOrServer(SessionRemote.java:329)
at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:107)
at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:91)
at org.h2.Driver.connect(Driver.java:72)
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:208)
at org.apache.ibatis.datasource.unpooled.UnpooledDataSource.doGetConnection(UnpooledDataSource.java:201)
at org.apache.ibatis.datasource.unpooled.UnpooledDataSource.doGetConnection(UnpooledDataSource.java:196)
at org.apache.ibatis.datasource.unpooled.UnpooledDataSource.getConnection(UnpooledDataSource.java:93)
at org.apache.ibatis.datasource.pooled.PooledDataSource.popConnection(PooledDataSource.java:385)
at org.apache.ibatis.datasource.pooled.PooledDataSource.getConnection(PooledDataSource.java:89)
at org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl.initDatabaseType(ProcessEngineConfigurationImpl.java:835)
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 BookOrderTest.startBookOrder(BookOrderTest.java:25)
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.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
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: java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at org.h2.util.NetUtils.createSocket(NetUtils.java:122)
at org.h2.util.NetUtils.createSocket(NetUtils.java:102)
at org.h2.engine.SessionRemote.initTransfer(SessionRemote.java:114)
at org.h2.engine.SessionRemote.connectServer(SessionRemote.java:448)
… 39 more
=======================================
I don't understand why I am getting this error and it sure looks like one related to H2 database.
Any pointers?
Labels:
- Labels:
-
Archive
6 REPLIES 6
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-23-2016 02:45 AM
Hi,
your configuration still uses H2 DB. Check config files for H2 configuration and change it to postgres.
Regards
Martin
your configuration still uses H2 DB. Check config files for H2 configuration and change it to postgres.
Regards
Martin

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-23-2016 10:02 AM
I am sorry, I don't understand.
Is there any other file except db.properties and activiti.cfg.xml?
As shown in my original question above, I have already updated these files for Postgres.
Also, I would like to point out again from above that:
"when I start tomcat, I see my activiti database (the one I created in postgres, gets populated with 25 tables), but when I run the test case shown above I get the below error:
org.h2.jdbc.JdbcSQLException: Connection is broken: "java.net.ConnectException: Connection refused: localhost" [90067-191]
"
Is there any other file except db.properties and activiti.cfg.xml?
As shown in my original question above, I have already updated these files for Postgres.
Also, I would like to point out again from above that:
"when I start tomcat, I see my activiti database (the one I created in postgres, gets populated with 25 tables), but when I run the test case shown above I get the below error:
org.h2.jdbc.JdbcSQLException: Connection is broken: "java.net.ConnectException: Connection refused: localhost" [90067-191]
"

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-23-2016 10:29 AM
Whoa, something odd happened:
I updated my test case to have process-engine bootstrapped like:
ProcessEngine processEngine = ProcessEngineConfiguration.createStandaloneInMemProcessEngineConfiguration()
.setDatabaseSchemaUpdate(ProcessEngineConfiguration.DB_SCHEMA_UPDATE_FALSE)
.setJdbcUrl("jdbc
ostgresql://localhost:5432/activiti")
.setJdbcUsername("activiti")
.setJdbcPassword("activiti")
.buildProcessEngine();
instead of
ProcessEngine processEngine = ProcessEngineConfiguration
.createStandaloneProcessEngineConfiguration()
.buildProcessEngine();
Can someone please explain what happened and why the values were not picked from activiti.cfg.xml?
Thanks
I updated my test case to have process-engine bootstrapped like:
ProcessEngine processEngine = ProcessEngineConfiguration.createStandaloneInMemProcessEngineConfiguration()
.setDatabaseSchemaUpdate(ProcessEngineConfiguration.DB_SCHEMA_UPDATE_FALSE)
.setJdbcUrl("jdbc

.setJdbcUsername("activiti")
.setJdbcPassword("activiti")
.buildProcessEngine();
instead of
ProcessEngine processEngine = ProcessEngineConfiguration
.createStandaloneProcessEngineConfiguration()
.buildProcessEngine();
Can someone please explain what happened and why the values were not picked from activiti.cfg.xml?
Thanks
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-24-2016 05:04 AM
Because now you're instantiating the engine programmatically - no cfg.xml file is involved.
Use the createProcessEngineConfigurationFromResource() method if you want to create a process engine based on an external file.
Use the createProcessEngineConfigurationFromResource() method if you want to create a process engine based on an external file.

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-24-2016 11:25 AM
Hi jbarrez,
Thanks to the reply.
So you are suggesting that if I do:
ProcessEngine processEngine = ProcessEngineConfiguration.createStandaloneProcessEngineConfiguration().buildProcessEngine();
It simply defaults to the default values i.e. H2 db etc.
So, either I instantiate the processEngine programmatically or use createProcessEngineConfigurationFromResource() if I want to read from cfg.xml
Thanks,
Mohit
Thanks to the reply.
So you are suggesting that if I do:
ProcessEngine processEngine = ProcessEngineConfiguration.createStandaloneProcessEngineConfiguration().buildProcessEngine();
It simply defaults to the default values i.e. H2 db etc.
So, either I instantiate the processEngine programmatically or use createProcessEngineConfigurationFromResource() if I want to read from cfg.xml
Thanks,
Mohit
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-01-2016 03:20 PM
No, after createStandaloneProcessEngineConfiguration you can call many (many) setters, like setJdbcUrl and all ….
