Quartz not working in Grails4, Issue in dependency not able to compile - grails

Getting error in Scheduler Dependency i'm using grails4 :
Anyone let me know correct dependency for scheduler
dependencies {
compile "org.grails.plugins:quartz:2.0.1"
}
and also tried this:
dependencies {
compile "com.agileorbit:schwartz:1.0.1"
}
Both are not able to compile:
grails run-app
| Resolving Dependencies. Please wait...
| Running application...
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':compileGroovy'.
org/quartz/JobExecutionContext
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
BUILD FAILED in 10s
| Error Failed to start server (Use --stacktrace to see the full trace)

You will need to add the quartz dependency explicitly in addition to the plugin as Gradle 5 stopped pulling in transitive dependancies. Also I'd suggest using the latest version (2.0.13 vs 2.0.1 which is quite old)
buildscript {
dependencies {
classpath 'org.grails.plugins:quartz:2.0.13' // Needed to compile *Job classes
}
}
dependencies {
compile 'org.grails.plugins:quartz:2.0.13'
compile 'org.quartz-scheduler:quartz:2.2.1' // Is not pulled in by default
}

We're using quartz in grails4 applications with:
dependencies {
//...
compile("org.quartz-scheduler:quartz:2.2.3") {
exclude group: 'slf4j-api', module: 'c3p0'
}
compile ('org.grails.plugins:quartz:2.0.13')
}
here's the issue description on github: https://github.com/grails-plugins/grails-quartz/issues/107

Related

How to import a proprietary library in Grails 4.0.3

I am trying to import a proprietary jar lib (ICOMConector.jar) in my grails 4.0.3 project, but it is sending me an error.
In IntelliJ, I right-clicked the project folder and accessed Open Module Settings. Then I clicked in Libraries and chose my jar. Right after, clicked in Module / Dependencies and chose that jar in a compilation scope.
In build.gradle file I put this flatDir, because the jar in my project grails stardard structure:
repositories {
maven { url "https://repo.grails.org/grails/core" }
flatDir {
dirs 'lib'
}
}
And this in the same build.gradle, I've tried all of that, including those now commented,
but the error persists.
dependencies {
//implementation name: 'lib/ICOMConector.jar'
//runtime files('lib/ICOMConector.jar')
//runtime fileTree(dir: 'lib', include: '*.jar')
compile fileTree(dir: 'lib', include: ['*.jar'])
}
when I send grails run-app in the command line, the error is:
| Running application...
startup failed:
/media/alfredo/1TBHDD/CMB/Code projects/Grails 4/detran-mspid/grails-app/init/detran/mspid/BootStrap.groovy: 5: unable to resolve class com.workers.icom.ICOMConector
**# line 5, column 1.
import com.workers.icom.ICOMConector
^
1 error**
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileGroovy'.
> Compilation failed; see the compiler error output for details.
* 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
I tried to instantiate the class in Bootstrap.groovy, to make it easier to verify if it is working as expected.
Could anyone help me to import this library. A friend of mine did this in a Spring boot project and it worked, so the problem seems to be a wrong configuration in Grails.
package detran.mspid
import com.workers.icom.ICOMConector
class BootStrap {
def init = { servletContext ->
ICOMConector icom = new ICOMConector()
}
def destroy = {
}
}
This is what I have in my build.gradle for using a library in grails 4.0.3 (been this way since at least grails 3, though). This is almost identical to one you tried with runtime scope.
compile files("lib/opencsv-2.3.jar")
runtimeOnly fileTree(dir: './lib', include: ['*.jar'])
It's entirely possible that either one or both of those is unnecessary...

Custom Ant Task Not Working On Build Server

I've got a custom Ant task that I'm using successfully from gradle on my local machine:
task fetchRelMod {
doLast {
println 'Fetching the RelMod'
ant.taskdef(name:'relmod',
classpath:'retrievePBSInfo.jar:hsjt400-4-9.jar',
classname:"com.myco.ant.tasks.RetrievePBSRelModString")
ant.relmod(user:project.ext.props.getProperty('fetchrelmod.username'),
password:project.ext.props.getProperty('fetchrelmod.password'),
prodCode:project.ext.props.getProperty('profile.pbs.product.code'),
branch:project.ext.props.getProperty('profile.pbs.branch'),
state:project.ext.props.getProperty('profile.pbs.relmod.selector'))
project.ext.set('iseries_relmod',ant.relmodStub)
project.ext.set('iseries_relmodAndDate', ant.relmod)
}
}
I've got the jar files sitting next to build.gradle for now, out of simplicity... they exist in the same location on the build server. Works great locally. When I run my build from my build server (either through Jenkins or going on the box and running Gradle directly), I get the following:
sudo /var/lib/jenkins/tools/hudson.plugins.gradle.GradleInstallation/gradle214/bin/gradle all -DisQUABuild=true
Building My App
Loading Properties files...
QUA Build. Using build-qua.props
:fetchRelMod
Fetching the RelMod
:fetchRelMod FAILED
FAILURE: Build failed with an exception.
* Where:
Build file '/var/lib/jenkins/workspace/MyApp/build.gradle' line: 141
* What went wrong:
Execution failed for task ':fetchRelMod'.
> taskdef class com.myco.ant.tasks.RetrievePBSRelModString cannot be found
using the classloader AntClassLoader[/var/lib/jenkins/workspace/myApp/hsjt400-4-9.jar]
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 3.104 secs
What concerns me is that there are two jar files in the classpath and it only mentions one in the error. Does anyone have any ideas as to what might be going on?

Passing command Line Arguments for grails run-app through gradle task

I have a grails 3 application for which I am trying to pass command line arguments to my application when I am running it through gradle bootRun task.
I want to read the arguments in my config file for runtime operations. As per the grails documentation for yml configration here I tried to add the following to my build.gradle file
run {
systemProperties = System.properties
}
When I add that configuration and run my task I get the following error:
3:11:20 PM: Executing external task 'bootRun -Dcolor=red -Dfruit=apple'...
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\docs\projects\jet\build.gradle' line: 85
* What went wrong:
A problem occurred evaluating root project 'jet'.
> Could not find method run() for arguments [build_6lnm3xriwcnri1zrvfit1niuu$_run_closure8#4446881a] on root project 'jet'.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 8.892 secs
Could not find method run() for arguments [build_6lnm3xriwcnri1zrvfit1niuu$_run_closure8#4446881a] on root project 'jet'.
3:11:32 PM: External task execution finished 'bootRun -Dcolor=red -Dfruit=apple'.
Please let me know if there is anything I am missing here or if there is a better way of doing this.
So I find out what the issue was.
Grails 3.0 uses bootRun as target instead of run. Changing adding the below code fixed the issue.
bootRun {
systemProperties = System.properties
}
Hope this helps everyone.

ElasticSearch plugin causing server to stop in Grails 3.1.6

I'm trying to add ElasticSearch plugin in my Grails 3.1.6 project.
I installed plugin as:
dependencies {
//..
compile 'org.grails.plugins:elasticsearch:1.0.0.2'
//..}
And configured application.yml as
elasticSearch:
client:
node: local
datastoreImpl: hibernateDatastore
But when I try to run application, i'm getting error as below:
BUILD SUCCESSFUL
Total time: 5.118 secs
|Running application...
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':bootRun'.
> A problem occurred starting process 'command 'C:\Program Files\Java\jdk1.8.0_45\bin\java.exe''
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Error |
Failed to start server (Use --stacktrace to see the full trace)
Process finished with exit code 1
I'm using IntellijIdea v2016 as IDE.
Would someone please help me to figure out the error spot please.
Thanks.
This isn't related to the plugin, it's a Boot/Gradle problem caused by having a classpath that causes the process to fail because the combined length of the process command is larger than the max Windows allows. This was fixed in 3.1.2 but you have to add a small config setting to build.gradle since it's not a problem in Linux or OSX:
grails {
pathingJar = true
}
See https://github.com/grails/grails-core/issues/9125 for more info.

Gradle cannot find plugin

I have the following in my build.gradle of my Grails 3 project.
dependencies {
...
compile "org.grails.plugins:spring-security-core:3.0.3"
// The following line was the true cause of my problem
compile("org.grails.plugins:spring-security-oauth-google:0.3.1")
...
}
Now when I run Gradle I get this error:
Error Error initializing classpath: Could not find spring-security-core.zip (org.grails.plugins:spring-security-core:3.0.3).
Searched in the following locations:
https://repo.grails.org/grails/core/org/grails/plugins/spring-security-core/3.0.3/spring-security-core-3.0.3.zip (Use --stacktrace to see the full trace)
If I go to the specified path I do see the plugin but just as reported there is no zip file.
What am I doing wrong here?
The root for this problem I found in a little bit different place than expected.
I am working on upgrading a Grails 2.5 project to Grails 3 and I had lead myself on a wrong track. I needed to include spring-security-oauth-google and when it did not work as expected I also included spring-security-core which then derailed me.
The cause of this problem is dependencies being loaded from dependencies I have in my own project. In order to avoid loading those dependencies - called transitive dependencies - the following has to be done:
plugins {
compile "org.grails.plugins:spring-security-core:3.0.3"
compile("org.grails.plugins:spring-security-oauth-google:0.3.1") {
exclude group: 'org.grails.plugins', module: 'spring-security-core'
}
}
This will load the spring-security-core 3.0.3 correctly ignoring the dependency from spring-security-oauth-google.

Resources