[fixed]Docker error (http 500, postgres version)

start docker with postgres version,but get http 500 error when try to access web page.
Root Cause
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver

error log: xwiki-error.log (33.3 KB)

steps:

  1. docker network create -d bridge xwiki-nw --subnet=10.0.2.0/24
  2. docker run --net=xwiki-nw --name postgres-xwiki --ip 10.0.2.2 -p 7432:5432 -m 512m -e POSTGRES_PASSWORD=my-password -v /usr/var/xwiki/postgres:/var/lib/postgresql/data -d postgres:10-alpine
  3. manually create user & db in postgres

    CREATE DATABASE xwiki
    WITH
    OWNER = xwiki
    ENCODING = ‘UTF8’
    LC_COLLATE = ‘en_US.utf8’
    LC_CTYPE = ‘en_US.utf8’
    TABLESPACE = pg_default
    CONNECTION LIMIT = -1;
  4. docker run --net=xwiki-nw --name xwiki -d --ip 10.0.2.3 -p 80:8080 -v /usr/var/xwiki/xwiki-data:/usr/local/xwiki -e DB_USER=xwiki -e DB_PASSWORD=my-password2 -e DB_DATABASE=xwiki -e DB_HOST=postgres-xwiki xwiki:stable-postgres-tomcat

Hi. I’ve tried to reproduce your problem on postgresql with both xwiki:stable-postgres-tomcat and xwiki:lts-postgres-tomcat and couldn’t.

I started XWiki using the command lines defined in xwiki-docker/README.md at master · xwiki/xwiki-docker · GitHub

IMO you simply had some existing hibernate.cfg.xml file in your xwiki permanent directory at /usr/var/xwiki/xwiki-data which points to a MySQL DB. You probably tried with MySQL first and then tried with postgresql after without updating the hibernate file. When you don’t have this file, it’s copied from the container to the permanent directory but if it exists it’s not copied (since you may have made changes that need to be kept).

yes, my bad, at first downloaded mysql version incorrectly. forget to delete home folder.
now is ok, thank you.