I need to run a Grails 3 app against MySql/Hibernate and MongoDB.
(Had is running on Grails 2.5 without an hitch).
I tried many different combinations, searched and tried related SO answers, but with no luck.
Used the latest Mongodb plugin doc for the configuration.
Using Grails 3.1.10:
grailsVersion=3.1.10
I started with the following details in build.gradle:
buildscript {
ext {
grailsVersion = project.grailsVersion
}
repositories {
mavenLocal()
maven { url "https://repo.grails.org/grails/core" }
}
dependencies {
classpath "org.grails:grails-gradle-plugin:$grailsVersion"
classpath "com.bertramlabs.plugins:asset-pipeline-gradle:2.8.2"
classpath "org.grails.plugins:hibernate4:5.0.10"
}
}
...
dependencies {
compile "org.springframework.boot:spring-boot-starter-logging"
compile "org.springframework.boot:spring-boot-autoconfigure"
compile "org.grails:grails-core"
compile "org.springframework.boot:spring-boot-starter-actuator"
compile "org.springframework.boot:spring-boot-starter-tomcat"
compile "org.grails:grails-dependencies"
compile "org.grails:grails-web-boot"
compile "org.grails.plugins:cache"
compile "org.grails.plugins:scaffolding"
compile "org.grails.plugins:hibernate4"
compile "org.hibernate:hibernate-ehcache"
console "org.grails:grails-console"
profile "org.grails.profiles:web"
runtime "com.bertramlabs.plugins:asset-pipeline-grails:2.8.2"
testCompile "org.grails:grails-plugin-testing"
testCompile "org.grails.plugins:geb"
testRuntime "org.seleniumhq.selenium:selenium-htmlunit-driver:2.47.1"
testRuntime "net.sourceforge.htmlunit:htmlunit:2.18"
//databases
compile 'org.grails.plugins:mongodb:6.0.0.M2'
runtime 'mysql:mysql-connector-java:5.1.36'
...
}
The application.yml:
---
hibernate:
cache:
queries: false
use_second_level_cache: true
use_query_cache: false
region.factory_class: org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory
dataSource:
pooled: true
jmxExport: true
driverClassName: com.mysql.jdbc.Driver
environments:
development:
dataSource:
dbCreate: update
url: jdbc:mysql://localhost:3306/dbname
driverClassName: com.mysql.jdbc.Driver
dialect: org.hibernate.dialect.MySQL5InnoDBDialect
username : "xxx"
password : "yyy"
properties:
maxActive : 50
maxIdle: 25
minIdle: 5
...
grails:
mongodb:
host: "localhost"
port: 27017
username: "blah"
password: "blah"
databaseName: "foo"
Now this gives me an error:
15:13:58.001 [QUIET] [system.out] ERROR org.springframework.boot.SpringApplication - Application startup failed
15:13:58.001 [QUIET] [system.out] java.lang.NoClassDefFoundError: org/grails/datastore/gorm/plugin/support/ConfigSupport
15:13:58.001 [QUIET] [system.out] at grails.plugins.mongodb.MongodbGrailsPlugin.doWithSpring(MongodbGrailsPlugin.groovy:42)
The MongoDB grails plugin does not find ConfigSupport
ConfigSupport.prepareConfig(config, (ConfigurableApplicationContext) applicationContext)
I then tried to add the following plugins in all orders possible:
//compile 'org.grails:grails-datastore-gorm-hibernate4:6.0.0.M2'
//compile 'org.grails:grails-datastore-core:4.0.0.M2'
//compile 'org.grails:grails-datastore-gorm-plugin-support:6.0.0.M2'
//compile 'org.springframework.data:spring-data-mongodb:1.9.2.RELEASE'
//compile 'org.mongodb:mongodb-driver:3.3.0'
//compile 'org.mongodb:mongo-java-driver:3.3.0'
No luck.
I also moved the mongodb: section down to the grails: section in the yml file. Same error.
So the question is how to get MongoDB running with MySql with grails3.
Ok, stupid me. I solved the puzzle using these simple dependency settings:
compile "org.springframework.boot:spring-boot-starter-logging"
compile "org.springframework.boot:spring-boot-autoconfigure"
compile "org.grails:grails-core"
compile "org.springframework.boot:spring-boot-starter-actuator"
compile "org.springframework.boot:spring-boot-starter-tomcat"
compile "org.grails:grails-dependencies"
compile "org.grails:grails-web-boot"
compile "org.grails.plugins:cache"
compile "org.grails.plugins:scaffolding"
compile "org.grails.plugins:hibernate4"
compile "org.hibernate:hibernate-ehcache"
console "org.grails:grails-console"
profile "org.grails.profiles:web"
runtime "com.bertramlabs.plugins:asset-pipeline-grails:2.8.2"
testCompile "org.grails:grails-plugin-testing"
testCompile "org.grails.plugins:geb"
testRuntime "org.seleniumhq.selenium:selenium-htmlunit-driver:2.47.1"
testRuntime "net.sourceforge.htmlunit:htmlunit:2.18"
//databases
compile 'org.grails.plugins:mongodb'
runtime 'mysql:mysql-connector-java:5.1.36'
runtime 'com.googlecode.json-simple:json-simple:1.1'
It seems that the following line made the difference:
compile 'org.grails.plugins:mongodb'
Omitting the version number. This should be explained in the docs a bit better. Usually it is a good thing defining versions, or is this too old fashioned these days? :-)
Happy to have it working
Ok I found correct previous answer for referring mongodb plugin, i.e. compile 'org.grails.plugins:mongodb' but I want to sum up with a brief checklist, having me a correctly running mixed solution (both hibernate + mysql and mongodb), after many trials and errors. So, in order to have a mixed mysql/mongo grails3 configuration, you have to
insert compile 'org.grails.plugins:mongodb' (without any version) in build.gradle (remember that there is no BuildConfig.groovy in grails 3, as documented here/grails2->3)
keep ordinary dependency to hibernate/mysql, for example: compile 'org.grails.plugins:hibernate4' compile 'org.hibernate:hibernate-ehcache' runtime 'mysql:mysql-connector-java:5.1.38'
set up correctly connections in application.yml, but I prefer old-style application.groovy, in grails-app/conf (as in older GRAILS), as below (remember that in GRAILS3 differently from 2 you have to use mongodb and no more mongo keyword)
use ordinary GRAILS entities for mysql mapping
and use static mapWith="mongo" inside mongo entities (as stated in GRAILS-mongo doc)
not use usual mysql Long id for mongo, but ObjectId id, and for it import org.bson.types.ObjectId
Application.groovy set up
grails {
mongodb {
host = "localhost"
port = 27017
username = mongouser
password= mongopasswd
databaseName = mongoDBname
}
}
environments {
development {
dataSource {
driverClassName = "com.mysql.jdbc.Driver"
username = ...
password = ...
dbCreate = "create"
url = "jdbc:mysql://127.0.0.1:3306/dbnameMysql"
}
}
}
That's all. Enjoy MongoDB.
Not sure I can help much other than show my config that is confirmed working.
I've recently converted a 2.4.4 app to 3.1.8, admittedly I'm using Oracle as my RDBMS rather than mysql.
In build.gradle I just have:
dependencies {
classpath "org.grails.plugins:hibernate4:5.0.6"
...
}
dependencies {
compile "org.grails.plugins:mongodb:5.0.0.RC1"
...
}
And in application.yml:
mongodb:
databaseName: 'myApp'
engine: mapping
The engine: mapping bit was crucial for me, it reverts to the previous persistence engine as described here http://gorm.grails.org/latest/mongodb/manual/index.html
The doWithSpring() closure in my MongodbGrailsPlugin.groovy looks like:
Closure doWithSpring() {
def initializer = new MongoDbDataStoreSpringInitializer(config, grailsApplication.getArtefacts(DomainClassArtefactHandler.TYPE).collect() { GrailsClass cls -> cls.clazz })
initializer.registerApplicationIfNotPresent = false
initializer.setSecondaryDatastore( manager.hasGrailsPlugin("hibernate") )
return initializer.getBeanDefinitions((BeanDefinitionRegistry)applicationContext)
}
No reference to ConfigSupport which may have been added (or not) in your later version or there's a dependency missing.
Related
I'm trying to run a Karate test as a Gatling performance test. I am being use Gradle however. When trying to run under Gradle the below disaster unfolds.
Appreciate any ideas what might be causing KarateAction to crash.
i have added Gatling dependencies in gradle build
BUILD GRADLE:
plugins {
// id 'org.springframework.boot' version '2.5.5'
// id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id 'java'
id 'net.researchgate.release' version '2.8.1'
}
group 'org.ikano'
version '1.0-SNAPSHOT'
sourceCompatibility = 1.8
ext {
cucumberVersion = "5.7.0"
karateVersion = '1.1.0'
// kafkaProducer = "3.2.0"
// kafkaConsumer = "3.2.0"
// kafkaCommonModel = "3.2.0"
dbUtilsVersion = "1.7"
}
apply plugin: 'scala'
configurations {
gatling
}
sourceSets {
test {
resources {
srcDir file('src/test/java')
exclude '**/*.java'
exclude '**/*.scala'
}
}
}
test {
useJUnitPlatform()
systemProperty "karate.options", System.properties.getProperty("karate.options")
systemProperty "karate.env", System.properties.getProperty("karate.env")
outputs.upToDateWhen { false }
}
repositories {
maven {
url "https://artifacts.le.tnt.bank.*****/repository/maven-****"
credentials {
username '*******'
password '**********'
}
mavenCentral()
}
}
task karateDebug(type: JavaExec) {
classpath = sourceSets.test.runtimeClasspath
main = 'com.intuit.karate.cli.Main'
}
dependencies {
implementation("commons-configuration:commons-configuration:1.10")
implementation("org.json:json:20180813")
implementation("javax.mail:mail:1.5.0-b01")
implementation("com.jayway.jsonpath:json-path:2.6.0")
implementation("com.googlecode.json-simple:json-simple:1.1.1")
// implementation("org.springframework:spring-context:5.3.13")
implementation("org.apache.poi:poi-ooxml:4.1.1")
// implementation("org.springframework:spring-webmvc:4.3.0.RELEASE")
testImplementation("com.intuit.karate:karate-core:1.2.0")
testImplementation("junit:junit:4.13.2")
testImplementation("com.intuit.karate:karate-junit5:1.1.0")
testImplementation("com.intuit.karate:karate-gatling:1.1.0")
testImplementation("com.intuit.karate:karate-apache:0.9.6")
testImplementation("net.masterthought:cucumber-reporting:3.8.0")
testImplementation("hu.blackbelt.bundles.poi:org.apache.poi:4.1.2_2")
testImplementation("org.apache.poi:poi:4.1.1")
testImplementation("io.rest-assured:rest-assured:4.3.0")
testCompile 'com.intuit.karate:karate-junit5:1.1.0'
testCompile "com.intuit.karate:karate-gatling:${karateVersion}"
// compile group: 'org.springframework.boot', name: 'spring-boot-starter-parent', version: '2.5.5', ext: 'pom'
//implementation group: 'org.springframework', name: 'spring-websocket', version: '5.2.9.RELEASE'
//implementation group: 'org.springframework', name: 'spring-messaging', version: '5.2.9.RELEASE'
// implementation 'org.springframework.boot:spring-boot-starter-web'
// implementation 'org.springframework.boot:spring-boot-starter'
// testImplementation('org.springframework.boot:spring-boot-starter-test')
//{exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'}
compile group: 'joda-time', name: 'joda-time', version: '2.10.6'
// implementation "com.ikano.ipay.eem.kafka:kafka-producer:${kafkaProducer}"
// implementation "com.ikano.ipay.eem.kafka:kafka-consumer:${kafkaConsumer}"
// implementation "com.ikano.ipay.eem.kafka:kafka-common-model:${kafkaCommonModel}"
implementation group: 'redis.clients', name: 'jedis', version: '2.9.0'
implementation group: 'org.redisson', name: 'redisson', version: "3.16.3"
compile group: 'org.apache.poi', name: 'poi', version: '4.1.2'
compile group: 'org.apache.poi', name: 'poi-ooxml', version: '4.1.2'
compile group: 'commons-dbutils', name: 'commons-dbutils', version: "$dbUtilsVersion"
task gatlingRun(type: JavaExec) {
group = 'Web Tests'
description = 'Run Gatling Tests'
new File("${buildDir}/reports/gatling").mkdirs()
classpath = sourceSets.test.runtimeClasspath
main = "io.gatling.app.Gatling"
args = [
// change this to suit your simulation entry-point
'-s', 'performance2.userSimulation',
'-rf', "${buildDir}/reports/gatling"
]
systemProperties System.properties
}
group = "org.ikano"
version = "1.0-SNAPSHOT"
description = "IPay"
java.sourceCompatibility = JavaVersion.VERSION_1_8
FOR SCALA
package performance
import com.intuit.karate.gatling.PreDef._
import io.gatling.core.Predef._
import io.gatling.core.structure.ScenarioBuilder
import scala.concurrent.duration._
class UserSimulation extends Simulation{
val getSingleUser: ScenarioBuilder = scenario("UK Onboarding - Verify user is able to onboard successfully").exec(karateFeature("classpath:performance/onboarding.feature"))
setUp(
getSingleUser.inject(rampUsers(10).during(5 seconds))
)
}
Command Line :gradle gatlingRun
Starting a Gradle Daemon (subsequent builds will be faster)
> Task :gatlingRun
16:10:18.039 [main] INFO i.g.c.config.GatlingConfiguration$ - Gatling will try to use 'gatling.conf' as config file.
16:10:20.052 [GatlingSystem-akka.actor.default-dispatcher-6] INFO akka.event.slf4j.Slf4jLogger - Slf4jLogger started
16:10:22.818 [main] ERROR io.gatling.app.Gatling$ - Run crashed
java.lang.IllegalArgumentException: User defined Simulation class performance2.userSimulation could not be loaded
at io.gatling.app.Selection$Selector.findUserDefinedSimulationInClassloader$1(Selection.scala:80)
at io.gatling.app.Selection$Selector.$anonfun$singleSimulationFromConfig$4(Selection.scala:85)
at scala.Option.orElse(Option.scala:477)
at io.gatling.app.Selection$Selector.$anonfun$singleSimulationFromConfig$3(Selection.scala:85)
at scala.Option.flatMap(Option.scala:283)
at io.gatling.app.Selection$Selector.singleSimulationFromConfig(Selection.scala:83)
at io.gatling.app.Selection$Selector.$anonfun$selection$1(Selection.scala:52)
at scala.Option.getOrElse(Option.scala:201)
at io.gatling.app.Selection$Selector.selection(Selection.scala:44)
at io.gatling.app.Selection$.apply(Selection.scala:36)
at io.gatling.app.Runner.run0(Runner.scala:61)
at io.gatling.app.Runner.run(Runner.scala:49)
at io.gatling.app.Gatling$.start(Gatling.scala:83)
at io.gatling.app.Gatling$.fromArgs(Gatling.scala:45)
at io.gatling.app.Gatling$.main(Gatling.scala:37)
at io.gatling.app.Gatling.main(Gatling.scala)
Caused by: java.lang.ClassNotFoundException: performance2.userSimulation
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at io.gatling.app.Selection$Selector.$anonfun$singleSimulationFromConfig$2(Selection.scala:71)
at scala.util.Try$.apply(Try.scala:210)
at io.gatling.app.Selection$Selector.findUserDefinedSimulationInClassloader$1(Selection.scala:71)
... 15 common frames omitted
Exception in thread "main" java.lang.IllegalArgumentException: User defined Simulation class performance2.userSimulation could not be loaded
at io.gatling.app.Selection$Selector.findUserDefinedSimulationInClassloader$1(Selection.scala:80)
at io.gatling.app.Selection$Selector.$anonfun$singleSimulationFromConfig$4(Selection.scala:85)
at scala.Option.orElse(Option.scala:477)
at io.gatling.app.Selection$Selector.$anonfun$singleSimulationFromConfig$3(Selection.scala:85)
at scala.Option.flatMap(Option.scala:283)
at io.gatling.app.Selection$Selector.singleSimulationFromConfig(Selection.scala:83)
at io.gatling.app.Selection$Selector.$anonfun$selection$1(Selection.scala:52)
at scala.Option.getOrElse(Option.scala:201)
at io.gatling.app.Selection$Selector.selection(Selection.scala:44)
at io.gatling.app.Selection$.apply(Selection.scala:36)
at io.gatling.app.Runner.run0(Runner.scala:61)
at io.gatling.app.Runner.run(Runner.scala:49)
at io.gatling.app.Gatling$.start(Gatling.scala:83)
at io.gatling.app.Gatling$.fromArgs(Gatling.scala:45)
at io.gatling.app.Gatling$.main(Gatling.scala:37)
at io.gatling.app.Gatling.main(Gatling.scala)
Caused by: java.lang.ClassNotFoundException: performance2.userSimulation
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at io.gatling.app.Selection$Selector.$anonfun$singleSimulationFromConfig$2(Selection.scala:71)
at scala.util.Try$.apply(Try.scala:210)
at io.gatling.app.Selection$Selector.findUserDefinedSimulationInClassloader$1(Selection.scala:71)
... 15 more
> Task :gatlingRun FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':gatlingRun'.
> Process 'command 'C:\Program Files\Amazon Corretto\jdk1.8.0_282\bin\java.exe'' finished with non-zero exit value 1
* 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 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.9.1/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 44s
3 actionable tasks: 1 executed, 2 up-to-date
The package name is performance but inside the log it says:
performance2.userSimulation
Can you change it to in the run command:
performance.userSimulation
I think that is the issue you are facing. It cant find the simulation class.
I am able to connect cloud mysql server if I use hardcoded without externalizing it password=ravi#123 instead of the below, but at the moment I use the below format in order to use the value from the environment variable, it fails in spring boot. A hostname is our azure managed MySQL server host.
I googled enough StackOverflow solutions and tried multiple other options along with character encoding adding to connection string URL still no luck!
characterEncoding=UTF-8
url=jdbc:mysql://${mysql_host:hostname}:${mysql_port:3306}/ravidb?useUnicode=true&characterEncoding=UTF-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC&useSSL=false&autoReconnect=true&allowPublicKeyRetrieval=true
Could anybody help me to understand what I am missing? And what is the possible fix considering I have no option of modifying username or password?
application.yaml
spring:
profiles:
active: development
jackson:
serialization:
fail-on-empty-beans: false
datasource:
driver-class-name: org.mariadb.jdbc.Driver
type: com.zaxxer.hikari.HikariDataSource
url: jdbc:mariadb://${mysql_host:hostname}:${mysql_port:3306}/ravidb?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC&useSSL=false&autoReconnect=true&allowPublicKeyRetrieval=true
username: ${mysql_user:ravi#ravidb}
password: ${mysql_password:ravi#123}
hikari:
auto-commit: true
connection-timeout: 20000
idle-timeout: 300000
max-lifetime: 1200000
maximum-pool-size: 12
minimum-idle: 5
jpa:
properties:
hibernate:
dialect: org.hibernate.dialect.MariaDBDialect
format_sql: true
id:
new_generator_mappings: false
build.gradle
plugins {
id 'org.springframework.boot' version '2.3.9.RELEASE'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id 'org.asciidoctor.convert' version '1.5.8'
id 'java'
id 'groovy'
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.springframework.boot:spring-boot-starter-web'
compileOnly 'org.projectlombok:lombok'
runtimeOnly 'com.h2database:h2'
annotationProcessor 'org.projectlombok:lombok'
testImplementation('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
}
testImplementation 'org.springframework.restdocs:spring-restdocs-mockmvc'
testCompile 'org.spockframework:spock-core:1.3-groovy-2.5'
testCompile 'org.spockframework:spock-spring:1.3-groovy-2.5'
compile 'org.apache.commons:commons-lang3:3.11'
compile 'org.javassist:javassist:3.24.0-GA'
runtime 'mysql:mysql-connector-java'
runtime 'org.mariadb.jdbc:mariadb-java-client:2.7.1'
compile 'junit:junit:4.12'
implementation 'org.mapstruct:mapstruct:1.3.1.Final'
implementation group: 'com.google.guava', name: 'guava', version: '23.0'
annotationProcessor 'org.mapstruct:mapstruct-processor:1.3.1.Final'
testAnnotationProcessor 'org.mapstruct:mapstruct-processor:1.3.1.Final'
}
I wondered to see it worked if I just change key name mysql_password to mysql_pass
Issue reslved with this change:
spring.datasource.password=${mysql_pass:ravi#123}
We are trying to upgrade our project through build.gradle dependencies :
build.gradle file:
buildscript {
ext {
springBootVersion = '2.3.3.RELEASE'
}
repositories {
mavenCentral()
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
classpath('se.transmode.gradle:gradle-docker:1.2')
}
}
group = 'testing'
version = '0.0.1-SNAPSHOT'
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: "jacoco"
apply from: 'docker.gradle'
sourceCompatibility = 1.8
bootJar {
launchScript()
}
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-actuator'
compile ('org.springframework.boot:spring-boot-starter-data-jpa')
compile ('org.springframework.boot:spring-boot-starter-web')
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.flywaydb:flyway-core'
runtime 'mysql:mysql-connector-java:5.1.47'
implementation 'com.zaxxer:HikariCP'
annotationProcessor('org.hibernate:hibernate-jpamodelgen')
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.mobile:spring-mobile-device:1.1.5.RELEASE'
implementation 'io.jsonwebtoken:jjwt-api:0.10.5'
runtimeOnly 'io.jsonwebtoken:jjwt-impl:0.10.5'
runtimeOnly 'io.jsonwebtoken:jjwt-jackson:0.10.5'
implementation 'com.amazonaws:aws-java-sdk-s3:1.11.136'
implementation 'org.springframework.boot:spring-boot-starter-mail'
implementation 'org.springframework.boot:spring-boot-starter-freemarker'
implementation 'org.springframework.boot:spring-boot-starter-tomcat'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
testCompile('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
}
testImplementation('org.springframework.security:spring-security-test')
compile 'com.h2database:h2'
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
implementation 'org.apache.commons:commons-lang3'
implementation 'com.univocity:univocity-parsers:2.7.6'
implementation 'org.quartz-scheduler:quartz:2.2.1'
implementation 'org.apache.poi:poi:3.17'
implementation 'org.apache.poi:poi-ooxml:3.17'
}
test.reports.junitXml.setDestination(file("${buildDir}/test-results"))
jacocoTestReport {
reports {
html.destination file("${buildDir}/jacocoHtml")
}
}
sourceSets {
main {
java {
srcDirs += "src/jpaModelgen/java"
}
}
}
compileJava {
options.compilerArgs += ['-AaddGenerationDate=true'] // Specific to Hibernate JPA meta model generation processor.
options.annotationProcessorGeneratedSourcesDirectory = file("src/jpaModelgen/java")
}
application.properties file:
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.jpa.database=mysql
spring.data.jpa.repositories.enabled=true
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect
spring.datasource.url= jdbc:mysql://MyDB:3306/myschema
spring.datasource.username= testing
spring.datasource.password= root
spring-boot from version 1.5.7 to 2.3.3
Gradle from versionGradle-4.8-all to Gradle-6.4.1-all
while we run aplication in localy we get folowing output in log,
o.f.c.internal.database.DatabaseFactory : Database: jdbc:mysql://MyDB:3306/myschema (MySQL 5.7)
when we deploy this same code to AWS Elastic Beanstalk,
We are getting the following error:
Error creating bean with name 'flywayInitializer' defined in class path resource [org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration$FlywayConfiguration.class]: Invocation of init method failed; nested exception is org.flywaydb.core.internal.command.DbMigrate$FlywayMigrateException:
Migration V3__Sequence_Table.sql failed
---------------------------------------
SQL State : 42001
Error Code : 42001
Message : Syntax error in SQL statement "DELIMITER[*]
JDBC connection URL has been changed as below now,
o.f.c.internal.database.DatabaseFactory : Database: jdbc:h2:mem:testdb (H2 1.4)
Is this the cause of the above flyway migration error or Docker version error?
problem:
Run command for jar file is a problem for this project `
Dspring.config.location=run.properties this commad execute only run.properties
solution:
Instead of the above run command, I have tried this run command for the jar file
Dspring.config.additional-location=run.properties
this was working well
I'm trying to use jooq to load configurations automatically from gradle but had a hard time following the guide.
I finally have it loading data, but so far I can only get all databases to work (by having the database() chunk be blank).
My code below has my attempt to load only one database.
buildscript {
repositories {
mavenCentral()
maven {
name 'JFrog OSS snapshot repo'
url 'https://oss.jfrog.org/oss-snapshot-local/'
}
jcenter()
}
dependencies {
classpath 'org.jooq:jooq-codegen:3.9.1'
classpath group: 'mysql', name: 'mysql-connector-java', version: '6.0.6'
}
}
apply plugin: 'application'
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'antlr'
repositories {
mavenLocal()
mavenCentral()
jcenter()
}
dependencies {
//compile group: 'com.github.javaparser', name: 'javaparser-core', version: '3.0.0-alpha.2'
compile group: 'com.github.javaparser', name: 'java-symbol-solver-core', version: '0.5.2'
compile 'org.jooq:jooq:3.9.1'
runtime group: 'mysql', name: 'mysql-connector-java', version: '6.0.6'
testCompile "junit:junit:latest.release"
}
idea {
module {
excludeDirs += file('src/main/resources')
}
}
// Use your favourite XML builder to construct the code generation configuration file
// ----------------------------------------------------------------------------------
def writer = new StringWriter()
def xml = new groovy.xml.MarkupBuilder(writer)
.configuration('xmlns': 'http://www.jooq.org/xsd/jooq-codegen-3.9.0.xsd') {
jdbc() {
driver('com.mysql.cj.jdbc.Driver')
url('jdbc:mysql://127.0.0.1/graphUpgrade?serverTimezone=UTC')
user('parseUser')
password('password')
}
generator() {
database() {
name('org.jooq.util.mysql.MySQLDatabase')
inputSchema('graphUpgrade')
includes('.*')
}
// Watch out for this caveat when using MarkupBuilder with "reserved names"
// - https://github.com/jOOQ/jOOQ/issues/4797
// - http://stackoverflow.com/a/11389034/521799
// - https://groups.google.com/forum/#!topic/jooq-user/wi4S9rRxk4A
generate([:]) {
pojos true
daos true
}
target() {
packageName('us.klingman.codeParser.db')
directory('src/main/java')
}
}
}
print writer.toString()
// Run the code generator
// ----------------------
org.jooq.util.GenerationTool.generate(
javax.xml.bind.JAXB.unmarshal(new StringReader(writer.toString()), org.jooq.util.jaxb.Configuration.class)
)
Running this code produces the following error:
Error while fetching tables
java.lang.NullPointerException
at org.jooq.util.AbstractElementContainerDefinition.<init>(AbstractElementContainerDefinition.java:79)
at org.jooq.util.AbstractElementContainerDefinition.<init>(AbstractElementContainerDefinition.java:75)
at org.jooq.util.AbstractTableDefinition.<init>(AbstractTableDefinition.java:68)
at org.jooq.util.mysql.MySQLTableDefinition.<init>(MySQLTableDefinition.java:70)
at org.jooq.util.mysql.MySQLDatabase.getTables0(MySQLDatabase.java:256)
at org.jooq.util.AbstractDatabase.getTables(AbstractDatabase.java:1137)
at org.jooq.util.AbstractDatabase.getTable(AbstractDatabase.java:1163)
at org.jooq.util.AbstractDatabase.getTable(AbstractDatabase.java:1158)
at org.jooq.util.mysql.MySQLDatabase.getEnums0(MySQLDatabase.java:295)
at org.jooq.util.AbstractDatabase.getEnums(AbstractDatabase.java:1182)
at org.jooq.util.JavaGenerator.generateSchemaIfEmpty(JavaGenerator.java:334)
at org.jooq.util.JavaGenerator.generateCatalogIfEmpty(JavaGenerator.java:323)
at org.jooq.util.JavaGenerator.generate(JavaGenerator.java:297)
at org.jooq.util.GenerationTool.run(GenerationTool.java:610)
at org.jooq.util.GenerationTool.generate(GenerationTool.java:199)
at org.jooq.util.GenerationTool$generate.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at build_87hklhc6v691dvh83y5ogqnvl.run(/Users/lorenklingman/Sites/code-search-parser/build.gradle:79)
at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:74)
Finally, for completeness, here are the files generated for all databases.
I believe you've run into this problem here: #5213
Be sure to always use the exact upper/lower case writing of your database name also in the jOOQ configuration. Also, there are some caveats with case sensitivity in MySQL and MariaDB, depending on the operating system. These caveats can affect other tools than jOOQ. The relevant info is also in #5213.
I have set up a grails app using grails 3.0.9
Now I want to add the mysql connector to bring up an connection to a mysql database.
Therefore I have added an entry to my build.gradle, but the connector is not fetched by gradle.
buildscript {
ext {
grailsVersion = project.grailsVersion
}
repositories {
mavenLocal()
maven { url "https://repo.grails.org/grails/core" }
}
dependencies {
classpath "org.grails:grails-gradle-plugin:$grailsVersion"
classpath "com.bertramlabs.plugins:asset-pipeline-gradle:2.5.0"
classpath "org.grails.plugins:hibernate:4.3.10.5"
classpath "mysql:mysql-connector-java:5.1.37"
}
}
plugins {
id "io.spring.dependency-management" version "0.5.2.RELEASE"
}
version "0.1"
group "nexttext"
apply plugin: "spring-boot"
apply plugin: "war"
apply plugin: "asset-pipeline"
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: "org.grails.grails-web"
apply plugin: "org.grails.grails-gsp"
ext {
grailsVersion = project.grailsVersion
gradleWrapperVersion = project.gradleWrapperVersion
}
assets {
minifyJs = true
minifyCss = true
}
repositories {
mavenLocal()
maven { url "https://repo.grails.org/grails/core" }
}
dependencyManagement {
imports {
mavenBom "org.grails:grails-bom:$grailsVersion"
}
applyMavenExclusions false
}
dependencies {
compile "org.springframework.boot:spring-boot-starter-logging"
compile "org.springframework.boot:spring-boot-starter-actuator"
compile "org.springframework.boot:spring-boot-autoconfigure"
compile "org.springframework.boot:spring-boot-starter-tomcat"
compile "org.grails:grails-dependencies"
compile "org.grails:grails-web-boot"
compile "org.grails.plugins:hibernate"
compile "org.grails.plugins:cache"
compile "org.hibernate:hibernate-ehcache"
compile "org.grails.plugins:scaffolding"
runtime "org.grails.plugins:asset-pipeline"
testCompile "org.grails:grails-plugin-testing"
testCompile "org.grails.plugins:geb"
// Note: It is recommended to update to a more robust driver (Chrome, Firefox etc.)
testRuntime 'org.seleniumhq.selenium:selenium-htmlunit-driver:2.44.0'
console "org.grails:grails-console"
}
task wrapper(type: Wrapper) {
gradleVersion = gradleWrapperVersion
}
Don't know what I am doing wrong but I get an ClassNotFoundException.
Add runtime "mysql:mysql-connector-java:5.1.37" to your dependencies (Right under runtime "org.grails.plugins:asset-pipeline"). Then compile it. That should do the trick.
In my Grails 3 project I don't have a classpath to the connector, so I think it is save to remove it there.
Also don't forget to add these lines to your application.yml under your dataSource:
driverClassName: com.mysql.jdbc.Driver
dialect: org.hibernate.dialect.MySQL5InnoDBDialect
Adding a local gradle installation to Intellij seems to solve the problem. I think that the included gradle-wrapper caused the trouble.
So downloading gradle 2.8 and setting it to use in Settings -> Build... -> Build Tools -> Gradle solved the problem.
Now the mysql connector is showing up under External Libraries
Gradle: mysql:mysql-connector-java:5.1.37