JHipster - Running liquibase:diff fails due to "Access denied" - mysql

When adding a field to an Entity in JHipster, the last step (when using MySQL) is running
./mvnw compile liquibase:diff
As per the docs at https://jhipster.github.io/development/
However, this doesn't work for my rather simple install, because the process doesn't use the correct MySQL user and pass. My app runs fine in dev profile, but not like this.
Where does Liquibase get its credentials from?
Below you can see the output.
[INFO] artifact: file:/Users/wouter/.m2/repository/org/glassfish/javax.el/3.0.0/javax.el-3.0.0.jar
[INFO] artifact: file:/Users/wouter/.m2/repository/org/springframework/boot/spring-boot-devtools/1.4.2.RELEASE/spring-boot-devtools-1.4.2.RELEASE.jar
[INFO] artifact: file:/Users/wouter/Business/Workspace/imi-publishing-cloud/target/classes/
[INFO] artifact: file:/Users/wouter/Business/Workspace/imi-publishing-cloud/target/test-classes/
[INFO] ------------------------------------------------------------------------
[INFO] Settings
----------------------------
[INFO] driver: com.mysql.jdbc.Driver
[INFO] url: jdbc:mysql://localhost:3306/imicloud
[INFO] username: root
[INFO] password: *****
[INFO] use empty password: false
[INFO] properties file: null
[INFO] properties file will override? false
[INFO] prompt on non-local database? true
[INFO] clear checksums? false
[INFO] changeLogFile: src/main/resources/config/liquibase/master.xml
[INFO] context(s): null
[INFO] label(s): null
[INFO] referenceDriver: null
[INFO] referenceUrl: hibernate:spring:be.storefront.imicloud.domain?dialect=org.hibernate.dialect.MySQL5InnoDBDialect&hibernate.physical_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy&hibernate.implicit_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy
[INFO] referenceUsername: null
[INFO] referencePassword: null
[INFO] referenceDefaultSchema: null
[INFO] diffChangeLogFile: src/main/resources/config/liquibase/changelog/20170125143850_changelog.xml
[INFO] ------------------------------------------------------------------------
Wed Jan 25 15:38:57 CET 2017 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7.129 s
[INFO] Finished at: 2017-01-25T15:38:58+01:00
[INFO] Final Memory: 63M/787M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.liquibase:liquibase-maven-plugin:3.5.3:diff (default-cli) on project imicloud: Error setting up or running Liquibase: liquibase.exception.DatabaseException: java.sql.SQLException: Access denied for user 'root'#'localhost' (using password: NO) -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
It first appears the correct settings are used. My DB is called "imicloud", but then later the error is:
java.sql.SQLException: Access denied for user 'root'#'localhost' (using password: NO)
Obviously I am using a password for MySQL.
How to fix this?
I guess I missed an essential setup step as this is the first time I'm using the liquibase:diff command.

The credentials used by the mvn liquibase commands are found in you pom.xml, in the liquibase plugin's configuration tag. The section of the pom.xml looks like:
<plugin>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-maven-plugin</artifactId>
<version>${liquibase.version}</version>
<configuration>
<changeLogFile>src/main/resources/config/liquibase/master.xml</changeLogFile>
<diffChangeLogFile>src/main/resources/config/liquibase/changelog/${maven.build.timestamp}_changelog.xml</diffChangeLogFile>
<driver>com.mysql.jdbc.Driver</driver>
<url>jdbc:mysql://localhost:3306/ng2</url>
<defaultSchemaName>ng2</defaultSchemaName>
<username>root</username>
<password></password>
<referenceUrl>hibernate:spring:com.mycompany.myapp.domain?dialect=org.hibernate.dialect.MySQL5InnoDBDialect&hibernate.physical_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy&hibernate.implicit_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy</referenceUrl>
<verbose>true</verbose>
<logging>debug</logging>
</configuration>
...

Configure your Spring Boot properties accordingly in your src/main/resources/config/application-.yml or application-.properties files
Add end with your database URL like this.
url: jdbc:mysql://localhost:3306/imicloud?u‌​seSSL=false

Related

DBGp proxy error Handler response error: Error reading command: Don't understand command '[507]'

