Unable to deploy helm chart on remote kubernetes server using org.unbroken-dome.helm plugin - build.gradle

I prefer https://unbroken-dome.github.io/projects/gradle-helm-plugin/ gradle plugin to deploy one of my application using helm chart on remote kubernetes cluster.
Please find below code snippet :
plugin and import section :
plugins {
id 'org.unbroken-dome.helm' version '1.0.0'
id 'org.unbroken-dome.helm-commands' version '1.0.0'
}
import org.unbrokendome.gradle.plugins.helm.command.tasks.*
gradle task section :
helm {
kubeConfig = file('src/main/resources/helm/kubeconfig')
charts {
app_chart {
chartVersion = "1.0.0"
filtering {
values.put 'imageRepository', "test-repo/appImage"
values.put 'imageTag', "1.0.0"
}
sourceDir = file 'src/main/resources/helm/app-helm'
}
}
}
task installApp(type: HelmInstallOrUpgrade) {
releaseName = 'app-release'
from helm.charts.app_chart
}
Execute task by command : gradle installApp
But getting error like commandLine[index - 1] must not be null. Please help to solve this error. Thanks in advance to reply.

Related

Springboot version upgrade - my sql error while deploying in aws elastic beanstalk

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

How do I configure jooq with Gradle and Mysql for a single database

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.

dependency error in standalone build.gradle

