retrievercommunications / docker-jasperserver

Docker image for the community edition of JasperReports® Server.
https://hub.docker.com/r/retriever/jasperserver/
MIT License
46 stars 50 forks source link

Can't create database 'jasperserver'; database exists #1

Closed FatmaBouchekoi closed 7 years ago

FatmaBouchekoi commented 8 years ago

I've used this Docker image of Jasperreports server. It works fine for the first time but when I down all containers and make them up jasperserver exit with code 1.

jasperserver | Caused by: org.mariadb.jdbc.internal.common.QueryException: Can't create database 'jasperserver'; database exists

I want to keep the old Database of Jasperreport server. Is there a solution to make Jasper use the old Database without recreating it?

grange74 commented 8 years ago

hi @FatmaBouchekoi, it is good to hear that someone else is using this container. i've tried reproducing your issue with both straight docker commands and docker-compose starting and stopping them several times but i can not get the same error as you.

Can you please provide more details on how to reproduce?

The only way i can think of this problem occurring is if you are creating the mysql/mariadb container, creating the jasperserver container and starting it up, letting it initialise, then stopping it, deleting the jasperserver container and then creating a new jasperserver container and linking it to the existing mariadb container. This scenario is not currently catered for. It is a valid scenario if there was a new version to the jasperserver container and you wanted to upgrade. To cater for this we'd have to look at changing the "entrypoint.sh" to not only check for the existence of the "$CATALINA_HOME/webapps/jasperserver" directory but also the existence of the jasperserver database before it does any bootstrapping.

jfuerwentsches commented 7 years ago

I encounter the same issue. I just cloned the repo and used docker compose up -d - when I docker-compose stop and then start it again.

fatmaBouchekoua commented 7 years ago

Hello, To keep the old Database and skip the error when creating a new one, I've just modified this line in entrypoint.sh file : ./js-ant create-js-db || true Sorry for answering too late !

grange74 commented 7 years ago

hi @jfuerwentsches, i just want to make sure that you are waiting long enough for the jasperserver container to fully initialise the first time. It does normally take quite a while, a few minutes even on a reasonably fast machine.

If you check the logs using docker-compose logs then you should see something like the following ouput: https://gist.github.com/grange74/df99f578cce25c7c673c2090bd62cf6f

grange74 commented 7 years ago

hi @FatmaBouchekoi, thanks for the response. i'm happy to accept a pull request :-)

fatmaBouchekoua commented 7 years ago

hi @grange74 , it would be better to search for another way to do this because my solution is not safe. In fact, even when there is a connection problem, i guess that the creation of the database will be skipped (first creation). This is a quick fix, think for another ;) Thanks..

grange74 commented 7 years ago

@FatmaBouchekoi i agree that the solution is not ideal but sometimes it is better to have a quick fix as an interim rather than waiting a long time for the perfect solution.