OHDSI Home | Forums | Wiki | Github

WebAPI PostgreSQL Installation

I am new to the ODHSI suite of web tools, and I am having trouble with my installation of the WebAPI (cloned from github 12/5/2017) using PostgreSQL 9.6.6. The build will complete successfully, but with the warnings shown below, the war file will not successfully deploy to Tomcat. I am using Java 1.8.0.151, Maven 3.5.0 and Tomcat 8.5.24 on Ubuntu 17.10.

I confirmed that a stand-alone Java class is able to connect to the same database on the PostgreSQL instance using JDBC and the credentials outlined in settings.xml.

It seems like whatever is happening in the build is keeping WebAPI to connect to the database, but I am not sure how to fix it. If anyone has any insight I would greatly appreciate it!

The initial catalina.out error message is as follows. It seems to be attempting to connect to the IP address specified in pom.wml, this is another error from catalina.out. Why is it trying to connect to this IP address, isn’t it supposed to connect to the localhost as specified in settings.xml?

 2017-12-07 10:47:33.817 WARN localhost-startStop-1 org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext -  - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'shiroFilter' defined in class path resource [org/ohdsi/webapi/ShiroConfiguration.class]: Unsatisfied dependency expressed through method 'shiroFilter' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flyway' defined in class path resource [org/ohdsi/webapi/FlywayConfig.class]: Invocation of init method failed; nested exception is org.flywaydb.core.api.FlywayException: Unable to obtain Jdbc connection from DataSource

Caused by: org.postgresql.util.PSQLException: Connection to 54.209.111.128:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
	at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:239)
	at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:66)
	at org.postgresql.jdbc2.AbstractJdbc2Connection.<init>(AbstractJdbc2Connection.java:127)
	at org.postgresql.jdbc3.AbstractJdbc3Connection.<init>(AbstractJdbc3Connection.java:29)
	at org.postgresql.jdbc3g.AbstractJdbc3gConnection.<init>(AbstractJdbc3gConnection.java:21)
	at org.postgresql.jdbc4.AbstractJdbc4Connection.<init>(AbstractJdbc4Connection.java:41)
	at org.postgresql.jdbc4.Jdbc4Connection.<init>(Jdbc4Connection.java:24)
	at org.postgresql.Driver.makeConnection(Driver.java:414)
	at org.postgresql.Driver.connect(Driver.java:282)
	at org.apache.tomcat.jdbc.pool.PooledConnection.connectUsingDriver(PooledConnection.java:310)
	at org.apache.tomcat.jdbc.pool.PooledConnection.connect(PooledConnection.java:203)
	at org.apache.tomcat.jdbc.pool.ConnectionPool.createConnection(ConnectionPool.java:732)
	at org.apache.tomcat.jdbc.pool.ConnectionPool.borrowConnection(ConnectionPool.java:664)
	at org.apache.tomcat.jdbc.pool.ConnectionPool.init(ConnectionPool.java:479)
	at org.apache.tomcat.jdbc.pool.ConnectionPool.<init>(ConnectionPool.java:154)
	at org.apache.tomcat.jdbc.pool.DataSourceProxy.pCreatePool(DataSourceProxy.java:118)
	at org.apache.tomcat.jdbc.pool.DataSourceProxy.createPool(DataSourceProxy.java:107)
	at org.apache.tomcat.jdbc.pool.DataSourceProxy.getConnection(DataSourceProxy.java:131)
	at org.flywaydb.core.internal.util.jdbc.JdbcUtils.openConnection(JdbcUtils.java:50)

Here are the settings.xml file contents:

<settings>
  <profiles>
    <profile>
      <id>webapi−postgresql</id>
      <properties>
        <datasource.driverClassName>org.postgresql.Driver</datasource.driverClassName>
        <datasource.url>jdbc:postgresql://localhost:5432/OHDSI</datasource.url>
        <datasource.username>ohdsi_app_user</datasource.username>
        <datasource.password>*************</datasource.password>
        <datasource.dialect>postgresql</datasource.dialect>
        <datasource.ohdsi.schema>webapi</datasource.ohdsi.schema>
        <flyway.datasource.driverClassName>${datasource.driverClassName}</flyway.datasource.driverClassName>
        <flyway.datasource.url>${datasource.url}</flyway.datasource.url>
        <flyway.datasource.username>ohdsi_admin_user</flyway.datasource.username>
        <flyway.datasource.password>*************</flyway.datasource.password>
        <flyway.locations>classpath:db/migration/postgresql</flyway.locations>
      </properties>
    </profile>
  </profiles>
</settings>

Here are the Maven command line and built output:

