Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automate deployment of postgres database schema #3

Open
bakhansen opened this issue Apr 5, 2018 · 0 comments
Open

Automate deployment of postgres database schema #3

bakhansen opened this issue Apr 5, 2018 · 0 comments
Labels

Comments

@bakhansen
Copy link
Member

bakhansen commented Apr 5, 2018

Steps to reproduce:

(...)
web-ds_1  | Apr 5, 2018 4:14:11 PM org.hibernate.cfg.annotations.Version <clinit>
web-ds_1  | INFO: Hibernate Annotations 3.3.0.GA
web-ds_1  | Apr 5, 2018 4:14:11 PM org.hibernate.cfg.Environment <clinit>
web-ds_1  | INFO: Hibernate 3.2.1
web-ds_1  | Apr 5, 2018 4:14:11 PM org.hibernate.cfg.Environment <clinit>
web-ds_1  | INFO: hibernate.properties not found
web-ds_1  | Apr 5, 2018 4:14:11 PM org.hibernate.cfg.Environment buildBytecodeProvider
web-ds_1  | INFO: Bytecode provider name : cglib
web-ds_1  | Apr 5, 2018 4:14:11 PM org.hibernate.cfg.Environment <clinit>
web-ds_1  | INFO: using JDK 1.4 java.sql.Timestamp handling
web-ds_1  | Apr 5, 2018 4:14:11 PM org.hibernate.cfg.Configuration configure
web-ds_1  | INFO: configuring from resource: /hibernate.cfg.xml
web-ds_1  | Apr 5, 2018 4:14:11 PM org.hibernate.cfg.Configuration getConfigurationInputStream
web-ds_1  | INFO: Configuration resource: /hibernate.cfg.xml
web-ds_1  | Apr 5, 2018 4:14:12 PM org.hibernate.cfg.Configuration addResource
web-ds_1  | INFO: Reading mappings from resource : Access.hbm.xml
web-ds_1  | Apr 5, 2018 4:14:12 PM org.hibernate.cfg.Configuration doConfigure
web-ds_1  | INFO: Configured SessionFactory: null
web-ds_1  | Apr 5, 2018 4:14:12 PM org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
web-ds_1  | INFO: Mapping class: org.b3mn.poem.Access -> access
web-ds_1  | Apr 5, 2018 4:14:12 PM org.hibernate.cfg.AnnotationBinder bindClass
web-ds_1  | INFO: Binding entity from annotated class: org.b3mn.poem.Identity
web-ds_1  | Apr 5, 2018 4:14:12 PM org.hibernate.cfg.annotations.EntityBinder bindTable
web-ds_1  | INFO: Bind entity org.b3mn.poem.Identity on table Identity
web-ds_1  | Apr 5, 2018 4:14:12 PM org.hibernate.cfg.AnnotationBinder bindClass
web-ds_1  | INFO: Binding entity from annotated class: org.b3mn.poem.Representation
web-ds_1  | Apr 5, 2018 4:14:12 PM org.hibernate.cfg.annotations.EntityBinder bindTable
web-ds_1  | INFO: Bind entity org.b3mn.poem.Representation on table Representation
web-ds_1  | Apr 5, 2018 4:14:12 PM org.hibernate.cfg.AnnotationBinder bindClass
web-ds_1  | INFO: Binding entity from annotated class: org.b3mn.poem.Plugin
web-ds_1  | Apr 5, 2018 4:14:12 PM org.hibernate.cfg.annotations.EntityBinder bindTable
web-ds_1  | INFO: Bind entity org.b3mn.poem.Plugin on table Plugin
web-ds_1  | Apr 5, 2018 4:14:12 PM org.hibernate.cfg.AnnotationBinder bindClass
web-ds_1  | INFO: Binding entity from annotated class: org.b3mn.poem.Interaction
web-ds_1  | Apr 5, 2018 4:14:12 PM org.hibernate.cfg.annotations.EntityBinder bindTable
web-ds_1  | INFO: Bind entity org.b3mn.poem.Interaction on table Interaction
web-ds_1  | Apr 5, 2018 4:14:12 PM org.hibernate.cfg.AnnotationBinder bindClass
web-ds_1  | INFO: Binding entity from annotated class: org.b3mn.poem.Structure
web-ds_1  | Apr 5, 2018 4:14:12 PM org.hibernate.cfg.annotations.EntityBinder bindTable
web-ds_1  | INFO: Bind entity org.b3mn.poem.Structure on table Structure
web-ds_1  | Apr 5, 2018 4:14:12 PM org.hibernate.cfg.AnnotationBinder bindClass
web-ds_1  | INFO: Binding entity from annotated class: org.b3mn.poem.Subject
web-ds_1  | Apr 5, 2018 4:14:12 PM org.hibernate.cfg.annotations.EntityBinder bindTable
web-ds_1  | INFO: Bind entity org.b3mn.poem.Subject on table subject
web-ds_1  | Apr 5, 2018 4:14:12 PM org.hibernate.cfg.AnnotationBinder bindClass
web-ds_1  | INFO: Binding entity from annotated class: org.b3mn.poem.Setting
web-ds_1  | Apr 5, 2018 4:14:12 PM org.hibernate.cfg.annotations.EntityBinder bindTable
web-ds_1  | INFO: Bind entity org.b3mn.poem.Setting on table Setting
web-ds_1  | Apr 5, 2018 4:14:12 PM org.hibernate.cfg.AnnotationBinder bindClass
web-ds_1  | INFO: Binding entity from annotated class: org.b3mn.poem.TagDefinition
web-ds_1  | Apr 5, 2018 4:14:12 PM org.hibernate.cfg.annotations.EntityBinder bindTable
web-ds_1  | INFO: Bind entity org.b3mn.poem.TagDefinition on table tag_definition
web-ds_1  | Apr 5, 2018 4:14:12 PM org.hibernate.cfg.AnnotationBinder bindClass
web-ds_1  | INFO: Binding entity from annotated class: org.b3mn.poem.TagRelation
web-ds_1  | Apr 5, 2018 4:14:12 PM org.hibernate.cfg.annotations.EntityBinder bindTable
web-ds_1  | INFO: Bind entity org.b3mn.poem.TagRelation on table tag_relation
web-ds_1  | Apr 5, 2018 4:14:12 PM org.hibernate.cfg.AnnotationBinder bindClass
web-ds_1  | INFO: Binding entity from annotated class: org.b3mn.poem.ModelRating
web-ds_1  | Apr 5, 2018 4:14:12 PM org.hibernate.cfg.annotations.EntityBinder bindTable
web-ds_1  | INFO: Bind entity org.b3mn.poem.ModelRating on table model_rating
web-ds_1  | Apr 5, 2018 4:14:12 PM org.hibernate.cfg.AnnotationBinder bindClass
web-ds_1  | INFO: Binding entity from annotated class: org.b3mn.poem.Friend
web-ds_1  | Apr 5, 2018 4:14:12 PM org.hibernate.cfg.annotations.EntityBinder bindTable
web-ds_1  | INFO: Bind entity org.b3mn.poem.Friend on table Friend
web-ds_1  | Apr 5, 2018 4:14:12 PM org.hibernate.cfg.AnnotationConfiguration secondPassCompile
web-ds_1  | INFO: Hibernate Validator not found: ignoring
web-ds_1  | Apr 5, 2018 4:14:12 PM org.hibernate.connection.DriverManagerConnectionProvider configure
web-ds_1  | INFO: Using Hibernate built-in connection pool (not for production use!)
web-ds_1  | Apr 5, 2018 4:14:12 PM org.hibernate.connection.DriverManagerConnectionProvider configure
web-ds_1  | INFO: Hibernate connection pool size: 20
web-ds_1  | Apr 5, 2018 4:14:12 PM org.hibernate.connection.DriverManagerConnectionProvider configure
web-ds_1  | INFO: autocommit mode: false
web-ds_1  | Apr 5, 2018 4:14:12 PM org.hibernate.connection.DriverManagerConnectionProvider configure
web-ds_1  | INFO: using driver: org.postgresql.Driver at URL: jdbc:postgresql://database/poem
web-ds_1  | Apr 5, 2018 4:14:12 PM org.hibernate.connection.DriverManagerConnectionProvider configure
web-ds_1  | INFO: connection properties: {user=poem, password=****}
web-ds_1  | Apr 5, 2018 4:14:12 PM org.hibernate.cfg.SettingsFactory buildSettings
web-ds_1  | INFO: RDBMS: PostgreSQL, version: 8.4.22
web-ds_1  | Apr 5, 2018 4:14:12 PM org.hibernate.cfg.SettingsFactory buildSettings
web-ds_1  | INFO: JDBC driver: PostgreSQL Native Driver, version: PostgreSQL 8.3 JDBC3 with SSL (build 603)
web-ds_1  | Apr 5, 2018 4:14:12 PM org.hibernate.dialect.Dialect <init>
web-ds_1  | INFO: Using dialect: org.hibernate.dialect.PostgreSQLDialect
web-ds_1  | Apr 5, 2018 4:14:12 PM org.hibernate.transaction.TransactionFactoryFactory buildTransactionFactory
web-ds_1  | INFO: Using default transaction strategy (direct JDBC transactions)
web-ds_1  | Apr 5, 2018 4:14:12 PM org.hibernate.transaction.TransactionManagerLookupFactory getTransactionManagerLookup
web-ds_1  | INFO: No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
web-ds_1  | Apr 5, 2018 4:14:12 PM org.hibernate.cfg.SettingsFactory buildSettings
web-ds_1  | INFO: Automatic flush during beforeCompletion(): disabled
web-ds_1  | Apr 5, 2018 4:14:12 PM org.hibernate.cfg.SettingsFactory buildSettings
web-ds_1  | INFO: Automatic session close at end of transaction: disabled
web-ds_1  | Apr 5, 2018 4:14:12 PM org.hibernate.cfg.SettingsFactory buildSettings
web-ds_1  | INFO: JDBC batch size: 15
web-ds_1  | Apr 5, 2018 4:14:12 PM org.hibernate.cfg.SettingsFactory buildSettings
web-ds_1  | INFO: JDBC batch updates for versioned data: disabled
web-ds_1  | Apr 5, 2018 4:14:12 PM org.hibernate.cfg.SettingsFactory buildSettings
web-ds_1  | INFO: Scrollable result sets: enabled
web-ds_1  | Apr 5, 2018 4:14:12 PM org.hibernate.cfg.SettingsFactory buildSettings
web-ds_1  | INFO: JDBC3 getGeneratedKeys(): disabled
web-ds_1  | Apr 5, 2018 4:14:12 PM org.hibernate.cfg.SettingsFactory buildSettings
web-ds_1  | INFO: Connection release mode: auto
web-ds_1  | Apr 5, 2018 4:14:12 PM org.hibernate.cfg.SettingsFactory buildSettings
web-ds_1  | INFO: Default batch fetch size: 1
web-ds_1  | Apr 5, 2018 4:14:12 PM org.hibernate.cfg.SettingsFactory buildSettings
web-ds_1  | INFO: Generate SQL with comments: disabled
web-ds_1  | Apr 5, 2018 4:14:12 PM org.hibernate.cfg.SettingsFactory buildSettings
web-ds_1  | INFO: Order SQL updates by primary key: disabled
web-ds_1  | Apr 5, 2018 4:14:12 PM org.hibernate.cfg.SettingsFactory createQueryTranslatorFactory
web-ds_1  | INFO: Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
web-ds_1  | Apr 5, 2018 4:14:12 PM org.hibernate.hql.ast.ASTQueryTranslatorFactory <init>
web-ds_1  | INFO: Using ASTQueryTranslatorFactory
web-ds_1  | Apr 5, 2018 4:14:12 PM org.hibernate.cfg.SettingsFactory buildSettings
web-ds_1  | INFO: Query language substitutions: {}
web-ds_1  | Apr 5, 2018 4:14:12 PM org.hibernate.cfg.SettingsFactory buildSettings
web-ds_1  | INFO: JPA-QL strict compliance: disabled
web-ds_1  | Apr 5, 2018 4:14:12 PM org.hibernate.cfg.SettingsFactory buildSettings
web-ds_1  | INFO: Second-level cache: enabled
web-ds_1  | Apr 5, 2018 4:14:12 PM org.hibernate.cfg.SettingsFactory buildSettings
web-ds_1  | INFO: Query cache: disabled
web-ds_1  | Apr 5, 2018 4:14:12 PM org.hibernate.cfg.SettingsFactory createCacheProvider
web-ds_1  | INFO: Cache provider: org.hibernate.cache.HashtableCacheProvider
web-ds_1  | Apr 5, 2018 4:14:12 PM org.hibernate.cfg.SettingsFactory buildSettings
web-ds_1  | INFO: Optimize cache for minimal puts: disabled
web-ds_1  | Apr 5, 2018 4:14:12 PM org.hibernate.cfg.SettingsFactory buildSettings
web-ds_1  | INFO: Structured second-level cache entries: disabled
web-ds_1  | Apr 5, 2018 4:14:12 PM org.hibernate.cfg.SettingsFactory buildSettings
web-ds_1  | INFO: Statistics: disabled
web-ds_1  | Apr 5, 2018 4:14:12 PM org.hibernate.cfg.SettingsFactory buildSettings
web-ds_1  | INFO: Deleted entity synthetic identifier rollback: disabled
web-ds_1  | Apr 5, 2018 4:14:12 PM org.hibernate.cfg.SettingsFactory buildSettings
web-ds_1  | INFO: Default entity-mode: pojo
web-ds_1  | Apr 5, 2018 4:14:12 PM org.hibernate.impl.SessionFactoryImpl <init>
web-ds_1  | INFO: building session factory
web-ds_1  | Apr 5, 2018 4:14:13 PM org.hibernate.impl.SessionFactoryObjectFactory addInstance
web-ds_1  | INFO: Not binding factory to JNDI, no JNDI name configured
db-ds_1   | ERROR:  relation "identity" does not exist at character 60
db-ds_1   | STATEMENT:  select identity.id as id1_0_, identity.uri as uri1_0_ FROM identity where uri=$1
web-ds_1  | Apr 5, 2018 4:14:13 PM org.hibernate.util.JDBCExceptionReporter logExceptions
web-ds_1  | WARNING: SQL Error: 0, SQLState: 42P01
web-ds_1  | Apr 5, 2018 4:14:13 PM org.hibernate.util.JDBCExceptionReporter logExceptions
web-ds_1  | SEVERE: ERROR: relation "identity" does not exist
web-ds_1  | java.lang.NullPointerException
web-ds_1  | 	at org.b3mn.poem.Dispatcher.dispatch(Dispatcher.java:374)
web-ds_1  | 	at org.b3mn.poem.Dispatcher.doGet(Dispatcher.java:404)
web-ds_1  | 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
web-ds_1  | 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
web-ds_1  | 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
web-ds_1  | 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
web-ds_1  | 	at org.b3mn.poem.security.filter.AuthenticationFilter.doFilter(AuthenticationFilter.java:155)
web-ds_1  | 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
web-ds_1  | 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
web-ds_1  | 	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
web-ds_1  | 	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
web-ds_1  | 	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
web-ds_1  | 	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
web-ds_1  | 	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
web-ds_1  | 	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
web-ds_1  | 	at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:876)
web-ds_1  | 	at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:618)
web-ds_1  | 	at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1790)
web-ds_1  | 	at java.lang.Thread.run(Thread.java:662)

Development in branch: docker-setup

Currently the postgres database is deployed via the web container by executing ant create-schema. But it would probably be useful to deploy it as part of docker-compose.

Docker image postgres:8.4 can run sh files in /docker-entrypoint-initdb.d/ as a part of the first run of docker-compose, but not sql files for instance. sql files are supported in more recent postgres docker images, but that would require ./poem-jvm/data/database/db_schema.sql to be (made) compatible.

The current workaround is to copy in ./poem-jvm/Dockerfile:

COPY data/database/db_schema.sh /docker-entrypoint-initdb.d/
COPY data/database/db_schema.sql /docker-entrypoint-initdb.d/

Where ./poem-jvm/data/database/db_schema.sh executes the following:

#!/bin/bash

gosu postgres postgres --single -jE < /docker-entrypoint-initdb.d/db_schema.sql
echo

It appears to be executed correctly using $ docker-compose -f docker-compose.yml up but the schema is not accessible when visiting http://localhost:9090/backend/poem/repository and requires further investigation/correction.

Related material:

@bakhansen bakhansen changed the title Automate deployment of postgres database Automate deployment of postgres database schema Apr 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant