VaadinOnKotlin.dataSource undefined - vaadin

I'm new to web development and started experimenting with VaadinOnKotlin. In Bootstrap.kt I have this code
val cfg = HikariConfig().apply {
jdbcUrl = "jdbc:postgresql://localhost:5432/test_db"
username = "joe"
password = "public"
}
cfg.driverClassName = org.postgresql.Driver::class.java.getName()
JdbiOrm.setDataSource(HikariDataSource(cfg))
VaadinOnKotlin.init()
val flyway = Flyway.configure()
.dataSource(VaadinOnKotlin.dataSource)
.load()
flyway.migrate()
VaadinOnKotlin.dataSource or VaadinOnKotlin.getDataSource() are undefined.
They get defined if I import eu.vaadinonkotlin.sql2o.dataSource, but doing that causes following crash
java.lang.NoSuchMethodError: 'void com.github.vokorm.VokOrm.init()'
at eu.vaadinonkotlin.sql2o.VokOrmPlugin.init(VokOrmPlugin.kt:12) ~[na:na]
at eu.vaadinonkotlin.VaadinOnKotlin.init(VaadinOnKotlin.kt:17) ~[na:na]
at com.smartiops.epsilon.Bootstrap.contextInitialized(Bootstrap.kt:59) ~[na:na]
Could this be a version issue? I see this in my build.gradle.kts
plugins {
kotlin("jvm") version "1.3.72"
id("org.gretty") version "3.0.3"
war
id("com.vaadin") version "0.8.0"
}
thanks for your help

I figured out what I was doing wrong. In build.gradle.kts I had to add
dependencies {
implementation("eu.vaadinonkotlin:vok-framework-vokdb:0.8.2")
}
and in Bootstrap.kts I had to add
import eu.vaadinonkotlin.vokdb.dataSource

Related

Jetpack compose PreviewParameter annotaion is not injecting provider class