I am trying to hit a remote script thru ssh using gradle...but I am getting certain error.
Below is the build file:
buildscript{
repositories {
maven {
println('Hello World')
url "https://adlm.nielsen.com/artifactory/plugins-release/"
credentials {
username '********'
password '********'
}
}
}
dependencies {
classpath group: 'org.hidetake', name: 'gradle-ssh-plugin', version: '2.7.0'
}
}
remotes {
web01 {
role 'webServers'
host = '********hetibd043.********'
user = '********'
password = '********'
}
}
task reload << {
ssh.run {
session(remotes.role('webServers')) {
execute 'pwd'
}
}
}
Below is the error:
* What went wrong:
A problem occurred evaluating root project 'bi'.
> Could not find method remotes() for arguments [build_dors3zgr32fbn8jukg7pqp34n$_run_closure1#70606922] on root project 'bi' of type org.gradle.api.Project.
Please help resolving this...Thanks.
Looks like that the plugin isn't applied. Therefore the method can't be found.
apply plugin: "org.hidetake.ssh"

Connection lost overnight (spring boot + mysql)

My spring boot application always show me this whitelabel error in the morning: Could not open JPA EntityManager for transaction; nested exception is javax.persistence.PersistenceException: org.hibernate.TransactionException: JDBC begin transaction failed:
I searched the web I think it might be that mysql closes the connection for 8 hours of inactive. However according to the document spring boot will automatically configure a pooling apache datasource. http://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-sql.html
I am not sure how to configure the application code or database.
Here is the build.gradle I am using:
buildscript {
ext {
springBootVersion = '1.2.3.RELEASE'
}
repositories {
maven { url "http://repo.spring.io/libs-snapshot" }
mavenLocal()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.2.3.RELEASE")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'spring-boot'
apply plugin: 'war'
apply plugin: 'application'
repositories {
mavenCentral()
maven { url "http://repo.spring.io/libs-snapshot" }
maven { url "http://maven.springframework.org/milestone" }
}
// Seems tomcat 8 doesn't work with paypal
configurations.all {
resolutionStrategy {
eachDependency {
if (it.requested.group == 'org.apache.tomcat.embed') {
it.useVersion '7.0.59'
}
}
}
}
dependencies {
compile("org.springframework.boot:spring-boot-starter-web:${springBootVersion}")
compile("org.springframework.boot:spring-boot-starter-tomcat:${springBootVersion}")
compile("org.springframework.boot:spring-boot-starter-actuator")
compile("org.springframework.boot:spring-boot-starter-mail:${springBootVersion}")
compile("org.springframework.boot:spring-boot-starter-aop:${springBootVersion}")
compile("org.springframework.boot:spring-boot-starter-test:${springBootVersion}")
compile("org.springframework.boot:spring-boot-starter-security:${springBootVersion}")
compile("org.springframework.boot:spring-boot-starter-data-jpa:${springBootVersion}")
compile("org.springframework.data:spring-data-rest-webmvc")
compile("javax.servlet:jstl:1.2")
compile("org.apache.logging.log4j:log4j-api:2.3")
compile("org.apache.logging.log4j:log4j-core:2.3")
compile("com.paypal.sdk:rest-api-sdk:1.2.1")
compile("com.opencsv:opencsv:3.4")
compile("mysql:mysql-connector-java:5.1.35")
compile("com.google.guava:guava:17.0")
compile("org.apache.httpcomponents:httpclient:4.3.4")
compile("com.squareup.retrofit:retrofit:1.6.0")
compile("commons-io:commons-io:2.4")
compile("org.apache.commons:commons-lang3:3.4")
compile("com.amazonaws:aws-java-sdk:1.9.34")
providedCompile("org.apache.tomcat.embed:tomcat-embed-jasper:8.0.22")
testCompile("junit:junit")
}
sourceCompatibility = 1.7
targetCompatibility = 1.7
war {
baseName = 'gs-convert-jar-to-war'
version = '0.1.0'
}
task wrapper(type: Wrapper) {
gradleVersion = '2.3'
}
Here is the database configurations in application.properties:
spring.datasource.url=jdbc:mysql://fakeurl:3306/qa
spring.datasource.username=username
spring.datasource.password=password
spring.datasource.driverClassName=com.mysql.jdbc.Driver
spring.jpa.database-platform=org.hibernate.dialect.MySQLDialect
#
# hibernate
#
spring.jpa.hibernate.ddl-auto=update
For the datasource I use spring data's repository:
#Repository
public interface EventRepository extends CrudRepository<EventDetail, Long> {
}
Here is the result against the mysql database running "show variables like '%timeout%':
'connect_timeout','10'
'delayed_insert_timeout','300'
'innodb_flush_log_at_timeout','1'
'innodb_lock_wait_timeout','50'
'innodb_rollback_on_timeout','OFF'
'interactive_timeout','28800'
'lock_wait_timeout','31536000'
'net_read_timeout','30'
'net_write_timeout','60'
'rpl_stop_slave_timeout','31536000'
'slave_net_timeout','3600'
'wait_timeout','28800'
Check this answer: Spring Boot JPA - configuring auto reconnect
In short, you'll need:
spring.datasource.testOnBorrow=true
spring.datasource.validationQuery=SELECT 1
You can also see this link
It tells you to include the following lines in the application.properties file.
spring.datasource.testWhileIdle = true
spring.datasource.timeBetweenEvictionRunsMillis = 3600000
spring.datasource.validationQuery = SELECT 1
You can fix this by setting the property wait_timeout = 31536000 in the DB Server. This is equivalent to one year.
In case if you DB is running in the AWS environment, go to Parameters group-> create a new group -> set wait_timeout = 31536000 and assign the newly created parameters group to your RDS instance.
If you want to fix this in the spring boot instance, you can fix by C3P0 settings only, but I haven't tried that.

Gradle loads mysql-connector jar but no dbunit jar as external dependencies, why?

Please give me some lights about what I'm doing wrong here. First of all I'm newbie with Gradle and Groovy and for learning purposes I'm playing with them and DBUnit.
I tried the code listed below, my goal is to generate a dataset getting the data from a mysql db.
import groovy.sql.Sql
import org.dbunit.database.DatabaseConnection;
import org.dbunit.database.IDatabaseConnection;
import org.dbunit.dataset.IDataSet;
import org.dbunit.dataset.xml.FlatXmlDataSet;
repositories {
mavenCentral()
}
configurations {
dbunit
}
dependencies {
dbunit 'dbunit:dbunit:2.2',
'junit:junit:4.11',
'mysql:mysql-connector-java:5.1.25'
}
URLClassLoader loader = GroovyObject.class.classLoader
configurations.dbunit.each { File file -> loader.addURL(file.toURL()) }
task listJars << {
configurations.dbunit.each { File file -> println file.name }
}
task listTables << {
getConnection("mydb").eachRow('show tables') { row -> println row[0] }
}
task generateDataSet << {
def IDatabaseConnection conn = new DatabaseConnection(getConnection("mydb").connection)
def IDataSet fullDataSet = conn.createDataSet()
FlatXmlDataSet.write(fullDataSet, new FileOutputStream("full.xml"))
}
static Sql getConnection(db) {
def props = [user: 'dbuser', password: 'userpass', allowMultiQueries: 'true'] as Properties
def url = (db) ? 'jdbc:mysql://host:3306/'.plus(db) : 'jdbc:mysql://host:3306/'
def driver = 'com.mysql.jdbc.Driver'
Sql.newInstance(url, props, driver)
}
What is weird to me is that all MySQL methods work well, I can get the list of tables and for instance the connection was done well so the mysql-connector-java.jar is being loaded (I think), but when I add the DBUnit stuff (import libs and the generateDataSet method) it seems the dbunit jar is not available for the script, I got the following errors:
FAILURE: Build failed with an exception.
* Where:
Build file '/home/me/tmp/dbunit/build.gradle' line: 5
* What went wrong:
Could not compile build file '/home/me/tmp/dbunit/build.gradle'.
> startup failed:
build file '/home/me/tmp/dbunit/build.gradle': 5: unable to resolve class org.dbunit.dataset.xml.FlatXmlDataSet
# line 5, column 1.
import org.dbunit.dataset.xml.FlatXmlDataSet;
^
build file '/home/me/tmp/dbunit/build.gradle': 2: unable to resolve class org.dbunit.database.DatabaseConnection
# line 2, column 1.
import org.dbunit.database.DatabaseConnection;
^
build file '/home/me/tmp/dbunit/build.gradle': 3: unable to resolve class org.dbunit.database.IDatabaseConnection
# line 3, column 1.
import org.dbunit.database.IDatabaseConnection;
^
build file '/home/me/tmp/dbunit/build.gradle': 4: unable to resolve class org.dbunit.dataset.IDataSet
# line 4, column 1.
import org.dbunit.dataset.IDataSet;
^
4 errors
But if I call the listJars task, I got this:
:listJars
junit-4.11.jar
mysql-connector-java-5.1.25.jar
hamcrest-core-1.3.jar
xercesImpl-2.6.2.jar
xmlParserAPIs-2.6.2.jar
junit-addons-1.4.jar
poi-2.5.1-final-20040804.jar
commons-collections-3.1.jar
commons-lang-2.1.jar
commons-logging-1.0.4.jar
dbunit-2.2.jar
BUILD SUCCESSFUL
Which in my understanding means all those jars were loaded and are available for the script, am I right? or am I doing something wrong with the class loader stuff?
Thanks very much.
The GroovyObject.class.classLoader.addURL hack is not the right way to add a dependency to the build script class path. It's just sometimes necessary to get JDBC drivers to work with Groovy (long story). Here is how you add a dependency to the build script class path:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath "some:library:1.0"
}
}
// library can be used in the rest of the build script
You can learn more about this in the Gradle User Guide.