Remote debugging using Xdebug DBGp proxy and PhpStorm:
Ubuntu 22.10
PHP 8.1
Xdebug v3.1.2
Xdebug DBGp proxy (0.4.2-dev)
./dbgpProxy
Xdebug DBGp proxy (0.4.2-dev)
Copyright 2020 by Derick Rethans
2023-02-13 07:16:48.394 [warn] [SSL] The 'certs/fullchain.pem' file could not be found, not enabling SSL listeners
2023-02-13 07:16:48.394 [info] [dbgpProxy] Proxy started
2023-02-13 07:16:48.395 [info] [server] Started server server on 127.0.0.1:9003
2023-02-13 07:16:48.395 [info] [server] Started client server on 127.0.0.1:9001
Xdebug settings:
zend_extension=xdebug.so
xdebug.mode=debug
xdebug.client_host=127.0.0.1
xdebug.client_port=9003
xdebug.log=/tmp/xdebug.log
SSH settings:
RemoteForward 9001 localhost:9001
LocalForward 9001 localhost:9001
Tools -> DBGp proxy -> Register IDE
2023-02-13 07:17:08.768 [info] [server] Start new client connection from 127.0.0.1:33682
2023-02-13 07:17:08.839 [info] [proxyinit] [POLYANIN] Added connection for IDE Key 'POLYANIN': 127.0.0.1:9001
2023-02-13 07:17:08.840 [info] [server] Closing client connection from 127.0.0.1:33682
The error:
2023-02-13 07:28:18.141 [info] [proxy-client] [POLYANIN] Found connection for IDE Key 'POLYANIN': 127.0.0.1:9001
2023-02-13 07:28:18.141 [info] [proxy-client] [POLYANIN] Connecting to 127.0.0.1:9001
2023-02-13 07:28:18.142 [info] [proxy-client] [POLYANIN] IDE connected
2023-02-13 07:28:18.142 [info] [server] Start new client connection from 127.0.0.1:33694
2023-02-13 07:28:18.142 [info] [proxy-client] [POLYANIN] Init forwarded, start pipe
2023-02-13 07:28:18.142 [warn] [server] Handler response error: Error reading command: Don't understand command '[507]'
2023-02-13 07:28:18.142 [info] [server] Closing client connection from 127.0.0.1:33694
2023-02-13 07:28:18.192 [info] [proxy-client] [POLYANIN] IDE closed connection
I put a breakpoint and refresh the page.
You cannot use the DBGp proxy this way, as it always sends the debug data to the host where the IDE registration with the key came from.
Since you are using a tunnel, it always comes from 127.0.0.1; this is why you get Found connection for IDE Key 'POLYANIN': 127.0.0.1:9001, and this is why you get the error message - the proxy tries to send the debug data to itself instead of PhpStorm.
There is an extremely ugly workaround - you can modify the proxy code so that it uses the IDE key as a port number to connect to:
https://intellij-support.jetbrains.com/hc/en-us/community/posts/360010264920-xdebug-multiple-developers-php-storm-dbgpproxy

can't started my app. java.lang.IllegalStateException: Illegal access: this web application instance has been stopped already. Could not load []