VirtualBox:~/WebAPI$ mvn clean package -s ../settings.xml -P webapi-postgresql
[INFO] Scanning for projects...
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] Building WebAPI 1.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
Downloading: http://repo.ohdsi.org:8085/nexus/content/repositories/thirdparty/org/ohdsi/sql/SqlRender/1.3.0-SNAPSHOT/maven-metadata.xml
Downloading: http://repo.maven.apache.org/maven2/org/ohdsi/sql/SqlRender/1.3.0-SNAPSHOT/maven-metadata.xml
Downloading: http://repo.ohdsi.org:8085/nexus/content/repositories/snapshots/org/ohdsi/sql/SqlRender/1.3.0-SNAPSHOT/maven-metadata.xml
Downloading: http://repo.ohdsi.org:8085/nexus/content/repositories/releases/org/ohdsi/sql/SqlRender/1.3.0-SNAPSHOT/maven-metadata.xml
Downloading: http://redshift-maven-repository.s3-website-us-east-1.amazonaws.com/release/org/ohdsi/sql/SqlRender/1.3.0-SNAPSHOT/maven-metadata.xml
Downloaded: http://repo.ohdsi.org:8085/nexus/content/repositories/snapshots/org/ohdsi/sql/SqlRender/1.3.0-SNAPSHOT/maven-metadata.xml (1.2 kB at 2.4 kB/s)
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ WebAPI ---
[INFO] Deleting /home/kai/WebAPI/target
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ WebAPI ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 398 resources
[INFO] Copying 1 resource
[INFO] Copying 0 resource
[INFO] 
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ WebAPI ---
[INFO] Compiling 354 source files to /home/kai/WebAPI/target/classes
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ WebAPI ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] 
[INFO] --- maven-compiler-plugin:2.5.1:testCompile (default-testCompile) @ WebAPI ---
[INFO] Compiling 7 source files to /home/kai/WebAPI/target/test-classes
[INFO] 
[INFO] --- maven-surefire-plugin:2.18.1:test (default-test) @ WebAPI ---
[INFO] Tests are skipped.
[INFO] 
[INFO] --- maven-war-plugin:2.2:war (default-war) @ WebAPI ---
[INFO] Packaging webapp
[INFO] Assembling webapp [WebAPI] in [/home/kai/WebAPI/target/WebAPI]
[INFO] Processing war project
[INFO] Copying webapp resources [/home/kai/WebAPI/src/main/webapp]
[INFO] Webapp assembled in [2158 msecs]
[INFO] Building war: /home/kai/WebAPI/target/WebAPI.war
[INFO] 
[INFO] --- miredot-plugin:1.5.1:restdoc (default) @ WebAPI ---
[WARNING] Miredot is unable to document the status codes of rest interfaces, unless a statusCodes-block is specified in pom.xml
[INFO] Building reflective model of API and reading annotations...
[WARNING] Unknown annotation on service method: skipped @org.springframework.transaction.annotation.Transactional(propagation=REQUIRED, rollbackForClassName=[], readOnly=false, transactionManager=, isolation=DEFAULT, noRollbackFor=[], noRollbackForClassName=[], value=, timeout=-1, rollbackFor=[])
[WARNING] Unknown annotation on service method: skipped @org.springframework.transaction.annotation.Transactional(propagation=REQUIRED, rollbackForClassName=[], readOnly=false, transactionManager=, isolation=DEFAULT, noRollbackFor=[], noRollbackForClassName=[], value=, timeout=-1, rollbackFor=[])
[WARNING] Unknown annotation on service method: skipped @org.springframework.transaction.annotation.Transactional(propagation=REQUIRED, rollbackForClassName=[], readOnly=true, transactionManager=, isolation=DEFAULT, noRollbackFor=[], noRollbackForClassName=[], value=, timeout=-1, rollbackFor=[])
[WARNING] Unknown annotation on service method: skipped @org.springframework.transaction.annotation.Transactional(propagation=REQUIRED, rollbackForClassName=[], readOnly=false, transactionManager=, isolation=DEFAULT, noRollbackFor=[], noRollbackForClassName=[], value=, timeout=-1, rollbackFor=[])
[WARNING] Unknown annotation on service method: skipped @org.springframework.transaction.annotation.Transactional(propagation=REQUIRED, rollbackForClassName=[], readOnly=false, transactionManager=, isolation=DEFAULT, noRollbackFor=[], noRollbackForClassName=[], value=, timeout=-1, rollbackFor=[])
[WARNING] Unknown annotation on service method: skipped @org.springframework.transaction.annotation.Transactional(propagation=REQUIRED, rollbackForClassName=[], readOnly=true, transactionManager=, isolation=DEFAULT, noRollbackFor=[], noRollbackForClassName=[], value=, timeout=-1, rollbackFor=[])
[WARNING] Unknown annotation on service method: skipped @org.springframework.transaction.annotation.Transactional(propagation=REQUIRED, rollbackForClassName=[], readOnly=false, transactionManager=, isolation=DEFAULT, noRollbackFor=[], noRollbackForClassName=[], value=, timeout=-1, rollbackFor=[])
[WARNING] Unknown annotation on service method: skipped @javax.transaction.Transactional(value=REQUIRED, rollbackOn=[], dontRollbackOn=[])
[WARNING] Unknown annotation on service method: skipped @org.springframework.context.annotation.Bean(name=[], initMethod=, destroyMethod=(inferred), autowire=NO, value=[])
[WARNING] Unknown annotation on service method: skipped @org.springframework.transaction.annotation.Transactional(propagation=REQUIRED, rollbackForClassName=[], readOnly=false, transactionManager=, isolation=DEFAULT, noRollbackFor=[], noRollbackForClassName=[], value=, timeout=-1, rollbackFor=[])
[WARNING] Unknown annotation on service method: skipped @org.springframework.transaction.annotation.Transactional(propagation=REQUIRED, rollbackForClassName=[], readOnly=true, transactionManager=, isolation=DEFAULT, noRollbackFor=[], noRollbackForClassName=[], value=, timeout=-1, rollbackFor=[])
[WARNING] Unknown annotation on service method: skipped @org.springframework.transaction.annotation.Transactional(propagation=REQUIRED, rollbackForClassName=[], readOnly=true, transactionManager=, isolation=DEFAULT, noRollbackFor=[], noRollbackForClassName=[], value=, timeout=-1, rollbackFor=[])
[WARNING] Unknown annotation on service method: skipped @org.springframework.transaction.annotation.Transactional(propagation=REQUIRED, rollbackForClassName=[], readOnly=false, transactionManager=, isolation=DEFAULT, noRollbackFor=[], noRollbackForClassName=[], value=, timeout=-1, rollbackFor=[])
[WARNING] Unknown annotation on service method: skipped @org.springframework.transaction.annotation.Transactional(propagation=REQUIRED, rollbackForClassName=[], readOnly=false, transactionManager=, isolation=DEFAULT, noRollbackFor=[], noRollbackForClassName=[], value=, timeout=-1, rollbackFor=[])
[WARNING] Unknown annotation on service method: skipped @org.springframework.transaction.annotation.Transactional(propagation=REQUIRED, rollbackForClassName=[], readOnly=false, transactionManager=, isolation=DEFAULT, noRollbackFor=[], noRollbackForClassName=[], value=, timeout=-1, rollbackFor=[])
[WARNING] Unknown annotation on service method: skipped @javax.transaction.Transactional(value=REQUIRED, rollbackOn=[], dontRollbackOn=[])
[WARNING] Unknown annotation on service method: skipped @javax.annotation.PostConstruct()
[WARNING] Unknown annotation on service method: skipped @javax.transaction.Transactional(value=REQUIRED, rollbackOn=[], dontRollbackOn=[])
[WARNING] Unknown annotation on service method: skipped @javax.transaction.Transactional(value=REQUIRED, rollbackOn=[], dontRollbackOn=[])
[WARNING] Unknown annotation on service method: skipped @javax.transaction.Transactional(value=REQUIRED, rollbackOn=[], dontRollbackOn=[])
[WARNING] Unknown annotation on service method: skipped @javax.transaction.Transactional(value=REQUIRED, rollbackOn=[], dontRollbackOn=[])
[WARNING] Unknown annotation on service method: skipped @javax.transaction.Transactional(value=REQUIRED, rollbackOn=[], dontRollbackOn=[])
[WARNING] Unknown annotation on service method: skipped @javax.transaction.Transactional(value=REQUIRED, rollbackOn=[class java.lang.Exception], dontRollbackOn=[class org.springframework.dao.EmptyResultDataAccessException])
[WARNING] Unknown annotation on service method: skipped @javax.annotation.PostConstruct()
[INFO] Built.
[INFO] Reading javadoc comments from sourcefiles...
[INFO] Read.
[INFO] Merging reflective and javadoc models...
[WARNING] Limited support for jdk8 (@link, @see, @linkplain javadoc tags won't format properly)
[INFO] Merged.
[INFO] Performing issue analysis...
[INFO] Analysis done.
[INFO] Constructing Html documentation
[WARNING] Could not find html intro file file: miredot.htmlintro.html
[INFO] MireDot: Completed
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 30.126 s
[INFO] Finished at: 2017-12-07T09:47:47-08:00
[INFO] Final Memory: 60M/176M
[INFO] ------------------------------------------------------------------------

Hi @kaiwpost - based on the error, a connection is being refused when attempting to the DB:

Caused by: org.postgresql.util.PSQLException: Connection to 54.209.111.128:5432 refused.

It could be the case that your stand-along Java application is connecting to the DB using the loopback address (127.0.0.1) while Tomcat is attempting to resolve localhost against the system resources thus resulting in a different IP for the connection (54.209.111.128). You might want to see if you have any luck by changing your settings from:

jdbc:postgresql://localhost:5432/OHDSI

to:

jdbc:postgresql://127.0.0.1:5432/OHDSI

If that doesn’t work, you may need to look at how to enable the communication with PostgreSQL over the machine IP instead of the loopback address. I’m not as familiar with Linux configuration so I don’t have any suggestions on where to start at the moment. Let us know if this helps.

Hi @anthonysena - thanks for the tip, it nudged me a little closer to a solution. 54.209.111.128 is the IP used for the weapi-postgresql configuration in the application’s pom.xml file. I am at a loss why it’s not overridden by the IP in my settings.xml file, but when I replace the properties in pom.xml with those of settings.xml it seems to deploy. I understand that’s not what I want to do in a production environment, but at least I have a little more understanding of it right now. Really appreciate your quick help. Cheers, Kai

t