Hi Lukas,
Thank you for the reply.
After doing some modifications to my .gradle files, now I am able to start the MySql testcontainer, apply the DB migrations using Liquibase but when its executing the generateJooq task, its breaking with the below error.
Here is the fill log when I run
./gradlew clean build command in my local. Any idea whats going wrong here.
> Configure project :
Executing build script:
https://chegg-gradle.test.devx.chegg.services/chegg-gradle/scripts/boots-build.5/application.gradleExecuting build script:
https://chegg-gradle.test.devx.chegg.services/chegg-gradle/scripts/boots-build.5/internal/chegg-repository.gradleUsing AWS CLI to get CodeArtifact repo URL
Executing: aws codeartifact get-repository-endpoint --profile chegg-app-edu1-nonprod --domain chegg --domain-owner 084139392869 --region us-west-2 --repository java-chegg --format maven --query repositoryEndpoint --output text
Result: "
https://chegg-084139392869.d.codeartifact.us-west-2.amazonaws.com/maven/java-chegg/"
Using repo url
https://chegg-084139392869.d.codeartifact.us-west-2.amazonaws.com/maven/java-chegg/Using AWS CLI to get CodeArtifact token
Executing: aws codeartifact get-authorization-token --profile chegg-app-edu1-nonprod --domain chegg --domain-owner 084139392869 --region us-west-2 --query authorizationToken --output text
Result: "( 1438 hidden characters )"
Executing build script:
https://chegg-gradle.test.devx.chegg.services/chegg-gradle/scripts/boots-build.5/internal/common.gradleStandard configured repositories:
- CodeArtifact (url:
https://chegg-084139392869.d.codeartifact.us-west-2.amazonaws.com/maven/java-chegg/, username: aws)
- confluent (url:
https://packages.confluent.io/maven/)
Executing build script:
https://chegg-gradle.test.devx.chegg.services/chegg-gradle/scripts/boots-build.5/internal/build-props.gradlebuildCheggEnv = dev
Loading properties from src/main/resources/application.properties...
Loading properties from src/main/resources/application-dev.properties...
Found
spring.application.name in application properties
Loading secrets from dev/lms-registration-service...
Loading parameters from /dev/lms-registration-service/...
Executing build script:
https://chegg-gradle.test.devx.chegg.services/chegg-gradle/scripts/boots-build.5/internal/tests.gradleExecuting build script:
https://chegg-gradle.test.devx.chegg.services/chegg-gradle/scripts/boots-build.5/internal/jacoco.gradleExecuting build script:
https://chegg-gradle.test.devx.chegg.services/chegg-gradle/scripts/boots-build.5/internal/newrelic.gradle
Configuring JOOQ dependencies and code generation plugin...
Configuring Netflix DGS code generation plugin...
----Stating MySql DB TC----
> Task :startMySQLContainer
----MySql Test container started successfully with URL : jdbc:mysql://localhost:50255/lmsdb
> Task :update
liquibase-plugin: Running the 'main' activity...
####################################################
## _ _ _ _ ##
## | | (_) (_) | ##
## | | _ __ _ _ _ _| |__ __ _ ___ ___ ##
## | | | |/ _` | | | | | '_ \ / _` / __|/ _ \ ##
## | |___| | (_| | |_| | | |_) | (_| \__ \ __/ ##
## \_____/_|\__, |\__,_|_|_.__/ \__,_|___/\___| ##
## | | ##
## |_| ##
## ##
## Get documentation at
docs.liquibase.com ##
## Get certified courses at
learn.liquibase.com ##
## ##
####################################################
Starting Liquibase at 23:46:32 (version 4.24.0 #14062 built at 2023-09-28 12:18+0000)
[2024-06-11 23:46:32] INFO [liquibase.ui] ####################################################
## _ _ _ _ ##
## | | (_) (_) | ##
## | | _ __ _ _ _ _| |__ __ _ ___ ___ ##
## | | | |/ _` | | | | | '_ \ / _` / __|/ _ \ ##
## | |___| | (_| | |_| | | |_) | (_| \__ \ __/ ##
## \_____/_|\__, |\__,_|_|_.__/ \__,_|___/\___| ##
## | | ##
## |_| ##
## ##
## Get documentation at
docs.liquibase.com ##
## Get certified courses at
learn.liquibase.com ##
## ##
####################################################
Starting Liquibase at 23:46:32 (version 4.24.0 #14062 built at 2023-09-28 12:18+0000)
Liquibase Version: 4.24.0
[2024-06-11 23:46:32] INFO [liquibase.ui] Liquibase Version: 4.24.0
WARNING: License service not loaded, cannot determine Liquibase Pro license status. Please consider re-installing Liquibase to include all dependencies. Continuing operation without Pro license.
[2024-06-11 23:46:32] INFO [liquibase.ui] WARNING: License service not loaded, cannot determine Liquibase Pro license status. Please consider re-installing Liquibase to include all dependencies. Continuing operation without Pro license.
[2024-06-11 23:46:32] INFO [liquibase.integration] Starting command execution.
[2024-06-11 23:46:32] INFO [liquibase.changelog] Reading resource: liquibase/db1/sqlfiles/V0__create_lms_integration_tables.sql
[2024-06-11 23:46:32] INFO [liquibase.changelog] Creating database history table with name: lmsdb.DATABASECHANGELOG
[2024-06-11 23:46:32] INFO [liquibase.changelog] Reading from lmsdb.DATABASECHANGELOG
[2024-06-11 23:46:32] WARNING [liquibase.executor] Integer display width is deprecated and will be removed in a future release.
[2024-06-11 23:46:32] INFO [liquibase.lockservice] Successfully acquired change log lock
[2024-06-11 23:46:32] INFO [liquibase.command] Using deploymentId:
8174792776[2024-06-11 23:46:32] INFO [liquibase.changelog] Reading from lmsdb.DATABASECHANGELOG
Running Changeset: liquibase/db1/sqlfiles/V0__create_lms_integration_tables.sql::raw::includeAll
[2024-06-11 23:46:32] INFO [liquibase.ui] Running Changeset: liquibase/db1/sqlfiles/V0__create_lms_integration_tables.sql::raw::includeAll
[2024-06-11 23:46:32] INFO [liquibase.changelog] Custom SQL executed
[2024-06-11 23:46:32] INFO [liquibase.changelog] ChangeSet liquibase/db1/sqlfiles/V0__create_lms_integration_tables.sql::raw::includeAll ran successfully in 31ms
UPDATE SUMMARY
Run: 1
Previously run: 0
Filtered out: 0
-------------------------------
Total change sets: 1
[2024-06-11 23:46:32] INFO [liquibase.util] UPDATE SUMMARY
[2024-06-11 23:46:32] INFO [liquibase.util] Run: 1
[2024-06-11 23:46:32] INFO [liquibase.util] Previously run: 0
[2024-06-11 23:46:32] INFO [liquibase.util] Filtered out: 0
[2024-06-11 23:46:32] INFO [liquibase.util] -------------------------------
[2024-06-11 23:46:32] INFO [liquibase.util] Total change sets: 1
[2024-06-11 23:46:32] INFO [liquibase.util] Update summary generated
[2024-06-11 23:46:32] INFO [liquibase.command] Update command completed successfully.
Liquibase: Update has been successful. Rows affected: 1
[2024-06-11 23:46:32] INFO [liquibase.ui] Liquibase: Update has been successful. Rows affected: 1
[2024-06-11 23:46:32] INFO [liquibase.lockservice] Successfully released change log lock
[2024-06-11 23:46:32] INFO [liquibase.command] Command execution complete
Liquibase command 'update' was executed successfully.
[2024-06-11 23:46:32] INFO [liquibase.ui] Liquibase command 'update' was executed successfully.
> Task :generateJooq FAILED
Running jOOQ code generation with URL: jdbc:mysql://localhost:50255/lmsdb
Username: test
Password: test
Driver: com.mysql.cj.jdbc.Driver
[main] WARN org.jooq.meta.AbstractDatabase - SQL exception : Exception while executing meta query: Cannot execute query. No JDBC Connection configured
If you think this is a bug in jOOQ, please report it here:
https://jooq.org/bugNote you can mute some exceptions using the configuration/onError flag
```sql
select information_schema.SCHEMATA.SCHEMA_NAME
from information_schema.SCHEMATA```
[main] ERROR org.jooq.meta.AbstractDatabase - Code generation error : An error was encountered during code generation. This can have various reasons:
- There's a bug in jOOQ. Please report it here:
https://jooq.org/bug- Your database user doesn't have the necessary privileges to access a metadata table
- The database connection suffered a failure
There are other reasons. If the error can be ignored, you can either:
- Turn off the relevant feature in the code generator to avoid running into the error
- Avoid fetching the relevant meta data by excluding the object from code generation
- Use the <onError/> code generation configuration to specify the severity of such errors (for all errors!)
See
https://www.jooq.org/doc/latest/manual/code-generation/codegen-advanced/codegen-config-onerror/[main] ERROR org.jooq.codegen.GenerationTool - Error in file: /Users/dpatra/Downloads/HSLab/BEServices/PartnerServices/lms-registration-service/build/tmp/generateJooq/config.xml. Error : Error generating code for catalog
org.jooq.codegen.GeneratorException: Error generating code for catalog
at org.jooq.codegen.JavaGenerator.generate0(JavaGenerator.java:542)
at org.jooq.codegen.AbstractGenerator.generate(AbstractGenerator.java:191)
at org.jooq.codegen.JavaGenerator.generate(JavaGenerator.java:225)
at org.jooq.codegen.GenerationTool.run0(GenerationTool.java:944)
at org.jooq.codegen.GenerationTool.run(GenerationTool.java:244)
at org.jooq.codegen.GenerationTool.generate(GenerationTool.java:239)
at org.jooq.codegen.GenerationTool.main(GenerationTool.java:211)
Caused by: java.lang.RuntimeException: org.jooq.exception.DetachedException: Cannot execute query. No JDBC Connection configured
at org.jooq.meta.AbstractDatabase.onError(AbstractDatabase.java:3886)
at org.jooq.meta.AbstractDatabase.getSchemata(AbstractDatabase.java:759)
at org.jooq.meta.AbstractDatabase.getSchemata(AbstractDatabase.java:779)
at org.jooq.meta.CatalogDefinition.getSchemata(CatalogDefinition.java:65)
at org.jooq.codegen.JavaGenerator.generateCatalogIfEmpty(JavaGenerator.java:574)
at org.jooq.codegen.JavaGenerator.generate0(JavaGenerator.java:536)
... 6 more
Caused by: org.jooq.exception.DetachedException: Cannot execute query. No JDBC Connection configured
at org.jooq_3.18.15.MYSQL.debug(Unknown Source)
at org.jooq.impl.AbstractQuery.connection(AbstractQuery.java:393)
at org.jooq.impl.AbstractQuery.execute(AbstractQuery.java:306)
at org.jooq.impl.AbstractResultQuery.fetchLazy(AbstractResultQuery.java:301)
at org.jooq.impl.AbstractResultQuery.fetchLazyNonAutoClosing(AbstractResultQuery.java:322)
at org.jooq.impl.SelectImpl.fetchLazyNonAutoClosing(SelectImpl.java:2862)
at org.jooq.impl.ResultQueryTrait.collect(ResultQueryTrait.java:360)
at org.jooq.meta.mysql.MySQLDatabase.getSchemata0(MySQLDatabase.java:426)
at org.jooq.meta.AbstractDatabase.lambda$getSchemata$2(AbstractDatabase.java:759)
at org.jooq.meta.AbstractDatabase.onError(AbstractDatabase.java:3860)
... 11 more
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':generateJooq'.
> Process 'command '/Library/Java/JavaVirtualMachines/amazon-corretto-17.jdk/Contents/Home/bin/java'' finished with non-zero exit value 255
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at
https://help.gradle.org.
Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
For more on this, please refer to
https://docs.gradle.org/8.7/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.
BUILD FAILED in 18s
6 actionable tasks: 6 executed
Here is my three files.
// mysql-tc.gradle
import org.testcontainers.containers.MySQLContainer
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath "org.testcontainers:testcontainers:${testcontainersVersion}"
classpath "org.testcontainers:mysql:${testcontainersVersion}"
classpath "com.mysql:mysql-connector-j:8.4.0"
}
}
tasks.register('startMySQLContainer') {
println("----Stating MySql DB TC----")
doLast {
def mysqlContainer = new MySQLContainer("mysql:latest")
.withDatabaseName("lmsdb")
mysqlContainer.start()
project.ext.dbUrl = mysqlContainer.getJdbcUrl()
project.ext.dbUsername = mysqlContainer.getUsername()
project.ext.dbPassword = mysqlContainer.getPassword()
project.ext.dbDriver = mysqlContainer.getDriverClassName()
println("----MySql Test container started successfully with URL : ${project.ext.dbUrl}")
}
}
tasks.register('stopMySqlContainer') {
doLast {
if (mysqlContainer) {
mysqlContainer.stop()
}
}
}
// liquibase.gradle
configurations {
liquibaseRuntime.extendsFrom runtimeClasspath
}
dependencies {
liquibaseRuntime sourceSets.main.output
implementation 'org.liquibase:liquibase-core:4.24.0'
implementation 'info.picocli:picocli:4.7.6'
}
tasks.named('startMySQLContainer').configure {
doLast {
liquibase {
activities {
main {
changelogFile 'liquibase/db1/tc_changelog.yml'
url project.ext.has('dbUrl') ? project.ext.dbUrl : ''
username project.ext.has('dbUsername') ? project.ext.dbUsername : ''
password project.ext.has('dbPassword') ? project.ext.dbPassword : ''
}
}
runList = 'main'
}
}
}
tasks.named('update') {
dependsOn ':startMySQLContainer'
}
jooq.configurations.main {
generationTool {
jdbc {
url = project.ext.has('dbUrl') ? project.ext.dbUrl : ''
user = project.ext.has('dbUsername') ? project.ext.dbUsername : ''
password = project.ext.has('dbPassword') ? project.ext.dbPassword : ''
driver = project.ext.has('dbDriver') ? project.ext.dbDriver : ''
}
}
}
// Configure the JVM used for the JOOQ code generation process
tasks.withType(JooqGenerate).configureEach {
javaExecSpec = { JavaExecSpec s ->
s.systemProperties System.properties
}
}
tasks.named('generateJooq') {
dependsOn ':startMySQLContainer', ':update'
doFirst {
println "Running jOOQ code generation with URL: ${project.ext.dbUrl}"
println "Username: ${project.ext.dbUsername}"
println "Password: ${project.ext.dbPassword}"
println "Driver: ${project.ext.dbDriver}"
}
}