Please help me with my error. My application not started. I can't understand where I could breake my app.
INFO [mysql-cj-abandoned-connection-cleanup] org.apache.catalina.loader.WebappClassLoaderBase.checkStateForResourceLoading Illegal access: this web application instance has been stopped already. Could not load []. The following stack trace is thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access.
java.lang.IllegalStateException: Illegal access: this web application instance has been stopped already. Could not load []. The following stack trace is thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access.
at org.apache.catalina.loader.WebappClassLoaderBase.checkStateForResourceLoading(WebappClassLoaderBase.java:1432)
at org.apache.catalina.loader.WebappClassLoaderBase.getResource(WebappClassLoaderBase.java:1057)
at com.mysql.cj.jdbc.AbandonedConnectionCleanupThread.checkThreadContextClassLoader(AbandonedConnectionCleanupThread.java:123)
at com.mysql.cj.jdbc.AbandonedConnectionCleanupThread.run(AbandonedConnectionCleanupThread.java:90)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:833)
hibernate.cfg.xml
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="connection.url">jdbc:mysql://localhost:3306/my_db?useSSL=false&serverTimezone=UTC</property>
createDatabaseIfNotExist=true</property>-->
<property name="connection.driver_class">com.mysql.cj.jdbc.Driver</property>
<property name="connection.username">name</property>
<property name="connection.password">password</property>
<property name="current_session_context_class">thread</property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="show_sql">true</property>
</session-factory>
</hibernate-configuration>
Dockerfile
FROM tomcat:9.0
COPY ./target/ROOT.war /usr/local/tomcat/webapps/
docker-compose.yml
version: "3"
services:
app:
build: .
ports:
- "80:8080"
working_dir: /app
volumes:
- ./:/app
environment:
DATABASE_HOST: mysql
DATABASE_USER: user
DATABASE_PASSWORD: password
DATABASE_NAME: my_db
DATABASE_PORT: 3306
depends_on:
- mysql
mysql:
image: "mysql:8.0"
volumes:
- mysql_data:/var/lib/mysql
- ./src/main/resources/init.sql:/data/application/init.sql
command: --init-file /data/application/init.sql
environment:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: my_db
MYSQL_USER: user
MYSQL_PASSWORD: password
volumes:
mysql_data:
Stacktrace:
08-Dec-2022 14:31:01.535 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent Loaded Apache Tomcat Native library [1.2.35] using APR version [1.7.0].
08-Dec-2022 14:31:01.536 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true], UDS [true].
08-Dec-2022 14:31:01.537 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR/OpenSSL configuration: useAprConnector [false], useOpenSSL [true]
08-Dec-2022 14:31:01.808 INFO [main] org.apache.catalina.core.AprLifecycleListener.initializeSSL OpenSSL successfully initialized [OpenSSL 1.1.1g FIPS 21 Apr 2020]
08-Dec-2022 14:31:03.059 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8080"]
08-Dec-2022 14:31:03.397 INFO [main] org.apache.catalina.startup.Catalina.load Server initialization in [2907] milliseconds
08-Dec-2022 14:31:03.484 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service [Catalina]
08-Dec-2022 14:31:03.484 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet engine: [Apache Tomcat/9.0.65]
08-Dec-2022 14:31:03.508 INFO [main] org.apache.catalina.startup.HostConfig.deployWAR Deploying web application archive [/usr/local/tomcat/webapps/ROOT.war]
08-Dec-2022 14:31:07.191 INFO [main] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
08-Dec-2022 14:31:10.629 SEVERE [main] org.apache.catalina.core.StandardContext.startInternal One or more listeners failed to start. Full details will be found in the appropriate container log file
08-Dec-2022 14:31:10.634 SEVERE [main] org.apache.catalina.core.StandardContext.startInternal Context [] startup failed due to previous errors
08-Dec-2022 14:31:10.641 WARNING [main] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesJdbc The web application [ROOT] registered the JDBC driver [com.mysql.cj.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
08-Dec-2022 14:31:10.643 WARNING [main] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [ROOT] appears to have started a thread named [mysql-cj-abandoned-connection-cleanup] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.base#17.0.4.1/java.lang.Object.wait(Native Method)
java.base#17.0.4.1/java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:155)
com.mysql.cj.jdbc.AbandonedConnectionCleanupThread.run(AbandonedConnectionCleanupThread.java:91)
java.base#17.0.4.1/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
java.base#17.0.4.1/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
java.base#17.0.4.1/java.lang.Thread.run(Thread.java:833)
08-Dec-2022 14:31:10.653 INFO [main] org.apache.catalina.startup.HostConfig.deployWAR Deployment of web application archive [/usr/local/tomcat/webapps/ROOT.war] has finished in [7,143] ms
08-Dec-2022 14:31:10.656 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"]
08-Dec-2022 14:31:10.669 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in [7269] milliseconds
08-Dec-2022 14:31:14.969 INFO [mysql-cj-abandoned-connection-cleanup] org.apache.catalina.loader.WebappClassLoaderBase.checkStateForResourceLoading Illegal access: this web application instance has been stopped already. Could not load []. The following stack trace is thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access.
java.lang.IllegalStateException: Illegal access: this web application instance has been stopped already. Could not load []. The following stack trace is thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access.
at org.apache.catalina.loader.WebappClassLoaderBase.checkStateForResourceLoading(WebappClassLoaderBase.java:1432)
at org.apache.catalina.loader.WebappClassLoaderBase.getResource(WebappClassLoaderBase.java:1057)
at com.mysql.cj.jdbc.AbandonedConnectionCleanupThread.checkThreadContextClassLoader(AbandonedConnectionCleanupThread.java:123)
at com.mysql.cj.jdbc.AbandonedConnectionCleanupThread.run(AbandonedConnectionCleanupThread.java:90)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:833)
I had a similar issue, managed to fix it by changing the shutdown port.
The issue was resolved by changing the configuration in server.xml (to be found under the tomcat/config folder):
<Server port="8005" shutdown="SHUTDOWN">
to
<Server port="8004" shutdown="SHUTDOWN">
In your case it might be a different port.

How to know where ejabberd is config

I am working on old project where ejabberd is used. In laravel env file this information is written
JABBER_SERVER=localhost
JABBER_ENV=dev
RPC_SERVER= http://xx.xx.xx.xxx:4560/RPC2
JABBER_HOST=localhost
when i try to find the ejabberd service on my ubuntu server i couldn't.I don't have any idea how i can find ejabberd information because i am getting an error.
2019-12-26 07:54:27.338 [info] <0.23787.5>#ejabberd_c2s:process_terminated:264 (tcp|<0.23786.5>) Closing c2s session for prod6067#localhost/121590970668513998469410: Connection failed: connection closed
2019-12-26 07:54:30.577 [info] <0.339.0>#ejabberd_listener:accept:300 (<0.23789.5>) Accepted connection 115.186.58.62:58101 -> 172.31.42.93:5222
2019-12-26 07:54:31.390 [info] <0.23790.5>#ejabberd_c2s:handle_auth_success:423 (tcp|<0.23789.5>) Accepted c2s SCRAM-SHA-1 authentication for prod6067#localhost by mnesia backend from
2019-12-26 07:54:32.166 [info] <0.23790.5>#ejabberd_c2s:bind:394 (tcp|<0.23789.5>) Opened c2s session for prod6067#localhost/151108589900049164879426
If you can run the ejabberdctl shell script, then it will show many information about where ejabberd is installed:
$ ejabberdctl
...
Optional parameters when starting an ejabberd node:
--config-dir dir Config ejabberd: /etc/ejabberd
--config file Config ejabberd: /etc/ejabberd/ejabberd.yml
--ctl-config file Config ejabberdctl: /etc/ejabberd/ejabberdctl.cfg
--logs dir Directory for logs: /usr/local/var/log/ejabberd
--spool dir Database spool dir: /usr/local/var/lib/ejabberd
--node nodename ejabberd node name: ejabberd#localhost

GitLab CI : My Test Job doesn't pickup the mysql container