I'm trying to preview my card composeable function which takes a custom parametrs.
My card composeable preview function is not rendered in the preview tab and when trying to deploy the preview into a device the app crashes and by inspecting the log I found that the parameter passed into my card composeable preview is returning null even though it's annotaited with #PreviewParameter and passed in a parameter provider class implementing the PreviewParameterProvider<*> interface.
I've noticed one line in the log that got my attention:
D/PreviewActivity: Previewing PokemonCardPreview without a parameter provider.
for some reason my parameter provider class is not being detected by PreviewActivity.
PokemonCardPreview
#Preview("Pokemon Card")
#Composable
fun PokemonCardPreview(
#PreviewParameter(PokedexEntryListParameterProvider::class) fakePokedex: PokedexListEntry,
navController: NavHostController = rememberNavController()
){
PokedexEntry(entry = fakePokedex, navController)
}
PokedexEntryListParameterProvider
class PokedexEntryListParameterProvider : PreviewParameterProvider<PokedexListEntry> {
override val values = sequenceOf(
PokedexListEntry(pokemonName = "ditto",
imageUrl = "https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/132.png",
pokemonNumber = 132)
)
}
Log Error
D/PreviewActivity: Previewing 'PokemonCardPreview' without a parameter provider.
D/AndroidRuntime: Shutting down VM
E/AndroidRuntime: FATAL EXCEPTION: main
Process: io.blacketron.jetpackcomposepokedex, PID: 4987
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947) 
Caused by: java.lang.ClassNotFoundException: Composable Method 'io.blacketron.jetpackcomposepokedex.util.preview.PreviewsKt.PokemonCardPreview' not found
at androidx.compose.ui.tooling.preview.PreviewUtilsKt.invokeComposableViaReflection(PreviewUtils.kt:188)
at androidx.compose.ui.tooling.preview.PreviewActivity$setComposableContent$2.invoke(PreviewActivity.kt:74)
at androidx.compose.ui.tooling.preview.PreviewActivity$setComposableContent$2.invoke(PreviewActivity.kt:73)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:109)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
at androidx.compose.ui.platform.ComposeView.Content(ComposeView.android.kt:346)
at androidx.compose.ui.platform.AbstractComposeView$ensureCompositionCreated$1.invoke(ComposeView.android.kt:202)
at androidx.compose.ui.platform.AbstractComposeView$ensureCompositionCreated$1.invoke(ComposeView.android.kt:201)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:109)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:193)
at androidx.compose.ui.platform.CompositionLocalsKt.ProvideCommonCompositionLocals(CompositionLocals.kt:148)
at androidx.compose.ui.platform.AndroidCompositionLocals_androidKt$ProvideAndroidCompositionLocals$3.invoke(AndroidCompositionLocals.android.kt:114)
at androidx.compose.ui.platform.AndroidCompositionLocals_androidKt$ProvideAndroidCompositionLocals$3.invoke(AndroidCompositionLocals.android.kt:113)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:109)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:193)
at androidx.compose.ui.platform.AndroidCompositionLocals_androidKt.ProvideAndroidCompositionLocals(AndroidCompositionLocals.android.kt:106)
at androidx.compose.ui.platform.WrappedComposition$setContent$1$1$3.invoke(Wrapper.android.kt:162)
at androidx.compose.ui.platform.WrappedComposition$setContent$1$1$3.invoke(Wrapper.android.kt:161)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:109)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:193)
at androidx.compose.ui.platform.WrappedComposition$setContent$1$1.invoke(Wrapper.android.kt:161)
at androidx.compose.ui.platform.WrappedComposition$setContent$1$1.invoke(Wrapper.android.kt:144)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:109)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34)
at androidx.compose.runtime.ComposerKt.invokeComposable(Composer.kt:3433)
at androidx.compose.runtime.ComposerImpl.composeContent$runtime_release(Composer.kt:2615)
at androidx.compose.runtime.CompositionImpl.composeContent(Composition.kt:348)
at androidx.compose.runtime.Recomposer.composeInitial$runtime_release(Recomposer.kt:702)
at androidx.compose.runtime.CompositionImpl.setContent(Composition.kt:304)
at androidx.compose.ui.platform.WrappedComposition$setContent$1.invoke(Wrapper.android.kt:144)
E/AndroidRuntime: at androidx.compose.ui.platform.WrappedComposition$setContent$1.invoke(Wrapper.android.kt:135)
at androidx.compose.ui.platform.AndroidComposeView.setOnViewTreeOwnersAvailable(AndroidComposeView.android.kt:655)
at androidx.compose.ui.platform.WrappedComposition.setContent(Wrapper.android.kt:135)
at androidx.compose.ui.platform.WrappedComposition.onStateChanged(Wrapper.android.kt:187)
at androidx.lifecycle.LifecycleRegistry$ObserverWithState.dispatchEvent(LifecycleRegistry.java:354)
at androidx.lifecycle.LifecycleRegistry.addObserver(LifecycleRegistry.java:196)
at androidx.compose.ui.platform.WrappedComposition$setContent$1.invoke(Wrapper.android.kt:142)
at androidx.compose.ui.platform.WrappedComposition$setContent$1.invoke(Wrapper.android.kt:135)
at androidx.compose.ui.platform.AndroidComposeView.onAttachedToWindow(AndroidComposeView.android.kt:719)
at android.view.View.dispatchAttachedToWindow(View.java:20479)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3489)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3496)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3496)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3496)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3496)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2417)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1952)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:8171)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:972)
at android.view.Choreographer.doCallbacks(Choreographer.java:796)
at android.view.Choreographer.doFrame(Choreographer.java:731)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:957)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7656)
... 3 more
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at androidx.compose.ui.tooling.preview.PreviewUtilsKt.invokeComposableMethod(PreviewUtils.kt:141)
at androidx.compose.ui.tooling.preview.PreviewUtilsKt.invokeComposableViaReflection(PreviewUtils.kt:180)
... 61 more
Caused by: java.lang.NullPointerException: Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkNotNullParameter, parameter fakePokedex
at io.blacketron.jetpackcomposepokedex.util.preview.PreviewsKt.PokemonCardPreview(Unknown Source:2)
... 64 more

