Hi,
I have 2 dockers: openjdk with mysql. I am able to run mysql -h mysql57 -u root -p
from the openjdk successfully.
when running the docker-compose I am getting:
web_1 | ERROR: Cannot check and update database. See the stacktrace below for details.
web_1 | Caused by: com.haulmont.cuba.core.sys.DbInitializationException: Error connecting to database: Cannot create PoolableConnectionFactory (Communications link failure
web_1 | The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.)
web_1 | Caused by: java.sql.SQLException: Cannot create PoolableConnectionFactory (Communications link failure
(full error: JustPaste.it - Share Text & Images the Easy Way)
I have the following jetty config:
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-" "http://www.eclipse.org/jetty/configure_9_0.dtd">
<Configure id='wac' class="org.eclipse.jetty.webapp.WebAppContext">
<New id="CubaDS" class="org.eclipse.jetty.plus.jndi.Resource">
<Arg/>
<Arg>jdbc/CubaDS</Arg>
<Arg>
<New class="org.apache.commons.dbcp2.BasicDataSource">
<Set name="driverClassName">com.mysql.jdbc.Driver</Set>
<Set name="url">jdbc:mysql://mysql57/crmdev?useSSL=false&allowMultiQueries=true&serverTimezone=UTC&allowPublicKeyRetrieval=true</Set>
<Set name="username">root</Set>
<Set name="password">rootPassword</Set>
<Set name="maxIdle">2</Set>
<Set name="maxTotal">20</Set>
<Set name="maxWaitMillis">5000</Set>
</New>
</Arg>
</New>
</Configure>
buildUber:
task buildUberJar(type: CubaUberJarBuilding) {
singleJar = true
coreJettyEnvPath = 'modules/core/web/META-INF/jetty-env.xml'
appProperties = ['cuba.automaticDatabaseUpdate' : true]
}
docker compose:
version: '2'
services:
mysql57:
image: mysql:5.7
restart: unless-stopped
container_name: mysql57
ports:
- "3357:3306"
environment:
MYSQL_ROOT_PASSWORD: rootPassword
MYSQL_DATABASE: crmdev
web:
build: .
ports:
- "8080:8080"
links:
- mysql57
(I just deployed the jar, I assume the env file is wrapped inside).
UPDATE
I have configured a new database in a remote machine, and still its not working, same error.
Here is a repository with the docker folder GitHub - avifatal/cuba-docker just run gradle build uber and copy the file to docker dir. docker-compose up
Thanks