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"
Related
I have encrypted passwords in runtime.groovy config file for three environments development, test, and production. when i run application in development env its starting fine with the password list in runtime.groovy file, but when I build war file for test env and run its not taking username and password from runtime.groovy file. Any idea?
environments {
development {
dataSource {
username = 'am'
password = new AesService().decode('encrypted_password')
}
}
test {
dataSource {
username = 'am'
password = new AesService().decode('encrypted_password')
}
}
production {
dataSource {
username = 'am'
password = new AesService().decode('encrypted_password')
}
}
}
command i used to build war file:
./gradlew -Dgrails.env=test assemble --stacktrace
getting following error msg in test env
Caused by: java.sql.SQLException: Access denied for user ''#'a.b.c.com' (using password: NO)
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.
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.
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.
When my Grails application crashes, it shows the error and the stacktrace on the error page because the error.gsp page has the following snippet <g:renderException exception="${exception}" />. However nothing gets logged in the log file.
How can I change this? because for the production application I plan to remove the renderException because I don't want users to see the entire stacktrace.
My log4j settings are as follows:
appenders {
rollingFile name:'catalinaOut', maxFileSize:1024, fileName:"${System.properties.getProperty('catalina.home')}/logs/mylog.log"
}
root {
error 'catalinaOut'
debug 'catalinaOut'
additivity = true
}
error 'org.codehaus.groovy.grails.web.servlet', // controllers
'org.codehaus.groovy.grails.web.pages', // GSP
'org.codehaus.groovy.grails.web.sitemesh', // layouts
'org.codehaus.groovy.grails.web.mapping.filter', // URL mapping
'org.codehaus.groovy.grails.web.mapping', // URL mapping
'org.codehaus.groovy.grails.commons', // core / classloading
'org.codehaus.groovy.grails.plugins', // plugins
'org.codehaus.groovy.grails.orm.hibernate', // hibernate integration
'org.springframework',
'org.hibernate',
'net.sf.ehcache.hibernate',
'grails.app'
debug 'grails.app'
}
I'm running the app in development as grails run-app
I use these settings for console and file based logging. You can remove stdout if you don't want/need console. Just copy all your error classes in the corresponding list.
log4j = {
def loggerPattern = '%d %-5p >> %m%n'
def errorClasses = [] // add more classes if needed
def infoClasses = ['grails.app.controllers.myController'] // add more classes if needed
def debugClasses = [] // add more classes if needed
appenders {
console name:'stdout', layout:pattern(conversionPattern: loggerPattern)
rollingFile name: "file", maxFileSize: 1024, file: "./tmp/logs/logger.log", layout:pattern(conversionPattern: loggerPattern)
}
error stdout: errorClasses, file: errorClasses
info stdout: infoClasses, file: infoClasses
debug stdout: debugClasses, file: debugClasses
}