Kotlin/native cinterop build problem with gradle

I'm experimenting with Kotlin native and iOS. I tried to use the example at raywenderlich as a starting point. This example is a bit old , so I have updated the code to fit the Kotlin multiplatform 1.3.61. I'm using AppCode to build the code.
I'm struggling with the Kotlin DSL gradle file ( build.gradle.kts) , the example is using build.gradle :
plugins {
id "org.jetbrains.kotlin.platform.native" version "1.3.0"
}
components.main {
def productsDir = new File("").absolutePath
targets = ['ios_arm64', 'ios_x64']
outputKinds = [EXECUTABLE]
allTargets {
linkerOpts '-rpath', '#executable_path/Frameworks'
linkerOpts "-F${productsDir}"
}
dependencies {
cinterop('AFNetworking'){
packageName 'com.afnetworking'
compilerOpts "-F${productsDir}"
linkerOpts "-F${productsDir}"
includeDirs{
allHeaders "${productsDir}/AFNetworking.framework/Headers"
}
}
}
}
task copyExecutable() {
doLast {
def srcFile = tasks['compileDebugIos_x64KotlinNative'].outputFile
def targetDir = getProperty("konan.configuration.build.dir")
copy {
from srcFile.parent
into targetDir
}
}
}
I have tried to translate this into the build.gradle.kts file of my own :
plugins {
kotlin("multiplatform") version "1.3.61"
kotlin("xcode-compat") version "0.2.5"
}
repositories {
mavenCentral()
}
kotlin {
val productsDir = "/Users/trond/Desktop/native_meteor/native_meteor/"
iosX64("ios")
{
compilations.getByName("main")
{
val myInterop by cinterops.creating {
defFile(project.file("src/nativeInterop/cinterop/afnetworking.def"))
packageName ("com.afnetworking")
compilerOpts ("-F${productsDir}")
// linkerOpts ("-F${productsDir}")
// 3
includeDirs{
allHeaders ("${productsDir}/AFNetworking.framework/Headers")
}
}
}
}
xcode {
setupApplication("native_meteor")
}
}
From what I can see the cinterops tool is doing it's job and is creating a klib file and a afnetworing.kt ( build/classes/kotlin/ios/main/..... )
But the I'm not able to use the library AFNetworking! I try to add the import directive in the ViewController.kt file :
import com.afnetworking.*
But this is not recognized. This results in that the project is not building :
> Task :native_meteor:compileKotlinNative_meteor FAILED
e: /Users/trond/Desktop/native_meteor/native_meteor/src/native_meteorMain/kotlin/ViewController.kt: (15, 8): Unresolved reference: com
e: /Users/trond/Desktop/native_meteor/native_meteor/src/native_meteorMain/kotlin/ViewController.kt: (37, 23): Unresolved reference: AFHTTPSessionManager
e: /Users/trond/Desktop/native_meteor/native_meteor/src/native_meteorMain/kotlin/ViewController.kt: (40, 38): Unresolved reference: AFJSONResponseSerializer
Anyone that can shed some light on this ?
Maybe it will make sense to check the contents of your result .klib to make sure you use the correct package name. It can be done using ~/.konan/kotlin-native-macos-1.3.61/bin/klib CLI tool. Also, I would recommend you to take a look at this sample from the Kotlin/Native Github, it also utilizes AFNetworking and uses the latest compiler version.
Thank you for pointing me in that direction. I investigated the .klib file, and I discovered that it contained the package that I expected. I then took a look at the Gradle sourcsets that I had in the Gradle pane in Appcode. Here I discovered that the .klib library was defined under "iosMain" and not "native_metorMain". I then found out that the line iosX64("ios") should be iosX64("meteor_main").
After that I got an error : "ld: framework not found AFNetworking" when I tried to compile in XCode. I then added -F{full path to framework} for the linkerOpts ( linkerOpts= -F{full path to framwork} -framework AFNetworking ) in the afnetworking.def file.
Now the project builds successfully.

