arnaugarcia / sallefy

Sallefy - A music platform
https://www.jhipster.tech/development/
GNU General Public License v3.0
11 stars 8 forks source link

User Service Can Not Acquire Db Connection #130

Open GvozdenMiskovic opened 4 years ago

GvozdenMiskovic commented 4 years ago

User Service throws com.mysql.cj.exceptions.WrongArgumentException on call to registerUser likely due to a failure by the UserRepository to connect to mysql db.

2020-02-27 20:34:20.750 WARN 17745 --- [ restartedMain] o.h.e.j.e.i.JdbcEnvironmentInitiator : HHH000342: Could not obtain connection to query metadata : Cannot load connection class because of underlying exception: com.mysql.cj.exceptions.WrongArgumentException: Failed to parse the host:port pair '${SALLEFY_DB_HOST}:${SALLEFY_DB_PORT}'.

Following the instructions provided mysql server is running inside a docker container. Perhaps specifying SALLEFY_DB_HOST and SALLEFY_DB_PORT to the correct ip and port for the docker container may work but I have not found where to do so.

This cause a failure to register on the website. Both the node web server and the api are running locally.

Version Info

Node v12.16.1 MySQL as per docker image specified in src/main/docker/mysql.yml openjdk version "11.0.6" 2020-01-14 OpenJDK Runtime Environment (build 11.0.6+10-post-Ubuntu-1ubuntu118.04.1) OpenJDK 64-Bit Server VM (build 11.0.6+10-post-Ubuntu-1ubuntu118.04.1, mixed mode, sharing)

OS Info

NAME="elementary OS" VERSION="5.1 Hera" ID=elementary ID_LIKE=ubuntu PRETTY_NAME="elementary OS 5.1 Hera" LOGO=distributor-logo VERSION_ID="5.1" UBUNTU_CODENAME=bionic

GvozdenMiskovic commented 4 years ago

SpringBoot configuration .yml files expect the following environment variables to be set:

SALLEFY_DB_PORT SALLEFY_DB_HOST SALLEFY_DB_USER SALLEFY_DB_PASSWORD

However, when launching the app from Docker container, defining the variables in the container instantiation environment does not transfer these vars to the container, only those vars directly substituted into a string are set to a correct value.

E.g. with SALLEFY_DB_HOST and SALLEFY_DB_PORT set the previous error does not occur, but Db connection still fails however, with the an authentication error for ${SALLEFY_DB_USER}@'host'

It seems that SALLEFY_DB_USER and SALLEFY_DB_PASSWORD are not being transferred to the user and password fields of SpringBoot datasource configuration.

Quick and Dirty Fix

Define all above mentioned env variables in app.xml.

arnaugarcia commented 4 years ago

Hi @GvozdenMiskovic sorry for answering too late. Yes in order to start the application you'll need to set the enviornment variables to your container.