Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Grails quartz plugin is not working when deployed in Tomcat

I have a web application that was developed using Grails. I'm trying to implement a background process that scans a table in DB for every 5 mins using quartz1.0-RC9 plugin for Grails.

Before trying to code the actual logic I'm learning how to use the plugin as I'm new to quartz. So I created a job that prints the message "hai" with the current timestamp for every 5 seconds.

class checkJob {
    static triggers = {
      simple name:'sampleQuartz', startDelay:10000, repeatInterval: 5000l, repeatCount: -1 // execute job once in 5 seconds
    }

    def execute() {
        println "hai!!!"+new Date()// execute job
    }
}

And my QuartzConfig.groovy is

quartz {
    autoStartup = true
    jdbcStore = false
    waitForJobsToCompleteOnShutdown = true
    exposeSchedulerInRepository = false

    props {
        scheduler.skipUpdateCheck = true
    }
}

environments {
    test {
        quartz {
            autoStartup = true
        }
    }
    production {
        quartz {
            autoStartup = true
        }
    }
}

This works fine when run using the command grails run-app. But when a war is created using the command grails prod war and when deployed in Tomcat nothing works. Even the index.html page is not loading instead it gives Http-404 error.

I have referenced this plugin in BuilConfig.groovy as mentioned in the documentation under plugin category.

compile ":quartz:1.0-RC9"

But yet nothing works.

Then I created a new Grails project that has nothing but only the quartz code mentioned above and created a war using grails prod war. This works fine with Tomcat.

I'm using

Tomcat 6
Grails 2.0.1
quartz 1.0-RC9

What I'm missing while creating a job in already existing grails application?

Please somebody help me.

I did some groundwork on this issue. On creating war of my grails application "Timeprocess" by grails dev-war and deploying under Tomcat6, I am getting the following in localhost.txt file

Jul 29, 2013 3:35:27 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring root WebApplicationContext
Jul 29, 2013 3:35:32 PM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class org.codehaus.groovy.grails.web.context.GrailsContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'pluginManager' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.RuntimeException: Unable to locate constructor with Class parameter for class grails.plugins.quartz.DefaultGrailsJobClass
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1455)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:567)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:384)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:283)
    at org.codehaus.groovy.grails.web.context.GrailsContextLoader.initWebApplicationContext(GrailsContextLoader.java:66)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4135)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4630)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:546)
    at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:905)
    at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:740)
    at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:500)
    at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1277)
    at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:321)
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
    at org.apache.catalina.core.StandardHost.start(StandardHost.java:785)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
    at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:445)
    at org.apache.catalina.core.StandardService.start(StandardService.java:519)
    at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:581)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: java.lang.RuntimeException: Unable to locate constructor with Class parameter for class grails.plugins.quartz.DefaultGrailsJobClass
    at org.codehaus.groovy.grails.commons.ArtefactHandlerAdapter.newArtefactClass(ArtefactHandlerAdapter.java:113)
    at org.codehaus.groovy.grails.commons.DefaultGrailsApplication.addArtefact(DefaultGrailsApplication.java:894)
    at org.codehaus.groovy.grails.commons.DefaultGrailsApplication.addArtefact(DefaultGrailsApplication.java:615)
    at org.codehaus.groovy.grails.commons.DefaultGrailsApplication.configureLoadedClasses(DefaultGrailsApplication.java:326)
    at org.codehaus.groovy.grails.commons.DefaultGrailsApplication.initialise(DefaultGrailsApplication.java:825)
    at org.codehaus.groovy.grails.plugins.GrailsPluginManagerFactoryBean.afterPropertiesSet(GrailsPluginManagerFactoryBean.java:110)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1514)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1452)
    ... 37 more
Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at org.codehaus.groovy.grails.commons.ArtefactHandlerAdapter.newArtefactClass(ArtefactHandlerAdapter.java:104)
    ... 44 more
Caused by: java.lang.IncompatibleClassChangeError: Implementing class
    at grails.plugins.quartz.config.TriggersConfigBuilder.createTrigger(TriggersConfigBuilder.groovy:74)
    at grails.plugins.quartz.config.TriggersConfigBuilder.createNode(TriggersConfigBuilder.groovy:215)
    at grails.plugins.quartz.config.TriggersConfigBuilder.createNode(TriggersConfigBuilder.groovy:208)
    at Timeprocess.ScheduleScanJob$__clinit__closure1.doCall(ScheduleScanJob.groovy:7)
    at grails.plugins.quartz.config.TriggersConfigBuilder.build(TriggersConfigBuilder.groovy:52)
    at grails.plugins.quartz.DefaultGrailsJobClass.evaluateTriggers(DefaultGrailsJobClass.java:58)
    at grails.plugins.quartz.DefaultGrailsJobClass.<init>(DefaultGrailsJobClass.java:48)
Jul 29, 2013 3:35:34 PM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextInitialized()
Jul 29, 2013 3:35:34 PM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextInitialized()
Jul 29, 2013 3:36:31 PM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextDestroyed()
Jul 29, 2013 3:36:31 PM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextDestroyed()

Can anyone please help me to point-out what's is wrong in here?

like image 668
Vasanth Rajasekaran Avatar asked Jul 24 '13 11:07

Vasanth Rajasekaran


1 Answers

I would suggest doing a:

grails clean

and also deleting the .slcache folder, that you can find under

~/.grails/.slcache

regards

like image 165
Juan Garcia Avatar answered Oct 15 '22 17:10

Juan Garcia