Is there an option in Jenkins to find a particular value from a console output by passing a key and post it in slack channel?

I am currently using
Slack Notification Plugin(2.18) and integrated with jenkins and it works well with the default functionalities.
But, I am trying to find a particular value from console output of a job by passing a key. For example key is "Unique_ID" and I need to get its value from console output and post it in slack channel.
console output will look like:
00:23:53 Started by user user1
00:24:23 INFO: Unique_ID: 12uy87tg Entity: com.net.qa.rest.domain
Basically, I want to get the value 12uy87tg in slack channel when the build succeeded/failed by passing Unique_ID in the job config.
Can someone help me on this how to do it or let me know if there is an option in jenkins to post it in slack channel.
Tried the below code in Groovy Postbuild:
import java.io.BufferedReader;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
// Define the regex to extract the value you want
pattern = Pattern.compile("^.*Unique_ID: (.*) Entity.*");
uniqueId = null;
reader = null;
// Open the log of the build in a buffer
try{
reader = new BufferedReader(manager.build.getLogReader())
// Read the buffer and look for a match of the regex
while ((line = reader.readLine()) != null) {
Matcher matcher = pattern.matcher(line);
if (matcher.find()) {
// If there is a match, the value is stored and the research is over
uniqueId = matcher.group(1);
break;
}
}
}
finally{
// Close the buffer
if (reader != null) {
reader.close();
}
}
// If a value has been found, it is passed to the slack plugin
if (uniqueId != null){
// Get the instance of the slack plugin
def slack = manager.build.project.publishers.find{ k, v -> v.class.name == 'jenkins.plugins.slack.SlackNotifier' }?.value
// Set the custom message in Slack
slack.setIncludeCustomMessage(true)
slack.setCustomMessage("Unique_ID: "+uniqueId)
}
But the above code gave the below error
16:36:36 ERROR: Failed to evaluate groovy script.
16:36:36 groovy.lang.MissingMethodException: No signature of method: Script1$_run_closure1.call() is applicable for argument types: (org.jvnet.hudson.plugins.groovypostbuild.GroovyPostbuildRecorder) values: [org.jvnet.hudson.plugins.groovypostbuild.GroovyPostbuildRecorder#5df675b1]
16:36:36 Possible solutions: any(), any(), any(groovy.lang.Closure), each(groovy.lang.Closure), any(groovy.lang.Closure), each(groovy.lang.Closure)
16:36:36 at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:286)
16:36:36 at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022)
16:36:36 at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:810)
16:36:36 at groovy.lang.GroovyObjectSupport.invokeMethod(GroovyObjectSupport.java:46)
16:36:36 at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:48)
16:36:36 at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
16:36:36 at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
16:36:36 at org.codehaus.groovy.runtime.callsite.BooleanReturningMethodInvoker.invoke(BooleanReturningMethodInvoker.java:51)
16:36:36 at org.codehaus.groovy.runtime.callsite.BooleanClosureWrapper.call(BooleanClosureWrapper.java:53)
16:36:36 at org.codehaus.groovy.runtime.DefaultGroovyMethods.find(DefaultGroovyMethods.java:3934)
16:36:36 at org.codehaus.groovy.runtime.dgm$193.invoke(Unknown Source)
16:36:36 at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoMetaMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:274)
16:36:36 at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:56)
16:36:36 at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
16:36:36 at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
16:36:36 at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
16:36:36 at Script1.run(Script1.groovy:35)
16:36:36 at groovy.lang.GroovyShell.evaluate(GroovyShell.java:585)
16:36:36 at groovy.lang.GroovyShell.evaluate(GroovyShell.java:623)
16:36:36 at groovy.lang.GroovyShell.evaluate(GroovyShell.java:594)
16:36:36 at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SecureGroovyScript.evaluate(SecureGroovyScript.java:350)
16:36:36 at org.jvnet.hudson.plugins.groovypostbuild.GroovyPostbuildRecorder.perform(GroovyPostbuildRecorder.java:380)
16:36:36 at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
16:36:36 at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:744)
16:36:36 at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:690)
16:36:36 at hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.post2(MavenModuleSetBuild.java:1073)
16:36:36 at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:635)
16:36:36 at hudson.model.Run.execute(Run.java:1844)
16:36:36 at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:543)
16:36:36 at hudson.model.ResourceController.execute(ResourceController.java:97)
16:36:36 at hudson.model.Executor.run(Executor.java:429)
16:36:41 [Slack Notifications] found #8905 as previous completed, non-aborted build
16:36:41 [Slack Notifications] will send OnSuccessNotification because build matches and user preferences allow it
16:36:41 Finished: SUCCESS
You can do it with a groovy script.
First, download and install the Groovy plugin for Jenkins, and then add a step "Execute system Groovy script" in your job.
The script will be something like this:
import java.io.BufferedReader;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
// Define the regex to extract the value you want
pattern = Pattern.compile("^.*Unique_ID: (.*) Entity.*");
uniqueId = null;
reader = null;
// Open the log of the build in a buffer
try{
reader = new BufferedReader(build.getLogReader())
// Read the buffer and look for a match of the regex
while ((line = reader.readLine()) != null) {
Matcher matcher = pattern.matcher(line);
if (matcher.find()) {
// If there is a match, the value is stored and the research is over
uniqueId = matcher.group(1);
break;
}
}
}
finally{
// Close the buffer
if (reader != null) {
reader.close();
}
}
// If a value has been found, it is passed to the slack plugin
if (uniqueId != null){
// Get the instance of the slack plugin
def slack = build.project.publishers.find{ k, v -> v.class.name == 'jenkins.plugins.slack.SlackNotifier' }?.value
// Set the custom message in Slack
slack.setIncludeCustomMessage(true)
slack.setCustomMessage("Unique_ID: "+uniqueId)
}

Initialize Audit Trial Plugin in Jenkins using Groovy

My approach:
import hudson.plugins.audit_trail.AuditTrailPlugin
import hudson.plugins.jobConfigHistory.JobConfigHistory
import net.sf.json.JSONObject
def auditTrialPlugin = Jenkins.getInstance().getPlugin(AuditTrailPlugin.class)
// println(auditTrialPlugin.getConfigXml().asString())
println("Going to configure...")
def logger = new JSONObject()
logger.put("log", "Vibin")
logger.put("limit", "1")
logger.put("count", "2")
logger.put("stapler-class", "hudson.plugins.audit_trail.LogFileAuditLogger")
logger.put("\$class", "hudson.plugins.audit_trail.LogFileAuditLogger")
def plugin = new JSONObject()
plugin.put("name", "audit-trail")
plugin.put("pattern", "")
plugin.put("logBuildCause", true)
plugin.put("loggers", logger)
auditTrialPlugin.configure(null, plugin)
Error happening:
java.lang.NoSuchMethodException: hudson.plugins.audit_trail.LogFileAuditLogger.<init>()
at java.lang.Class.getConstructor0(Class.java:3082)
at java.lang.Class.newInstance(Class.java:412)
Caused: java.lang.InstantiationException: hudson.plugins.audit_trail.LogFileAuditLogger
at java.lang.Class.newInstance(Class.java:427)
at hudson.model.Descriptor.newInstance(Descriptor.java:578)
Caused: java.lang.Error: Failed to instantiate class hudson.plugins.audit_trail.LogFileAuditLogger from {"log":"Vibin","limit":"1","count":"2","stapler-class":"hudson.plugins.audit_trail.LogFileAuditLogger","$class":"hudson.plugins.audit_trail.LogFileAuditLogger"}
at hudson.model.Descriptor.newInstance(Descriptor.java:600)
at hudson.model.Descriptor.newInstancesFromHeteroList(Descriptor.java:1055)
at hudson.model.Descriptor.newInstancesFromHeteroList(Descriptor.java:1017)
at hudson.plugins.audit_trail.AuditTrailPlugin.configure(AuditTrailPlugin.java:78)
at hudson.plugins.audit_trail.AuditTrailPlugin$configure$1.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:133)
at Script1.run(Script1.groovy:24)
I tried to follow the code base of the plugin which I found on GitHub. There is a 'configure' function for the plugin which I tried to use which isn't working.
Codebase of plugin: GitHub link
Try this:
import jenkins.model.*;
import hudson.plugins.audit_trail.AuditTrailPlugin;
import hudson.plugins.audit_trail.LogFileAuditLogger;
def log = "Vibin"
def limit = 1
def count = 2
LogFileAuditLogger logFileAuditLogger = new LogFileAuditLogger(log, limit, count)
Jenkins j = Jenkins.getInstance();
AuditTrailPlugin plugin = j.getPlugin(AuditTrailPlugin.class);
plugin.loggers.clear()
plugin.loggers.add(logFileAuditLogger)
plugin.pattern = "" // empty pattern?
plugin.save()
plugin.start()
I think using LogFileAuditLogger class is more clear than 'configure' function.