I have a springboot application that is connected to a mysql database. I want to use the .gitlab-ci.yml to handle the pipeline. I created the following config file.
before_script:
- echo "Execute scripts which are required to bootstrap the application. !"
after_script:
- echo "Clean up activity can be done here !."
services:
- mysql
stages:
- build
- connect
- test
- package
- deploy
variables:
MAVEN_CLI_OPTS: "--batch-mode"
MAVEN_OPTS: "-Dmaven.repo.local=.m2/repository"
MYSQL_DATABASE_NAME: gyyconsortiumdb
MYSQL_DATABASE_SCHEMA: "$CI_PROJECT_DIR/src/main/resources/static/sql/gyyconsortiumdb.sql"
MYSQL_ROOT_PASSWORD: mysql
cache:
paths:
- .m2/repository/
- target/
build:
stage: build
image: maven:latest
script:
- mvn $MAVEN_CLI_OPTS clean compile
connect:
stage: connect
image: mysql
before_script:
- mysql --version
script:
- echo "create database $MYSQL_DATABASE_NAME;" | mysql --user=root --password="$MYSQL_ROOT_PASSWORD" --host=mysql
- mysql --user=root --password="$MYSQL_ROOT_PASSWORD" --host=mysql $MYSQL_DATABASE_NAME < $MYSQL_DATABASE_SCHEMA
- mysql --user=root --password="$MYSQL_ROOT_PASSWORD" --host=mysql -e "show databases; use $MYSQL_DATABASE_NAME; show tables;"
test:
stage: test
image: maven:latest
script:
- mvn $MAVEN_CLI_OPTS test
package:
stage: package
image: maven:latest
script:
- mvn $MAVEN_CLI_OPTS package
artifacts:
paths: [target/basecamp-0.0.1.war]
deploy_test:
stage: deploy
script:
- echo "######## To be defined ########"
environment: staging
deploy_prod:
stage: deploy
script:
- echo "######## To be defined ########"
only:
- master
environment: production
When the first job is running, it is pulling the mysql image from docker hub, and I don't know why? I thought the mysql should be built only on the connect job.
Also, after the connect job is success, the test job pull the mysql image again. And my test job doesn't recognize my database however the service was create successfully and I was able to see the database also created.
Build job console output:
Running with gitlab-runner 10.3.0 (5cf5e19a)
on docker-auto-scale (fa6cab46)
Using Docker executor with image maven:latest ...
Starting service mysql:latest ...
Pulling docker image mysql:latest ...
Using docker image mysql:latest ID=sha256:7d83a47ab2d2d0f803aa230fdac1c4e53d251bfafe9b7265a3777bcc95163755 for mysql service...
Waiting for services to be up and running...
Using docker image sha256:d6e999707ab00f954f4ab77c8ced4efce186099fb8318e1a0bc2f4fd8bb7bf6b for predefined container...
Pulling docker image maven:latest ...
Using docker image maven:latest ID=sha256:1f858e89a5843b0804a9e1498476a135f45e23a42fe673914f977e0882a6789e for build container...
Running on runner-fa6cab46-project-4899225-concurrent-0 via runner-fa6cab46-srm-1514081729-3d654341...
Cloning repository...
Cloning into '/builds/user/xxx'...
Checking out b9efb2da as 24-create-the-gitlab-ci-yml-file...
Skipping Git submodules setup
Checking cache for default...
Downloading cache.zip from http://runners-cache-3-internal.gitlab.com:444/runner/project/4899225/default
Successfully extracted cache
$ echo "Execute scripts which are required to bootstrap the application. !"
Execute scripts which are required to bootstrap the application. !
$ mvn $MAVEN_CLI_OPTS clean compile
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building xxx 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.6.1:clean (default-clean) # xxx ---
[INFO] Deleting /builds/user/xxx/target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # xxx ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 4 resources
[INFO] Copying 108 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # xxx ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 35 source files to /builds/user/xxx/target/classes
[WARNING] /builds/user/xxx/src/main/java/com//www/xxx/domain/Project.java: Some input files use unchecked or unsafe operations.
[WARNING] /builds/user/xxx/src/main/java/com/xxx/www/xxx/domain/Project.java: Recompile with -Xlint:unchecked for details.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.111 s
[INFO] Finished at: 2017-12-24T02:18:07Z
[INFO] Final Memory: 30M/71M
[INFO] ------------------------------------------------------------------------
Running after script...
$ echo "Clean up activity can be done here !."
Clean up activity can be done here !.
Creating cache default...
.m2/repository/: found 1775 matching files
target/: found 197 matching files
Uploading cache.zip to http://runners-cache-3-
internal.gitlab.com:444/runner/project/4899225/default
Created cache
Job succeeded
Connect job console output
Running with gitlab-runner 10.3.0 (5cf5e19a)
on docker-auto-scale (e11ae361)
Using Docker executor with image mysql ...
Starting service mysql:latest ...
Pulling docker image mysql:latest ...
Using docker image mysql:latest ID=sha256:7d83a47ab2d2d0f803aa230fdac1c4e53d251bfafe9b7265a3777bcc95163755 for mysql service...
Waiting for services to be up and running...
Using docker image sha256:295a9e80fe6ae475bfeef8e318eb11db267d317fa6bc1ed8d72185dfd2adb8b7 for predefined container...
Pulling docker image mysql ...
Using docker image mysql ID=sha256:7d83a47ab2d2d0f803aa230fdac1c4e53d251bfafe9b7265a3777bcc95163755 for build container...
Running on runner-e11ae361-project-4899225-concurrent-0 via runner-e11ae361-srm-1514081811-5092ac06...
Cloning repository...
Cloning into '/builds/yimengael/basecamp'...
Checking out b9efb2da as 24-create-the-gitlab-ci-yml-file...
Skipping Git submodules setup
Checking cache for default...
Downloading cache.zip from http://runners-cache-5-internal.gitlab.com:444/runner/project/4899225/default
Successfully extracted cache
$ mysql --version
mysql Ver 14.14 Distrib 5.7.20, for Linux (x86_64) using EditLine wrapper
$ echo "create database $MYSQL_DATABASE_NAME;" | mysql --user=root --password="$MYSQL_ROOT_PASSWORD" --host=mysql
mysql: [Warning] Using a password on the command line interface can be insecure.
$ mysql --user=root --password="$MYSQL_ROOT_PASSWORD" --host=mysql $MYSQL_DATABASE_NAME < $MYSQL_DATABASE_SCHEMA
mysql: [Warning] Using a password on the command line interface can be insecure.
$ mysql --user=root --password="$MYSQL_ROOT_PASSWORD" --host=mysql -e "show databases; use $MYSQL_DATABASE_NAME; show tables;"
mysql: [Warning] Using a password on the command line interface can be insecure.
Database
information_schema
mydb
mysql
performance_schema
sys
Tables_in_mydb
message
persistent_logins
project
project_description
role
user
user_role
Running after script...
$ echo "Clean up activity can be done here !."
Clean up activity can be done here !.
Creating cache default...
.m2/repository/: found 1775 matching files
target/: found 197 matching files
Archive is up to date!
Created cache
Job succeeded
Test job failed :
2017-12-24 02:21:43.827 INFO 62 --- [ main] c.g.w.b.xxxWebApplicationTests : Starting xxxWebApplicationTests on runner-4e4528ca-project-4899225-concurrent-0 with PID 62 (started by root in /builds/yimengael/xxx)
2017-12-24 02:21:43.829 DEBUG 62 --- [ main] c.g.w.b.xxxWebApplicationTests : Running with Spring Boot v1.5.8.RELEASE, Spring v4.3.12.RELEASE
2017-12-24 02:21:43.829 INFO 62 --- [ main] c.g.w.b.xxxWebApplicationTests : The following profiles are active: dev
2017-12-24 02:21:45.101 INFO 62 --- [ main] o.s.w.c.s.GenericWebApplicationContext : Refreshing org.springframework.web.context.support.GenericWebApplicationContext#62e20a76: startup date [Sun Dec 24 02:21:45 UTC 2017]; root of context hierarchy
2017-12-24 02:21:49.515 INFO 62 --- [ main] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
2017-12-24 02:21:51.533 WARN 62 --- [ main] o.a.tomcat.jdbc.pool.ConnectionPool : maxIdle is larger than maxActive, setting maxIdle to: 50
2017-12-24 02:21:52.448 ERROR 62 --- [ main] o.a.tomcat.jdbc.pool.ConnectionPool : Unable to create initial connections of pool.
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown database 'mydb'
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
.....
2017-12-24 02:21:52.477 WARN 62 --- [ main] o.s.b.a.orm.jpa.DatabaseLookup : Unable to determine jdbc url from datasource
org.springframework.jdbc.support.MetaDataAccessException: Could not get Connection for extracting meta data; nested exception is
org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown database 'mydb'
at org.springframework.jdbc.support.JdbcUtils.extractDatabaseMetaData(JdbcUtils.java:339)
at org.springframework.jdbc.support.JdbcUtils.extractDatabaseMetaData(JdbcUtils.java:366)
at org.springframework.boot.autoconfigure.orm.jpa.DatabaseLookup.getDatabase(DatabaseLookup.java:72)
at org.springframework.boot.autoconfigure.orm.jpa.JpaProperties.determineDatabase(JpaProperties.java:139)
Could you please tell me why the test job does not pick up the mysql service the right way ?
Best,
G
When the first job is running, it is pulling the mysql image from
docker hub, and I don't know why?
Because you defined Mysql as a service. GitLab CI uses the services keyword to define what docker containers should be linked with your base image. So, it will be run for every stages.
Could you please tell me why the test job does not pick up the mysql
service the right way ?
Your database name in your gitlab config file is 'gyyconsortiumdb' which is different from what you defined in your spring config file as log shows you are trying to connect to 'mydb'
jdbc4.MySQLSyntaxErrorException: Unknown database 'mydb'
follow the link for more info
https://docs.gitlab.com/ce/ci/services/mysql.html

