Uploaded image for project: 'XWiki Docker images'
  1. XWiki Docker images
  2. XDOCKER-242

Error with image 14.4-postgres-tomcat

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • Major
    • None
    • Unknown
    • N/A
    • N/A

    Description

      I tried to use the image of XWiki with Postgres.

      There are my docker-compose.yaml file:

       

      version: "3"
      ##
      # stack services definitions:
      ##
      services:
        # the service of the XWiki on Tomcat:
        xwiki:
          image: "${XWIKI_DOCKER_IMAGE}"
          container_name: "${XWIKI_CONTAINER_NAME}"
          ports:
            - "${XWIKI_HOST_NETWORK}:${XWIKI_HOST_PORT}:8080"
          env_file: .env
          environment:
           - DB_HOST=${DATABASE_CONTAINER_NAME}
           - DB_DATABASE=${DATABASE_NAME}
           - DB_USER=${DATABASE_USER}
           - DB_PASSWORD=${DATABASE_PASSWORD}
          volumes:
            - xwiki-data:/usr/local/xwiki
          depends_on:
            - database
          restart: always
          networks:
            - public
            - private
        # the service of the PostgreSQL database for XWiki on an internal network:
        database:
          image: "${DATABASE_DOCKER_IMAGE}"
          container_name: "${DATABASE_CONTAINER_NAME}"
          env_file: .env
          environment:
            - POSTGRES_DB=${DATABASE_NAME}
            - POSTGRES_USER=${DATABASE_USER}
            - POSTGRES_PASSWORD=${DATABASE_PASSWORD}
            - POSTGRES_INITDB_ARGS="${DATABASE_INITDB_ARG}"
            #- POSTGRES_ROOT_PASSWORD=${DATABASE_ROOT_PASSWORD}
            #- POSTGRES_ROOT_PASSWORD=${POSTGRES_ROOT_PASSWORD}
            #- POSTGRES_PASSWORD=${DB_PASSWORD}
            #- POSTGRES_USER=${DB_USER}
            #- POSTGRES_DB=${DB_DATABASE}
            #- POSTGRES_INITDB_ARGS="--encoding=UTF8"
          volumes:
            - postgres-data:/var/lib/postgresql/data
          restart: always
          # healthcheck:
          #   test: ["CMD", "/usr/bin/healthcheck"]
          #   interval: 30s
          #   timeout: 10s
          #   retries: 5
          networks:
            - private
      ##
      # stack volumes definitions:
      ##
      volumes:
        postgres-data: {}
        xwiki-data: {}
      ##
      # stack networks definition:
      # @see https://docs.docker.com/compose/compose-file/#network-configuration-reference
      # @see https://docs.docker.com/compose/compose-file/#internal
      ##
      networks:
        public:
          internal: false
        private:
          internal: true
      

       

      My .env file

       

      #!/usr/bin/env
      
      #### xwiki params
      XWIKI_DOCKER_IMAGE=xwiki:14.4-postgres-tomcat
      XWIKI_CONTAINER_NAME=xwiki-postgres-tomcat-container
      XWIKI_HOST_NETWORK=0.0.0.0
      XWIKI_HOST_PORT=11080
      ### pgAdmin params (optional, only if you use it)
      #### pgAdmin environment variables
      PGADMIN_IMAGE=dpage/pgadmin4
      PGADMIN_CONTAINER_NAME=xwiki-pgadmin-container
      PGADMIN_HOST_NETWORK=0.0.0.0
      PGADMIN_HOST_PORT=11180
      PGADMIN_USER_DEFAULT_EMAIL=XXXXX
      PGADMIN_USER_DEFAULT_PASSWORD=XXXXXXXXXX
      ### database params
      DATABASE_DOCKER_IMAGE=postgres:13
      DATABASE_CONTAINER_NAME=xwiki-postgres-db-container
      #DATABASE_ROOT_PASSWORD=742pAU8Kfht5kPXd54DLFS9jvmAdEvCg
      DATABASE_NAME=xwikidb
      DATABASE_USER=xwikiuser
      DATABASE_PASSWORD=xwikipass
      DATABASE_INITDB_ARG=--encoding=UTF8

       

       

       

       

      I added a pgAdmin to ensure that the database is created and i can access it with the DATABASE_USER and DATABASE_PASSWORD defined.

       

      You can see in this screenshot that i can:

       

      And there aren't any table.

       

      In the log of the docker container, i have multiple messages like this:

      xwiki-postgres-tomcat-container  | 2022-07-17 19:01:47,871 [XWiki initialization] ERROR c.x.x.i.s.h.HibernateStore     - Error executing DDL "create index EVENT_PRIORITY on xwikidb.activitystream_events (ase_priority)" via JDBC Statementxwiki-postgres-tomcat-container  | 2022-07-17 19:01:47,871 [XWiki initialization] ERROR c.x.x.i.s.h.HibernateStore     - Error executing DDL "create index EVENT_PRIORITY on xwikidb.activitystream_events (ase_priority)" via JDBC Statementxwiki-postgres-tomcat-container  | org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL "create index EVENT_PRIORITY on xwikidb.activitystream_events (ase_priority)" via JDBC Statementxwiki-postgres-tomcat-container  | at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:67)xwiki-postgres-tomcat-container  | at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.applySqlString(AbstractSchemaMigrator.java:581)xwiki-postgres-tomcat-container  | at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.applySqlStrings(AbstractSchemaMigrator.java:526)xwiki-postgres-tomcat-container  | at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.applyIndexes(AbstractSchemaMigrator.java:348)xwiki-postgres-tomcat-container  | at org.hibernate.tool.schema.internal.GroupedSchemaMigratorImpl.performTablesMigration(GroupedSchemaMigratorImpl.java:88)xwiki-postgres-tomcat-container  | at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.performMigration(AbstractSchemaMigrator.java:220)xwiki-postgres-tomcat-container  | at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.doMigration(AbstractSchemaMigrator.java:123)xwiki-postgres-tomcat-container  | at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:94)xwiki-postgres-tomcat-container  | at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:63)xwiki-postgres-tomcat-container  | at com.xpn.xwiki.internal.store.hibernate.HibernateStore.updateDatabase(HibernateStore.java:1137)xwiki-postgres-tomcat-container  | at com.xpn.xwiki.internal.store.hibernate.HibernateStore.updateDatabase(HibernateStore.java:1004)xwiki-postgres-tomcat-container  | at com.xpn.xwiki.internal.store.hibernate.HibernateStore.updateDatabase(HibernateStore.java:1171)xwiki-postgres-tomcat-container  | at com.xpn.xwiki.store.XWikiHibernateBaseStore.updateSchema(XWikiHibernateBaseStore.java:264)xwiki-postgres-tomcat-container  | at com.xpn.xwiki.store.migration.hibernate.HibernateDataMigrationManager.hibernateShemaUpdate(HibernateDataMigrationManager.java:208)xwiki-postgres-tomcat-container  | at com.xpn.xwiki.store.migration.hibernate.HibernateDataMigrationManager.updateSchema(HibernateDataMigrationManager.java:189)xwiki-postgres-tomcat-container  | at com.xpn.xwiki.store.migration.hibernate.HibernateDataMigrationManager.initializeEmptyDB(HibernateDataMigrationManager.java:158)xwiki-postgres-tomcat-container  | at com.xpn.xwiki.store.migration.AbstractDataMigrationManager.initNewDB(AbstractDataMigrationManager.java:446)xwiki-postgres-tomcat-container  | at com.xpn.xwiki.store.migration.AbstractDataMigrationManager.initializeCurrentDatabase(AbstractDataMigrationManager.java:551)xwiki-postgres-tomcat-container  | at com.xpn.xwiki.store.migration.AbstractDataMigrationManager.checkDatabase(AbstractDataMigrationManager.java:534)xwiki-postgres-tomcat-container  | at com.xpn.xwiki.internal.store.hibernate.HibernateStore.setWiki(HibernateStore.java:704)xwiki-postgres-tomcat-container  | at com.xpn.xwiki.internal.store.hibernate.HibernateStore.setWiki(HibernateStore.java:663)xwiki-postgres-tomcat-container  | at com.xpn.xwiki.internal.store.hibernate.HibernateStore.beginTransaction(HibernateStore.java:865)xwiki-postgres-tomcat-container  | at com.xpn.xwiki.store.XWikiHibernateBaseStore.beginTransaction(XWikiHibernateBaseStore.java:576)xwiki-postgres-tomcat-container  | at com.xpn.xwiki.store.XWikiHibernateStore.loadXWikiDoc(XWikiHibernateStore.java:1024)xwiki-postgres-tomcat-container  | at com.xpn.xwiki.store.XWikiCacheStore.loadXWikiDoc(XWikiCacheStore.java:395)xwiki-postgres-tomcat-container  | at com.xpn.xwiki.XWiki.getDocument(XWiki.java:2164)xwiki-postgres-tomcat-container  | at com.xpn.xwiki.XWiki.getDocument(XWiki.java:2226)xwiki-postgres-tomcat-container  | at com.xpn.xwiki.XWiki.initializeMandatoryDocument(XWiki.java:1439)xwiki-postgres-tomcat-container  | at com.xpn.xwiki.XWiki.initializeMandatoryDocuments(XWiki.java:1406)xwiki-postgres-tomcat-container  | at com.xpn.xwiki.XWiki.initXWiki(XWiki.java:1315)xwiki-postgres-tomcat-container  | at com.xpn.xwiki.XWiki.initXWiki(XWiki.java:1252)xwiki-postgres-tomcat-container  | at com.xpn.xwiki.XWiki.<init>(XWiki.java:1225)xwiki-postgres-tomcat-container  | at com.xpn.xwiki.internal.XWikiInitializerJob.runInternal(XWikiInitializerJob.java:117)xwiki-postgres-tomcat-container  | at org.xwiki.job.AbstractJob.runInContext(AbstractJob.java:243)xwiki-postgres-tomcat-container  | at org.xwiki.job.AbstractJob.run(AbstractJob.java:220)xwiki-postgres-tomcat-container  | at java.base/java.lang.Thread.run(Unknown Source)xwiki-postgres-tomcat-container  | Caused by: org.postgresql.util.PSQLException: ERROR: schema "xwikidb" does not existxwiki-postgres-tomcat-container  | at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2675)xwiki-postgres-tomcat-container  | at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2365)xwiki-postgres-tomcat-container  | at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:355)xwiki-postgres-tomcat-container  | at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:490)xwiki-postgres-tomcat-container  | at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:408)xwiki-postgres-tomcat-container  | at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:329)xwiki-postgres-tomcat-container  | at org.postgresql.jdbc.PgStatement.executeCachedSql(PgStatement.java:315)xwiki-postgres-tomcat-container  | at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:291)xwiki-postgres-tomcat-container  | at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:286)xwiki-postgres-tomcat-container  | at org.apache.commons.dbcp2.DelegatingStatement.execute(DelegatingStatement.java:193)xwiki-postgres-tomcat-container  | at org.apache.commons.dbcp2.DelegatingStatement.execute(DelegatingStatement.java:193)xwiki-postgres-tomcat-container  | at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:54)xwiki-postgres-tomcat-container  | ... 35 common frames omittedxwiki-postgres-tomcat-container  | 2022-07-17 19:01:47,871 [XWiki initialization] ERROR c.x.x.i.s.h.HibernateStore     - Error executing DDL "create index EVENT_TYPE on xwikidb.activitystream_events (ase_type)" via JDBC Statement
       
      

      and in the database container:

      xwiki-postgres-db-container      | 2022-07-17 19:01:57.712 UTC [72] ERROR:  schema "xwikidb" does not exist at character 14
      canceled

      In the hibernate.cfg.xml of the container (located in /usr/local/tomcat/webapps/ROOT/WEB-INF/hibernate.cfg.xml), i have: (generated by the docker-entrypoint.sh):

      <?xml version="1.0" encoding="UTF-8"?><!--
       * See the NOTICE file distributed with this work for additional
       * information regarding copyright ownership.
       *
       * This is free software; you can redistribute it and/or modify it
       * under the terms of the GNU Lesser General Public License as
       * published by the Free Software Foundation; either version 2.1 of
       * the License, or (at your option) any later version.
       *
       * This software is distributed in the hope that it will be useful,
       * but WITHOUT ANY WARRANTY; without even the implied warranty of
       * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
       * Lesser General Public License for more details.
       *
       * You should have received a copy of the GNU Lesser General Public
       * License along with this software; if not, write to the Free
       * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
       * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
      --><!DOCTYPE hibernate-configuration PUBLIC
        "-//Hibernate/Hibernate Configuration DTD//EN"
        "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
      <hibernate-configuration>
        <session-factory>    <!-- Please refer to the installation guide on
               https://www.xwiki.org/xwiki/bin/view/Documentation/AdminGuide/Installation/ for configuring your
               database. You'll need to do 2 things:
               1) Copy your database driver JAR in WEB-INF/lib or in some shared lib directory
               2) Uncomment the properties below for your specific DB (and comment the default
                  database configuration if it doesn't match your DB)
          -->    <!-- Generic parameters common to all Databases -->    <property name="show_sql">false</property>
          <property name="use_outer_join">true</property>    <!-- Without it, some queries fail in MS SQL. XWiki doesn't need scrollable result sets, anyway. -->
          <property name="jdbc.use_scrollable_resultset">false</property>    <!-- DBCP Connection Pooling configuration. Only some properties are shown. All available properties can be found
               at https://commons.apache.org/proper/commons-dbcp/configuration.html
          -->
          <property name="dbcp.defaultAutoCommit">false</property>
          <property name="dbcp.maxTotal">50</property>
          <property name="dbcp.maxIdle">5</property>
          <property name="dbcp.maxWaitMillis">30000</property>
          <property name="connection.provider_class">com.xpn.xwiki.store.DBCPConnectionProvider</property>
      
      <!-- Setting "dbcp.poolPreparedStatements" to true and "dbcp.maxOpenPreparedStatements" will tell DBCP to cache
               Prepared Statements (it's off by default). Note that for backward compatibility the "dbcp.ps.maxActive" is also
               supported and when set it'll set "dbcp.poolPreparedStatements" to true and "dbcp.maxOpenPreparedStatements" to
               value of "dbcp.ps.maxActive".         Note 1: When using HSQLDB for example, it's important to NOT cache prepared statements because HSQLDB
               Prepared Statements (PS) contain the schema on which they were initially created and thus when switching
               schema if the same PS is reused it'll execute on the wrong schema! Since HSQLDB does internally cache
               prepared statement there's no performance loss by not caching Prepared Statements at the DBCP level.
               See https://jira.xwiki.org/browse/XWIKI-1740.
               Thus we recommend not turning on this configuration for HSQLDB unless you know what you're doing :)         Note 2: The same applies to PostGreSQL.
          -->    <!-- BoneCP Connection Pooling configuration.
          <property name="bonecp.idleMaxAgeInMinutes">240</property>
          <property name="bonecp.idleConnectionTestPeriodInMinutes">60</property>
          <property name="bonecp.partitionCount">3</property>
          <property name="bonecp.acquireIncrement">10</property>
          <property name="bonecp.maxConnectionsPerPartition">60</property>
          <property name="bonecp.minConnectionsPerPartition">20</property>
          <property name="bonecp.statementsCacheSize">50</property>
          <property name="bonecp.releaseHelperThreads">3</property>
          <property name="connection.provider_class">com.xpn.xwiki.store.DBCPConnectionProvider</property>
          -->    <!-- PostgreSQL configuration.
               Notes:
                 - "jdbc.use_streams_for_binary" needs to be set to "false",
                   see https://community.jboss.org/wiki/HibernateCoreMigrationGuide36
                 - "xwiki.virtual_mode" can be set to either "schema" or "database". Note that currently the database mode
                   doesn't support database creation (see https://jira.xwiki.org/browse/XWIKI-8753)
                 - if you want the main wiki database to be different than "xwiki" (or "public" in schema mode)
                   you will also have to set the property xwiki.db in xwiki.cfg file
          -->
          <property name="connection.url">jdbc:postgresql://xwiki-postgres-db-container:5432/xwikidb</property>
          <property name="connection.username">xwikiuser</property>
          <property name="connection.password">xwikipass</property>
          <property name="connection.driver_class">org.postgresql.Driver</property>
          <property name="jdbc.use_streams_for_binary">false</property>
      <property name="xwiki.virtual_mode">schema</property>
          <property name="hibernate.connection.charSet">UTF-8</property>
          <property name="hibernate.connection.useUnicode">true</property>
          <property name="hibernate.connection.characterEncoding">utf8</property>          <mapping resource="xwiki.postgresql.hbm.xml"/>
          <mapping resource="feeds.hbm.xml"/>
          <mapping resource="instance.hbm.xml"/>
          <mapping resource="notification-filter-preferences.hbm.xml"/>
          <mapping resource="mailsender.hbm.xml"/>
        </session-factory>
      </hibernate-configuration>

      In the same directory, on the xwiki.cfg (i put only the parameter of the database):

       

      #-# [Since 1.6M1]
      #-# Force the database name for the main wiki.
      xwiki.db=xwikidb
      
      
      

      I'm not an expert on Java ecosystem; but may be the parameter:

      <property name="xwiki.virtual_mode">schema</property>

      It's no ok for PostgreSQL, i don't know.

       

      If you put xwiki as database name, database user, and database password, the image works right; but it's obvious that the image (or the posgresql connection code) have any bug.

       

      If you need more info, please write me and i give you the requested info.

       

      Regards.

      Attachments

        Issue Links

          Activity

            People

              surli Simon Urli
              joserprieto Jose R. Prieto
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: