quartz 2.1.7 giving NoClassDefFoundError in ant project - ant

We are using quartz in our ant project, and for logging we are using log4j.
Still now we are using quartz 1.5.2, and there were no problem. Now we want to upgrade it to quartz 2.1.7.
When we replace our quartz-all-1.5.2.jar with quartz-all-2.1.7.jar file, and starte the service, we are getting the following error
[QuartzService] Create QuartzService(Quartz)...
WARN [ServiceController] Problem creating service user:service=QuartzService,name=Quartz
java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
at org.quartz.impl.StdSchedulerFactory.<init>(StdSchedulerFactory.java:261)
at org.quartz.ee.jmx.jboss.QuartzService.createService(QuartzService.java:220)
at org.jboss.system.ServiceMBeanSupport.jbossInternalCreate(ServiceMBeanSupport.java:260)
at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:243)
[...]
we tried quartz 1.6.6 and 1.7.3, and we didn't have any issue with that. But from 1.8.4 onward we are getting the above error
Now the problem is, we are not using slf4j for logging. so,
Is there anyway to use quartz 2.1.7 with log4j only?
If we need to use slf4j, can we redirect logging to log4j somehow?
Can we do this in ant?
The project is ant project, not maven project.

Quartz 2.1.7 uses log4j with slf4j, so I think you need slf4j 1.6.1 (api, slf4j-log4j12)
Look at the dependencies of version 1.5.2 and version 2.1.7.

Related

Upgrading a plugin fails going from Grails 3.1.11 to 3.2.2

I'm working on a Grails plugin whose main contribution is a taglib. In Grails 3.1.11 it worked ok. I also have a simple Grails app just for testing the plugin. Enter Grails 3.2.2.
After migrating plugin and app to 3.2.2 the plugin shows no signs of life. The plugin doWithApplicationContext closure is no longer executed at app startup. The taglib is not found by gsp:s. I did the migration by creating a new plugin and app with Grails 3.2.2 and then fill in the sources.
Sorry for this vague question, but what strings should I pull to find out what's wrong?
Edit 1: Yes, I did the sanity check to have the app depend on a non-existing version of the plugin and got the expected conflict. So it's not that the plugin is totally decoupled from the app.
Edit 2: After setting DEBUG logging on packages grails.plugins and org.grails.plugins a warning message appeared. It came from org.grails.plugins.CorePluginFinder. It couldn't find the plugin descriptor (...Plugin.groovy). I examined the plugin jar, found the plugin descriptor class in a file hierarchy rooted in BOOT-INF. Clearly the plugin loader didn't look into that hierarchy. I thought I was seeing a Grails bug because I didn't know about Boot repackaging. I added a post here to that effect, but after getting Graeme's answer I deleted the post because it detracted attention.
What you are seeing is that if you run gradle assemble on a plugin then the bootRepackage task is run which re-packages the plugin JAR as a runnable JAR which is not what you want when you plan to use the plugin from an application.
If you simply run gradle publish or gradle publishToMavenLocal or gradle jar then you get the JAR file that has not been re-packaged by Boot. As far as I am aware this is not a change from Grails 3.1.
You can also disable Boot repackaging all together in the plugin build.gradle if you never plan to use the plugin as an actual application or runnable JAR file:
bootRepackage.enabled = false

How do I configure installation of plugins in Grails 3.0.4?

I'm porting an application from Grails 2.4.2 to Grails 3.0.4, and I'm having problems with some plugins that were installed previously. Specifically one that is referenced in a GSP page. The particular plugin is called google-visualizer, and I've found some info here:
https://github.com/bmuschko/grails-google-visualization/blob/master/grails-app/views/formatter/index.gsp
However, I am clueless as to how to install this. I have not found the particular jar file in any maven repo, so I can't add it as a Gradle dependency. In general, where is it documented how to install existing plugins in Grails 3.X? I've read the documentation on how to port existing plugins, but that's not what I'm trying to do. I simply want to tell Grails/Gradle that I'd like to use this particular plugin and have it resolve the dependencies for me. I've tried this syntax as shown here:
https://grails.org/plugins/tag/grails3
Example:
compile ":quartz:1.0.2"
I've put that line in the dependencies block in my build.gradle file, but it doesn't work. I get errors from Gradle. Is there a particular Maven repo that has to be added for plugins? Any help with this is appreciated. Thanks.
Grails 1.x and 2.x plugins are sadly not compatible with Grails 3.x.
You can find the plugins that already have been ported to Grails 3 at: https://bintray.com/grails/plugins/
The grails-google-visualization plugin is not released in a Grails 3 version, but from the repo, it appears that work has started on upgrading.
You can see the progress on a Grails 3 version in this issue: https://github.com/bmuschko/grails-google-visualization/issues/49
Benjamin searched for a new maintainer back some time ago, and found a volunteer - see this tread for details: https://twitter.com/bmuschko/status/498610606896066560
For those plugins that are most important, the Grails Core team maintains a list here: https://github.com/grails/grails-core/wiki/Grails-3-Priority-Upgrade-Plugins
Some of the old plugins will be replaced by their Gradle counterpart, fx. the codenarc plugin, that exist in a Gradle version already.
A simple way is to find out the JAR file for the plugin and then use them in Grails 3.0.4. In this way there is no need to change the source code of the plugin

slf4j version mismatch when using grails 1.3.7 with quartz scheduler 1.0-RC1

My application uses grails 1.3.7 with quartz scheduler 1.0-RC1 plugin. It runs fine locally on tomcat when I run it using grails run-app. However, when I create a war file using grails prod war and deploy it in WebLogic, I'm getting the below error:
SLF4J: The requested version 1.5.8 by your slf4j binding is not compatible with [1.6]
SLF4J: See http://www.slf4j.org/codes.html#version_mismatch for further details.
log4j:ERROR Error initializing log4j: org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;Ljava/lang/Throwable;)V
java.lang.NoSuchMethodError: org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;Ljava/lang/Throwable;)V
at org.apache.commons.logging.impl.SLF4JLocationAwareLog.trace(SLF4JLocationAwareLog.java:107)
at org.apache.commons.beanutils.BeanUtilsBean.convert(BeanUtilsBean.java:1073)
I figured this is because grails 1.3.7 uses slf4j 1.5.8, but the quartz plugin uses 1.6.0 and hence there's a conflict. I tried to address it by excluding the slf4j-api jar in BuildConfig.groovy like:
plugins {
compile(":quartz:1.0-RC1") { excludes "slf4j-api" }
}
I was hoping the above config entry would prevent slf4j 1.6.0 from being downloaded and resolve the conflict. But it isn't. When I run grails dependency-report, I still see the conflict and I'm unable to deploy the application in WebLogic.
EDIT: Screenshot of the conflict from grails dependency-report:
Any pointers to resolve this?
You have conflict of jar file. Weblogic comes with sl4j by default and your war file should also contain sl4j jar file inside WEB-INF\lib folder. You can try changing class loading to parent last from admin console.
I resolved this issue by using the code below in BuildConfig.groovy to exclude slf4j-api-1.6.0.jar from the packaged war. The suggestion was posted here
grails.war.resources = { stagingDir ->
delete(file:"${stagingDir}/WEB-INF/lib/slf4j-api-1.6.0.jar")
}
I also had to add slf4j-api-1.5.8.jar to the project's lib folder.

exclude transitive plugin dependencies

I've installed the asynchronous mail plugin into a Grails 2.1.4 application. This plugin has a dependency on version 2.1.1 of the Hibernate plugin, whereas my app depends on version 2.1.4 of the Hibernate plugin.
Every time I execute a Grails command like run-app, I am asked the following question:
You currently already have a version of the plugin installed [hibernate-2.1.4]. Do you want to update to [hibernate-2.1.1]? [y,n] n
I know that run-app has an --non-interactive argument, but AFAIK this will automatically answer y to this question. Ideally, I would like to solve this problem by excluding the transitive Hibernate plugin dependency from the asynchronous mail plugin, but transitive dependency exclusion only seems to be possible for JAR dependencies.
The docs in the plugin page are wrong - you need this for any Grails app not using version 2.1.1, not just older apps:
compile(":asynchronous-mail:1.0-RC3") {
excludes 'hibernate'
}

Grails ant tasks don't work - Unable to start Grails: java.lang.reflect.InvocationTargetException

I'm having issues getting something which seems very basic running with Grails. I want to call grails commands from an Ant script - Grails provides a Grails task to achieve this. I have defined the Grails taskdef and classpaths as per the docs however, no matter what command I call I get the same error...
grails-compile:
[grails] Resolving dependencies...
[grails] Dependencies resolved in 1192ms.
BUILD FAILED
/java/grailstest/build.xml:22: Unable to start Grails: java.lang.reflect.InvocationTargetException
Even when I create a new Grails app using 'grails create-app' and then run the integrate ant command 'grails integrate-with --ant' to generate a default build.xml, I get the same error when running any of the tasks in the generated build.xml.
I've tested this with Grails 1.3.1, 1.3.4 and 1.3.5 and am getting the same error.
Has anyone else encountered this problem? There must be something stupid I'm doing wrong or this would never have made it out the door of the Grails factory... ;)
I forgot to mention that I am using Ant version 1.8.1. I have just discovered that switching back to Ant 1.7.1 'solves' this problem but this is not really ideal as I need 1.8.1 for other build tasks. I'll submit a bug on the Grails issue tracker as it seems a lot of people are having the same problem.
I've just found the same issue. It seems that Ant 1.8 is not supported yet (but Ant 1.7 is), see GRAILS-6897. Some users have complained that the documentation does not state it strictly.

Resources