Sonar 2.13.1 with MySQL 5.1 Issue

We are new to Sonar and just downloaded v2.13.1 and got it up and working with our project. It was great until it started running slowly and I realized it was because we were still running on the included Derby. We are running MySQL Server 5.1 on the same box (along with TeamCity CI), so I followed the steps to setup MySQL.
I ran extras\database\mysql\create_database.sql to create the sonar user and assign permissions.
I updated conf\sonar.properties to include:
sonar.jdbc.url: jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8
sonar.jdbc.driverClassName: com.mysql.jdbc.Driver
sonar.jdbc.validationQuery: select 1
I restarted the Sonar server and saw from the logs that the database tables were created and I can confirm this independently by browsing the database.
When I start the server, I get the following in the log:
2012.02.07 13:50:58 INFO o.s.c.p.Database Create JDBC datasource
2012.02.07 13:51:01 INFO org.sonar.INFO Initializing Hibernate
2012.02.07 13:51:11 INFO org.sonar.INFO Start services...
When I run our TeamCity configuration that does a "mvn clean install" followed by a "mvn sonar:sonar" goal, which previously worked under Derby, our build completes successfully, but Sonar dies with the following information:
[14:11:24] [west-chai:my-project] [INFO] --- sonar-maven-plugin:2.0:sonar (default-cli) # my-project ---
[14:11:26] [west-chai:my-project] [INFO] Sonar version: 2.13.1
[14:11:29] [west-chai:my-project] [WARN] [14:11:29.403] Derby database should be used for evaluation purpose only
[14:11:29] [west-chai:my-project] [INFO] [14:11:29.403] Create JDBC datasource
[14:11:30] [west-chai:my-project] Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.0:sonar (default-cli) on project my-project: Can not execute Sonar
[14:11:30] [INFO] ------------------------------------------------------------------------
[14:11:30] [INFO] Reactor Summary:
[14:11:30] [INFO]
[14:11:24] [west-chai:my-project] [INFO] --- sonar-maven-plugin:2.0:sonar (default-cli) # my-project ---
[14:11:26] [west-chai:my-project] [INFO] Sonar version: 2.13.1
[14:11:29] [west-chai:my-project] [WARN] [14:11:29.403] Derby database should be used for evaluation purpose only
[14:11:29] [west-chai:my-project] [INFO] [14:11:29.403] Create JDBC datasource
[14:11:30] [west-chai:my-project] Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.0:sonar (default-cli) on project my-project: Can not execute Sonar
[14:11:30] [INFO] ------------------------------------------------------------------------
[14:11:30] [INFO] Reactor Summary:
[14:11:30] [INFO]
[14:11:30] [INFO] PROJECT COMPONENT 1 ................... FAILURE [34.679s]
[14:11:30] [INFO] PROJECT COMPONENT 2 ................... SKIPPED
...
[14:11:30] [INFO] PROJECT COMPONENT N ................... SKIPPED
[14:11:30] [INFO] ------------------------------------------------------------------------
[14:11:30] [INFO] BUILD FAILURE
[14:11:30] [INFO] ------------------------------------------------------------------------
[14:11:30] [INFO] Total time: 41.809s
[14:11:30] [INFO] Finished at: Tue Feb 07 14:11:30 CST 2012
[14:11:31] [INFO] Final Memory: 31M/92M
[14:11:31] [INFO] ------------------------------------------------------------------------
[14:11:31] [ERROR] Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.0:sonar (default-cli) on project my-project: Can not execute Sonar: PicoLifecycleException: method 'public final org.sonar.core.persistence.DefaultDatabase org.sonar.core.persistence.DefaultDatabase.start()', instance 'org.sonar.batch.bootstrap.BatchDatabase#1d4d6a, java.lang.RuntimeException: wrapper: Fail to connect to database: Cannot create PoolableConnectionFactory (java.net.ConnectException : Error connecting to server localhost on port 1527 with message Connection refused: connect.) -> [Help 1]
[14:11:31] [ERROR]
[14:11:31] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[14:11:31] [ERROR] Re-run Maven using the -X switch to enable full debug logging.
[14:11:31] [ERROR]
[14:11:31] [ERROR] For more information about the errors and possible solutions, please read the following articles:
[14:11:31] [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
[14:11:31] Process exited with code 1
[14:11:31] [Publishing artifacts] Paths to publish: [E:\apps\TeamCity\server\buildAgent\temp\buildTmp\.tc-maven-bi\maven-build-info.1.xml.gz => .teamcity]
[14:11:31] [Publishing artifacts] Sending files
[14:11:31] Step Sonar (Maven) failed
[14:11:31] Waiting for 38 service processes to complete
[14:11:31] Sending build.finish.properties.gz file
[14:11:31] Paths to publish: [MyProject\Mainline\MyApp\target\chai.war, MyProject\Mainline\MyComponent\MyComponent-service\target\MyComponent.war]
[14:11:31] Sending files
[14:11:35] Build finished
[14:11:30] [INFO] ------------------------------------------------------------------------
[14:11:30] [INFO] BUILD FAILURE
[14:11:30] [INFO] ------------------------------------------------------------------------
[14:11:30] [INFO] Total time: 41.809s
[14:11:30] [INFO] Finished at: Tue Feb 07 14:11:30 CST 2012
[14:11:31] [INFO] Final Memory: 31M/92M
[14:11:31] [INFO] ------------------------------------------------------------------------
[14:11:31] [ERROR] Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.0:sonar (default-cli) on project my-project: Can not execute Sonar: PicoLifecycleException: method 'public final org.sonar.core.persistence.DefaultDatabase org.sonar.core.persistence.DefaultDatabase.start()', instance 'org.sonar.batch.bootstrap.BatchDatabase#1d4d6a, java.lang.RuntimeException: wrapper: Fail to connect to database: Cannot create PoolableConnectionFactory (java.net.ConnectException : Error connecting to server localhost on port 1527 with message Connection refused: connect.) -> [Help 1]
[14:11:31] [ERROR]
[14:11:31] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[14:11:31] [ERROR] Re-run Maven using the -X switch to enable full debug logging.
[14:11:31] [ERROR]
[14:11:31] [ERROR] For more information about the errors and possible solutions, please read the following articles:
[14:11:31] [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
[14:11:31] Process exited with code 1
[14:11:31] [Publishing artifacts] Paths to publish: [E:\apps\TeamCity\server\buildAgent\temp\buildTmp\.tc-maven-bi\maven-build-info.1.xml.gz => .teamcity]
[14:11:31] [Publishing artifacts] Sending files
[14:11:31] Step Sonar (Maven) failed
[14:11:31] Waiting for 38 service processes to complete
[14:11:31] Sending build.finish.properties.gz file
[14:11:31] Paths to publish: [MyProject\Mainline\MyApp\target\chai.war, MyProject\Mainline\MyComponent\MyComponent-service\target\MyComponent.war]
[14:11:31] Sending files
[14:11:35] Build finished
The error line that follows mentions port 1527, which is referenced by the commented out Derby config lines.
[14:11:31] [ERROR] Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.0:sonar (default-cli) on project my-project: Can not execute Sonar: PicoLifecycleException: method 'public final org.sonar.core.persistence.DefaultDatabase org.sonar.core.persistence.DefaultDatabase.start()', instance 'org.sonar.batch.bootstrap.BatchDatabase#1d4d6a, java.lang.RuntimeException: wrapper: Fail to connect to database: Cannot create PoolableConnectionFactory (java.net.ConnectException : Error connecting to server localhost on port 1527 with message Connection refused: connect.) -> [Help 1]
If I comment out the sonar.jdbc lines above and restore the following lines, then the both our "mvn clean install" and the "mvn sonar:sonar" complete successfully.
sonar.jdbc.url: jdbc:derby://localhost:152/sonar;create=true
sonar.jdbc.driverClassName: org.apache.derby.jdbc.ClientDriver
sonar.jdbc.validationQuery: values(1)
Is there a different configuration for the Maven target than what is used directly by the Sonar server? Is there an explicit way to tell which JDBC datasource is being connected to?
The Sonar server and your Maven client are configured separately.
Unless configured otherwise Maven will automatically assume that Sonar is running locally with a Derby database, explaining your errors.
The Sonar documentation explains how Maven can be configured to support MySQL.
I faced with the similar problem yesterday (April, 11 2012)
1) input:
teamcity 7
maven 3.0.4
sonar 2.13
postgresql 9
global maven settings.xml contains sonar profile with proper DB settings
jdk 1.6.30
project build from command line passed ok
2) result:
teamcity - Can not execute Sonar
log contains exception
Fail to connect to database: Cannot create PoolableConnectionFactory (java.net.ConnectException : Ошибка соединения с сервером localhost на порту 1527
3) possible cause:
TeamCity uses wrong settings.xml
4) solution:
goto Administratioin
goto left menu Integrations->Maven settings
upload your version of settings.xml (in my case with proper settings for Sonar)