部署到JBoss 7时,Quartz-Job in grails不起作用

时间:2013-09-09 09:47:36

标签: grails jboss jboss7.x

我正在尝试将grails-app(2.2.4)部署到JBoss AS 7.1.1。

我通过grails war构建了war文件,将其复制到独立/部署目录并使用bin / standalone.bat启动了JBoss。

这一切都运行正常,可以通过浏览器访问该网站。但应用程序的一部分是一个quartz-job,它应该从FTP服务器加载文件。

它会按预期定期启动,但由于以下错误而失败:

ERROR [grails.plugins.quartz.listeners.ExceptionPrinterJobListener] (quartzScheduler_Worker-6) Exception occurred in job: null: org.quartz.JobExecutionException: java.lang.NoClassDefFoundError: org/apache/tools/ant/BuildLogger [See nested exception: java.lang.NoClassDefFoundError: org/apache/tools/ant/BuildLogger]
    at grails.plugins.quartz.GrailsJobFactory$GrailsJob.execute(GrailsJobFactory.java:96) [classes:]
    at org.quartz.core.JobRunShell.run(JobRunShell.java:213) [quartz-2.1.5.jar:]
    at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:557) [quartz-2.1.5.jar:]
Caused by: java.lang.NoClassDefFoundError: org/apache/tools/ant/BuildLogger
    at java.lang.Class.getDeclaredConstructors0(Native Method) [rt.jar:1.7.0_03]
    at java.lang.Class.privateGetDeclaredConstructors(Class.java:2404) [rt.jar:1.7.0_03]
    at java.lang.Class.getDeclaredConstructors(Class.java:1853) [rt.jar:1.7.0_03]
    at org.codehaus.groovy.reflection.CachedClass$2$1.run(CachedClass.java:69) [groovy-all-2.0.8.jar:2.0.8]
    at java.security.AccessController.doPrivileged(Native Method) [rt.jar:1.7.0_03]
    at org.codehaus.groovy.reflection.CachedClass$2.initValue(CachedClass.java:66) [groovy-all-2.0.8.jar:2.0.8]
    at org.codehaus.groovy.reflection.CachedClass$2.initValue(CachedClass.java:64) [groovy-all-2.0.8.jar:2.0.8]
    at org.codehaus.groovy.util.LazyReference.getLocked(LazyReference.java:46) [groovy-all-2.0.8.jar:2.0.8]
    at org.codehaus.groovy.util.LazyReference.get(LazyReference.java:33) [groovy-all-2.0.8.jar:2.0.8]
    at org.codehaus.groovy.reflection.CachedClass.getConstructors(CachedClass.java:258) [groovy-all-2.0.8.jar:2.0.8]
    at groovy.lang.MetaClassImpl.<init>(MetaClassImpl.java:187) [groovy-all-2.0.8.jar:2.0.8]
    at groovy.lang.ExpandoMetaClass.<init>(ExpandoMetaClass.java:297) [groovy-all-2.0.8.jar:2.0.8]
    at groovy.lang.ExpandoMetaClass.<init>(ExpandoMetaClass.java:340) [groovy-all-2.0.8.jar:2.0.8]
    at groovy.lang.ExpandoMetaClassCreationHandle.createNormalMetaClass(ExpandoMetaClassCreationHandle.java:46) [groovy-all-2.0.8.jar:2.0.8]
    at groovy.lang.MetaClassRegistry$MetaClassCreationHandle.createWithCustomLookup(MetaClassRegistry.java:147) [groovy-all-2.0.8.jar:2.0.8]
    at groovy.lang.MetaClassRegistry$MetaClassCreationHandle.create(MetaClassRegistry.java:130) [groovy-all-2.0.8.jar:2.0.8]
    at org.codehaus.groovy.reflection.ClassInfo.getMetaClassUnderLock(ClassInfo.java:175) [groovy-all-2.0.8.jar:2.0.8]
    at org.codehaus.groovy.reflection.ClassInfo.getMetaClass(ClassInfo.java:192) [groovy-all-2.0.8.jar:2.0.8]
    at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.getMetaClass(MetaClassRegistryImpl.java:309) [groovy-all-2.0.8.jar:2.0.8]
    at org.codehaus.groovy.runtime.InvokerHelper.getMetaClass(InvokerHelper.java:806) [groovy-all-2.0.8.jar:2.0.8]
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.createCallConstructorSite(CallSiteArray.java:84) [groovy-all-2.0.8.jar:2.0.8]
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:57) [groovy-all-2.0.8.jar:2.0.8]
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:182) [groovy-all-2.0.8.jar:2.0.8]
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:186) [groovy-all-2.0.8.jar:2.0.8]
    at projectname.MessungImportJob$_ftpFileRetrieval_closure1.doCall(MessungImportJob.groovy:183) [classes:]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_03]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [rt.jar:1.7.0_03]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.7.0_03]
    at java.lang.reflect.Method.invoke(Method.java:601) [rt.jar:1.7.0_03]
    at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90) [groovy-all-2.0.8.jar:2.0.8]
    at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233) [groovy-all-2.0.8.jar:2.0.8]
    at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1082) [groovy-all-2.0.8.jar:2.0.8]
    at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:1106) [groovy-all-2.0.8.jar:2.0.8]
    at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:906) [groovy-all-2.0.8.jar:2.0.8]
    at groovy.lang.Closure.call(Closure.java:412) [groovy-all-2.0.8.jar:2.0.8]
    at groovy.lang.Closure.call(Closure.java:425) [groovy-all-2.0.8.jar:2.0.8]
    at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:1326) [groovy-all-2.0.8.jar:2.0.8]
    at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:1298) [groovy-all-2.0.8.jar:2.0.8]
    at org.codehaus.groovy.runtime.dgm$148.invoke(Unknown Source) [groovy-all-2.0.8.jar:2.0.8]
    at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoMetaMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:271) [groovy-all-2.0.8.jar:2.0.8]
    at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:53) [groovy-all-2.0.8.jar:2.0.8]
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45) [groovy-all-2.0.8.jar:2.0.8]
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108) [groovy-all-2.0.8.jar:2.0.8]
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116) [groovy-all-2.0.8.jar:2.0.8]
    at projectname.MessungImportJob.ftpFileRetrieval(MessungImportJob.groovy:115) [classes:]
    at projectname.MessungImportJob$ftpFileRetrieval.callCurrent(Unknown Source)
    at projectname.MessungImportJob.execute(MessungImportJob.groovy:77) [classes:]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_03]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [rt.jar:1.7.0_03]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.7.0_03]
    at java.lang.reflect.Method.invoke(Method.java:601) [rt.jar:1.7.0_03]
    at grails.plugins.quartz.GrailsJobFactory$GrailsJob.execute(GrailsJobFactory.java:89) [classes:]
    ... 2 more
Caused by: java.lang.ClassNotFoundException: org.apache.tools.ant.BuildLogger from [Module "deployment.projectname-0.1.war:main" from Service Module Loader]
    at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)
    at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468)
    at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456)
    at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)
    at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120)
    ... 54 more

我认为这是一个相当基本的Java问题,但是:我是否必须在某个地方包含这个org.apache.tools.ant-library?我是否必须在grails-configs中的某个地方“列出”它?或者我完全错过了什么?

在开发者模式(grails run-app)中启动它可以正常工作。

感谢您的提议, 的Marius

1 个答案:

答案 0 :(得分:2)

我在此网站上找到了原因和解决方案:http://grails.org/plugin/grails-ant

尽管ant是Grails核心的一部分,因为它主要是一个构建工具,它不包含在Grails war文件中(1)。您可以在自己的应用程序中执行此操作,无需此插件,只需在build.config中添加ant。

dependencies {
    // Workarounds for Grails not shipping ant in WAR
    compile 'org.apache.ant:ant:1.7.1'    //you can also use runtime
    compile 'org.apache.ant:ant-launcher:1.7.1' 
}

我将版本更改为here中的最新版本,JBoss启动它。

感谢第一个提示的tim_yates。