Expired activiti jobs throwing exception while server startup - Grails

This is with regard to activiti workflow timer jobs in grails application.
While starting the grails app with expired jobs, exception is thrown for normal grails features such as log and methods of domain classes.
For eg:
Caused by: groovy.lang.MissingPropertyException: No such property: log for class: com.service.common.UtilityService
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:49)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassGetPropertySite.getProperty(PogoMetaClassGetPropertySite.java:50)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGroovyObjectGetProperty(AbstractCallSite.java:239)
at com.service.common.UtilityService.insertToQueue(UtilityService.groovy:370)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.activiti.engine.impl.javax.el.BeanELResolver.invoke(BeanELResolver.java:479)
... 71 more
This happens in dev environment running the app from Spring STS. We are using activiti plugin 5.8.2 for grails (1.3.6)
After the web-app is started up completely, the jobs (schedule to a time after startup) run properly and no missing property exception is thrown.
Even though we can fix the of missing property issue for log by using private static final log = LogFactory.getLog(this) instead, then any reference to domain classes throw an error, like using get or find method.
eg:
Caused by: groovy.lang.MissingMethodException: No signature of method: static com.domain.wr.WorkRequest.read() is applicable for argument types: (java.lang.String) values: [44700]
Possible solutions: getId(), getAt(java.lang.String), setId(java.lang.Long), grep(java.lang.Object), each(groovy.lang.Closure), find(groovy.lang.Closure)
at groovy.lang.MetaClassImpl.invokeStaticMissingMethod(MetaClassImpl.java:1357)
at groovy.lang.MetaClassImpl.invokeStaticMethod(MetaClassImpl.java:1343)
at groovy.lang.ExpandoMetaClass.invokeStaticMethod(ExpandoMetaClass.java:1082)
at org.codehaus.groovy.runtime.callsite.StaticMetaClassSite.call(StaticMetaClassSite.java:50)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:40)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:124)
at com.service.common.UtilityService.insertToQueue(UtilityService.groovy:373)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.activiti.engine.impl.javax.el.BeanELResolver.invoke(BeanELResolver.java:479)
... 71 more
Activiti Configuration
Config.groovy
// Added by the Grails Activiti plugin:
activiti {
processEngineName = "activiti-engine-default"
databaseType = "oracle"
deploymentName = appName
history = "audit" // "none", "activity", "audit" or "full"
sessionUsernameKey = "username"
useFormKey = true
deploymentResources = ["classpath:activiti/escalation/WorkRequest.bpmn20.xml"]
}
Config.properties
activiti.processEngineName =activiti-engine-default
activiti.databaseSchemaUpdate =true
activiti.jobExecutorActivate =true
activiti.mailServerHost = "mail1.net"
activiti.mailServerPort = 25
activiti.mailServerUsername = ""
activiti.mailServerPassword = ""
activiti.mailServerDefaultFrom = ""
This is killing my application as a downtime makes the workflow unusable with timer tasks.
I had more or less the same problem, and in our case was caused by Activiti starting jobs execution before Spring injection being finished. That's why it only happens at startup: the job is accessing properties that are not there yet.
You can confirm that you are in the same situation by increasing the RETRIES_ in the ACT_RU_JOB table after the app has finished bootstraping and see if the jobs execute successfully.
If this is your case, I think the only option is to upgrade the plugin and if still fails, create a bug.
This issue got solved.
1) Edit Config.groovy and disable activiti during startup
activiti {
processEngineName = "activiti-engine-default"
databaseType = "oracle"
disabled = true
deploymentName = appName
sessionUsernameKey = "username"
useFormKey = true
deploymentResources = []
}
2) add the initialization of Activiti Objects in the init method of User BootStrap
def init = { servletContext ->
org.springframework.context.ApplicationContext ctx = ServletContextHolder.getServletContext().getAttribute(GrailsApplicationAttributes.APPLICATION_CONTEXT)
def bb = new grails.spring.BeanBuilder(ctx)
bb.beans {
//println "Activiti Process Engine Initialization..."
customDbIdGenerator(com.mycompany.activiti.customDbIdGenerator){
idBlockSize=CH.config.activiti.idBlockSize?:100
}
processEngineConfiguration(org.activiti.spring.SpringProcessEngineConfiguration) {
processEngineName = CH.config.activiti.processEngineName?:ActivitiConstants.DEFAULT_PROCESS_ENGINE_NAME
databaseType = CH.config.activiti.databaseType?:ActivitiConstants.DEFAULT_DATABASE_TYPE
databaseSchemaUpdate = CH.config.activiti.databaseSchemaUpdate ? CH.config.activiti.databaseSchemaUpdate.toString() : ActivitiConstants.DEFAULT_DATABASE_SCHEMA_UPDATE
deploymentName = CH.config.activiti.deploymentName?:ActivitiConstants.DEFAULT_DEPLOYMENT_NAME
deploymentResources = CH.config.activiti.deploymentResources?:ActivitiConstants.DEFAULT_DEPLOYMENT_RESOURCES
jobExecutorActivate = CH.config.activiti.jobExecutorActivate?:ActivitiConstants.DEFAULT_JOB_EXECUTOR_ACTIVATE
history = CH.config.activiti.history?:ActivitiConstants.DEFAULT_HISTORY
mailServerHost = CH.config.activiti.mailServerHost?:ActivitiConstants.DEFAULT_MAIL_SERVER_HOST
mailServerPort = CH.config.activiti.mailServerPort?:ActivitiConstants.DEFAULT_MAIL_SERVER_PORT
mailServerUsername = CH.config.activiti.mailServerUsername
mailServerPassword = CH.config.activiti.mailServerPassword
mailServerDefaultFrom = CH.config.activiti.mailServerDefaultFrom?:ActivitiConstants.DEFAULT_MAIL_SERVER_FROM
dataSource = ref("dataSource")
transactionManager = ref("transactionManager")
idGenerator= ref("customDbIdGenerator")
}
processEngine(org.activiti.spring.ProcessEngineFactoryBean) {
processEngineConfiguration = ref("processEngineConfiguration")
}
runtimeService(processEngine:"getRuntimeService")
repositoryService(processEngine:"getRepositoryService")
taskService(processEngine:"getTaskService")
managementService(processEngine:"getManagementService")
identityService(processEngine:"getIdentityService")
historyService(processEngine:"getHistoryService")
formService(processEngine:"getFormService")
activitiService(org.grails.activiti.ActivitiService) {
runtimeService = ref("runtimeService")
taskService = ref("taskService")
identityService = ref("identityService")
formService = ref("formService")
}
}
println "## Registering Beans ##";
bb.registerBeans(ctx);
ctx.getBean("processEngine");
println "Bean Count2 "+ctx.getBeanDefinitionCount();
}
Please note that DB Id Generator used is custom and can be replaced by the default one.

Resources