java.lang.NoSuchMethodError 在调用在 jboss mbean 中声明的石英作业期间
Posted
技术标签:
【中文标题】java.lang.NoSuchMethodError 在调用在 jboss mbean 中声明的石英作业期间【英文标题】:java.lang.NoSuchMethodError during invoking quartz job declared inside jboss mbean 【发布时间】:2015-04-15 15:47:17 【问题描述】:我在一个 jboss 实例上部署了两只耳朵。我正在使用在 mbean 中配置的石英。两只耳朵都在使用 StatefulJobs。不幸的是,一个使用库 antlr-runtime-3.0,但第二个使用的是 antlr-runtime-3.2。当 JBoss 调用该作业时,它使用了错误的库。我不知道如何强迫他从耳朵里使用图书馆。我的石英版本升级到1.8.6。 JBoss 是 4.2.2 GA
我的第一个耳朵结构:
元信息
antlr-runtime-3.0.jar
ejb.jar app.war我的第二耳结构:
元信息 application.xml jboss-app.xml antlr-runtime-3.2.jar ejb2.jar app2.war应用程序.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE application PUBLIC
"-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN"
"http://java.sun.com/dtd/application_1_3.dtd">
<application>
<display-name>ear</display-name>
<module>
<web>
<web-uri>app.war</web-uri>
<context-root>/</context-root>
</web>
</module>
<module>
<ejb>app.jar</ejb>
</module>
</application>
jboss-app.xml
<?xml version='1.0' encoding='UTF-8' ?>
<jboss-app>
<loader-repository>
pck.class:app.war=unique-app.war
<loader-repository-config>java2ParentDelegation=false</loader-repository-config>
</loader-repository>
</jboss-app>
堆栈:
org.quartz.SchedulerException: Problem instantiating class 'package.quartz.WsclFailureJob' - [See nested exception: java.lang.NoSuchMethodError: org.antlr.runtime.Lexer.<init>(Lorg/antlr/runtime/CharStream;Lorg/antlr/runtime/RecognizerSha
redState;)V]
at org.quartz.core.JobRunShell.initialize(JobRunShell.java:147)
at org.quartz.core.QuartzSchedulerThread.run(QuartzSchedulerThread.java:364)
Caused by: java.lang.NoSuchMethodError: org.antlr.runtime.Lexer.<init>(Lorg/antlr/runtime/CharStream;Lorg/antlr/runtime/RecognizerSharedState;)V
at package.cond.antlr.CondLexer.<init>(CondLexer.java:55)
at package.cond.antlr.CondLexer.<init>(CondLexer.java:52)
at package.cond.ExpressionFactory.getValue(ExpressionFactory.java:58)
at packagee.Configuration$ConfigInternal.loadParsableParams(Configuration.java:204)
at packagee.Configuration$ConfigInternal.reload(Configuration.java:172)
at packagee.Configuration$ConfigInternal.<init>(Configuration.java:161)
at packagee.Configuration.reload(Configuration.java:56)
at packagee.Configuration.<init>(Configuration.java:47)
at packagee.Configuration.<clinit>(Configuration.java:38)
at packagee.ScenarioProcessor.<init>(ScenarioProcessor.java:71)
at packagee.ScenarioProcessor.<clinit>(ScenarioProcessor.java:58)
at package.quartz.WsclFailureJob.<init>(WsclFailureJob.java:22)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
at java.lang.Class.newInstance0(Class.java:350)
at java.lang.Class.newInstance(Class.java:303)
at org.quartz.simpl.SimpleJobFactory.newJob(SimpleJobFactory.java:55)
at org.quartz.core.JobRunShell.initialize(JobRunShell.java:140)
... 1 more
我也在尝试将 java2ParentDelegation 设置为 true,但它不起作用。当我将此文件添加到项目中时,jboss 调用我的石英在从石英表检索作业期间给出 mi ClassNotFoundError。如果没有这个文件,一切都很好,但是当 jboss 上只部署了一个应用程序时。
与 jboss-app.xml 堆栈:
15-04-15 17:49:00,010 TRACE [RepositoryClassLoader] attempt(1) was: true for :org.jboss.mx.loading.UnifiedClassLoader3@13b310f2 url=null ,addedOrder=25
2015-04-15 17:49:00,010 TRACE [LoadMgr3] registerLoaderThread, ucl=org.jboss.mx.loading.UnifiedClassLoader3@13b310f2 url=null ,addedOrder=25, t=Thread[MySystemClusteredScheduler_QuartzSchedulerThread,5,QuartzScheduler:MySystemClusteredScheduler], prevT=null
2015-04-15 17:49:00,010 TRACE [LoadMgr3] Begin beginLoadTask, task=org.jboss.mx.loading.ClassLoadingTask@f31cdbclassname: package.quartz.WsclFailureJob, requestingThread: Thread[MySystemClusteredScheduler_QuartzSchedulerThread,5,QuartzScheduler:MySystemClusteredScheduler], requestingClassLoader: org.jboss.mx.loading.UnifiedClassLoader3@13b310f2 url=null ,addedOrder=25, loadedClass: nullnull, loadOrder: 2147483647, loadException: null, threadTaskCount: 0, state: 0, #CCE: 0
2015-04-15 17:49:00,010 TRACE [RepositoryClassLoader] loadClassLocally, org.jboss.mx.loading.UnifiedClassLoader3@13b310f2 url=null ,addedOrder=25 name=package.quartz.WsclFailureJob
2015-04-15 17:49:00,010 TRACE [RepositoryClassLoader] Class in blacklist, name=package.quartz.WsclFailureJob
2015-04-15 17:49:00,010 TRACE [RepositoryClassLoader] loadClassLocally, org.jboss.mx.loading.UnifiedClassLoader3@13b310f2 url=null ,addedOrder=25 name=package.quartz.WsclFailureJob not found
2015-04-15 17:49:00,010 TRACE [LoadMgr3] End beginLoadTask, ClassNotFoundException
2015-04-15 17:49:00,010 TRACE [LoadMgr3] Begin endLoadTask, task=org.jboss.mx.loading.ClassLoadingTask@f31cdbclassname: package.quartz.WsclFailureJob, requestingThread: Thread[MySystemClusteredScheduler_QuartzSchedulerThread,5,QuartzScheduler:MySystemClusteredScheduler], requestingClassLoader: org.jboss.mx.loading.UnifiedClassLoader3@13b310f2 url=null ,addedOrder=25, loadedClass: nullnull, loadOrder: 2147483647, loadException: null, threadTaskCount: 0, state: 0, #CCE: 0
2015-04-15 17:49:00,010 TRACE [RepositoryClassLoader] release(1) for :org.jboss.mx.loading.UnifiedClassLoader3@13b310f2 url=null ,addedOrder=25
2015-04-15 17:49:00,010 TRACE [RepositoryClassLoader] released, holds: 0
2015-04-15 17:49:00,010 TRACE [RepositoryClassLoader] loadClass org.jboss.mx.loading.UnifiedClassLoader3@13b310f2 url=null ,addedOrder=25 name=package.quartz.WsclFailureJob not found
2015-04-15 17:49:00,011 ERROR [JobStoreTX] Error retrieving job, setting trigger state to ERROR.
org.quartz.JobPersistenceException: Couldn't retrieve job because a required class was not found: No ClassLoaders found for: package.quartz.WsclFailureJob [See nested exception: java.lang.ClassNotFoundException: No ClassLoaders found for: package.quartz.WsclFailureJob]
at org.quartz.impl.jdbcjobstore.JobStoreSupport.retrieveJob(JobStoreSupport.java:1416)
at org.quartz.impl.jdbcjobstore.JobStoreSupport.triggerFired(JobStoreSupport.java:2903)
at org.quartz.impl.jdbcjobstore.JobStoreSupport$38.execute(JobStoreSupport.java:2871)
at org.quartz.impl.jdbcjobstore.JobStoreSupport.executeInNonManagedTXLock(JobStoreSupport.java:3788)
at org.quartz.impl.jdbcjobstore.JobStoreSupport.triggerFired(JobStoreSupport.java:2
865)
at org.quartz.core.QuartzSchedulerThread.run(QuartzSchedulerThread.java:319)
Caused by: java.lang.ClassNotFoundException: No ClassLoaders found for: package.quartz.WsclFailureJob
at org.jboss.mx.loading.LoadMgr3.beginLoadTask(LoadMgr3.java:306)
at org.jboss.mx.loading.RepositoryClassLoader.loadClassImpl(RepositoryClassLoader.java:521)
at org.jboss.mx.loading.RepositoryClassLoader.loadClass(RepositoryClassLoader.java:415)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at org.quartz.simpl.InitThreadContextClassLoadHelper.loadClass(InitThreadContextClassLoadHelper.java:72)
at org.quartz.simpl.CascadingClassLoadHelper.loadClass(CascadingClassLoadHelper.java:116)
at org.quartz.impl.jdbcjobstore.StdJDBCDelegate.selectJobDetail(StdJDBCDelegate.java:894)
at org.quartz.impl.jdbcjobstore.JobStoreSupport.retrieveJob(JobStoreSupport.java:1404)
没有 jboss-app.xml 的日志。当 jboss 上只有一个部署时,应用程序运行良好:
2015-04-15 17:53:40,370 TRACE [org.jboss.mx.loading.RepositoryClassLoader] loadClassLocally, org.jboss.mx.loading.UnifiedClassLoader3@7c067f03 url=file:/jboss/server/default/tmp/deploy/tmp34768system.ear ,addedOrder=44 name=package.quartz.WsclFailureJob class=class package.quartz.WsclFailureJob cl=org.jboss.mx.loading.UnifiedClassLoader3@7c067f03 url=file:/jboss/server/default/tmp/deploy/tmp34768system.ear ,addedOrder=44
2015-04-15 17:53:40,370 TRACE [org.jboss.mx.loading.ClassLoadingTask] setLoadedClass, theClass=class package.quartz.WsclFailureJob, order=44
2015-04-15 17:53:40,370 TRACE [org.jboss.mx.loading.UnifiedLoaderRepository3] cacheLoadedClass, classname: package.quartz.WsclFailureJob, class: class package.quartz.WsclFailureJob, ucl: org.jboss.mx.loading.UnifiedClassLoader3@7c067f03 url=file:/jboss/server/default/tmp/deploy/tmp34768system.ear ,addedOrder=44, prevClass: null
2015-04-15 17:53:40,370 TRACE [org.jboss.mx.loading.LoadMgr3] Notifying task of thread completion, loadTask:org.jboss.mx.loading.ClassLoadingTask@136e2ea3classname: package.quartz.WsclFailureJob, requestingThread: Thread[main,5,jboss], requestingClassLoader: org.jboss.mx.loading.UnifiedClassLoader3@7c067f03 url=file:/jboss/server/default/tmp/deploy/tmp34768system.ear ,addedOrder=44, loadedClass: class package.quartz.WsclFailureJobpackage.quartz.WsclFailureJob@3eeec5b4<CodeSource: (file:/jboss/server/default/tmp/deploy/tmp34768system.ear-contents/system.jar <no signer certificates>)>, loadOrder: 44, loadException: null, threadTaskCount: 0, state: 1, #CCE: 0
2015-04-15 17:53:40,370 TRACE [org.jboss.mx.loading.LoadMgr3] End nextTask(0), loadTask=org.jboss.mx.loading.ClassLoadingTask@136e2ea3classname: package.quartz.WsclFailureJob, requestingThread: Thread[main,5,jboss], requestingClassLoader: org.jboss.mx.loading.UnifiedClassLoader3@7c067f03 url=file:/jboss/server/default/tmp/deploy/tmp34768system.ear ,addedOrder=44, loadedClass: class package.quartz.WsclFailureJobpackage.quartz.WsclFailureJob@3eeec5b4<CodeSource: (file:/jboss/server/default/tmp/deploy/tmp34768system.ear-contents/system.jar <no signer certificates>)>, loadOrder: 44, loadException: null, threadTaskCount: 0, state: 4, #CCE: 0
2015-04-15 17:53:40,370 TRACE [org.jboss.mx.loading.LoadMgr3] Begin endLoadTask, task=org.jboss.mx.loading.ClassLoadingTask@136e2ea3classname: package.quartz.WsclFailureJob, requestingThread: Thread[main,5,jboss], requestingClassLoader: org.jboss.mx.loading.UnifiedClassLoader3@7c067f03 url=file:/jboss/server/default/tmp/deploy/tmp34768system.ear ,addedOrder=44, loadedClass: class package.quartz.WsclFailureJobpackage.quartz.WsclFailureJob@3eeec5b4<CodeSource: (file:/jboss/server/default/tmp/deploy/tmp34768system.ear-contents/system.jar <no signer certificates>)>, loadOrder: 44, loadException: null, threadTaskCount: 0, state: 4, #CCE: 0
2015-04-15 17:53:40,370 TRACE [org.jboss.mx.loading.RepositoryClassLoader] release(1) for :org.jboss.mx.loading.UnifiedClassLoader3@7c067f03 url=file:/jboss/server/default/tmp/deploy/tmp34768system.ear ,addedOrder=44
2015-04-15 17:53:40,370 TRACE [org.jboss.mx.loading.RepositoryClassLoader] released, holds: 0
2015-04-15 17:53:40,371 TRACE [org.jboss.mx.loading.RepositoryClassLoader] loadClass org.jboss.mx.loading.UnifiedClassLoader3@7c067f03 url=file:/jboss/server/default/tmp/deploy/tmp34768system.ear ,addedOrder=44 name=package.quartz.WsclFailureJob class=class package.quartz.WsclFailureJob cl=org.jboss.mx.loading.UnifiedClassLoader3@7c067f03 url=file:/jboss/server/default/tmp/deploy/tmp34768system.ear ,addedOrder=44
2015-04-15 17:53:40,371 TRACE [org.jboss.mx.loading.RepositoryClassLoader] loadClass org.jboss.mx.loading.UnifiedClassLoader3@7c067f03 url=file:/jboss/server/default/tmp/deploy/tmp34768system.ear ,addedOrder=44 name=package.quartz.VerifyTimeoutJob, loadClassDepth=0
没有 jboss-app.xml 的堆栈,但如果 2 个部署的应用程序具有不同版本的库 antlr-runtime:
2015-04-15 19:01:11,307 TRACE [RepositoryClassLoader] loadClassLocally, org.jboss.mx.loading.UnifiedClassLoader3@1ab0a47 url=file:/home/name/jboss/server/default/tmp/deploy/tmp34140system.ear ,addedOrder=48 name=org.antlr.runtime.Recognize
rSharedState class=class org.antlr.runtime.RecognizerSharedState cl=org.jboss.mx.loading.UnifiedClassLoader3@1ab0a47 url=file:/home/name/jboss/server/default/tmp/deploy/tmp34140system.ear ,addedOrder=48
2015-04-15 19:01:11,307 TRACE [ClassLoadingTask] setLoadedClass, theClass=class org.antlr.runtime.RecognizerSharedState, order=48
2015-04-15 19:01:11,307 TRACE [UnifiedLoaderRepository3] cacheLoadedClass, classname: org.antlr.runtime.RecognizerSharedState, class: class org.antlr.runtime.RecognizerSharedState, ucl: org.jboss.mx.loading.UnifiedClassLoader3@1ab0a47 ur
l=file:/home/name/jboss/server/default/tmp/deploy/tmp34140system.ear ,addedOrder=48, prevClass: null
2015-04-15 19:01:11,307 TRACE [LoadMgr3] Notifying task of thread completion, loadTask:org.jboss.mx.loading.ClassLoadingTask@61b7dcclassname: org.antlr.runtime.RecognizerSharedState, requestingThread: Thread[MySystemClusteredScheduler_QuartzS
chedulerThread,5,QuartzScheduler:MySystemClusteredScheduler], requestingClassLoader: org.jboss.mx.loading.UnifiedClassLoader3@1ab0a47 url=file:/home/name/jboss/server/default/tmp/deploy/tmp34140system.ear ,addedOrder=48, loadedClass: class org.a
ntlr.runtime.RecognizerSharedStateorg.antlr.runtime.RecognizerSharedState@196b1a5<CodeSource: (file:/home/name/jboss/server/default/tmp/deploy/tmp34140system.ear-contents/antlr-runtime-3.2.jar <no signer certificates>)>, loadOrder: 48, loadEx
ception: null, threadTaskCount: 0, state: 1, #CCE: 0
2015-04-15 19:01:11,307 TRACE [LoadMgr3] End nextTask(0), loadTask=org.jboss.mx.loading.ClassLoadingTask@61b7dcclassname: org.antlr.runtime.RecognizerSharedState, requestingThread: Thread[MySystemClusteredScheduler_QuartzSchedulerThread,5,Qua
rtzScheduler:MySystemClusteredScheduler], requestingClassLoader: org.jboss.mx.loading.UnifiedClassLoader3@1ab0a47 url=file:/home/name/jboss/server/default/tmp/deploy/tmp34140system.ear ,addedOrder=48, loadedClass: class org.antlr.runtime.Recogni
zerSharedStateorg.antlr.runtime.RecognizerSharedState@196b1a5<CodeSource: (file:/home/name/jboss/server/default/tmp/deploy/tmp34140system.ear-contents/antlr-runtime-3.2.jar <no signer certificates>)>, loadOrder: 48, loadException: null, threa
dTaskCount: 0, state: 4, #CCE: 0
2015-04-15 19:01:11,307 TRACE [LoadMgr3] Begin endLoadTask, task=org.jboss.mx.loading.ClassLoadingTask@61b7dcclassname: org.antlr.runtime.RecognizerSharedState, requestingThread: Thread[MySystemClusteredScheduler_QuartzSchedulerThread,5,Quart
zScheduler:MySystemClusteredScheduler], requestingClassLoader: org.jboss.mx.loading.UnifiedClassLoader3@1ab0a47 url=file:/home/name/jboss/server/default/tmp/deploy/tmp34140system.ear ,addedOrder=48, loadedClass: class org.antlr.runtime.Recognize
rSharedStateorg.antlr.runtime.RecognizerSharedState@196b1a5<CodeSource: (file:/home/name/jboss/server/default/tmp/deploy/tmp34140system.ear-contents/antlr-runtime-3.2.jar <no signer certificates>)>, loadOrder: 48, loadException: null, threadT
askCount: 0, state: 4, #CCE: 0
2015-04-15 19:01:11,307 TRACE [RepositoryClassLoader] release(1) for :org.jboss.mx.loading.UnifiedClassLoader3@1ab0a47 url=file:/home/name/jboss/server/default/tmp/deploy/tmp34140system.ear ,addedOrder=48
2015-04-15 19:01:11,307 TRACE [RepositoryClassLoader] released, holds: 0
2015-04-15 19:01:11,307 TRACE [RepositoryClassLoader] loadClass org.jboss.mx.loading.UnifiedClassLoader3@1ab0a47 url=file:/home/name/jboss/server/default/tmp/deploy/tmp34140system.ear ,addedOrder=48 name=org.antlr.runtime.RecognizerSharedState class=class org.antlr.runtime.RecognizerSharedState cl=org.jboss.mx.loading.UnifiedClassLoader3@1ab0a47 url=file:/home/name/jboss/server/default/tmp/deploy/tmp34140system.ear ,addedOrder=48
2015-04-15 19:01:11,307 TRACE [RepositoryClassLoader] loadClass org.jboss.mx.loading.UnifiedClassLoader3@1ab0a47 url=file:/home/name/jboss/server/default/tmp/deploy/tmp34140system.ear ,addedOrder=48 name=org.antlr.runtime.BitSet, loadClassDepth=0
2015-04-15 19:01:11,307 TRACE [RepositoryClassLoader] Loaded class from cache, org.antlr.runtime.BitSet@15b3baf<CodeSource: (file:/home/name/jboss/server/default/tmp/deploy/tmp34122OTHER_SYSTEM.ear-contents/antlr-runtime-3.0.jar <no signer certificates>)>
2015-04-15 19:01:11,307 TRACE [RepositoryClassLoader] loadClass org.jboss.mx.loading.UnifiedClassLoader3@1ab0a47 url=file:/home/name/jboss/server/default/tmp/deploy/tmp34140system.ear ,addedOrder=48 name=org.antlr.runtime.BitSet class=class org.antlr.runtime.BitSet cl=org.jboss.mx.loading.UnifiedClassLoader3@45f0ed url=file:/home/name/jboss/server/default/tmp/deploy/tmp34122OTHER_SYSTEM.ear ,addedOrder=45
2015-04-15 19:01:11,309 ERROR [ErrorLogger] An error occured instantiating job to be executed. job= 'DEFAULT.package.quartz.WsclFailureJob'
org.quartz.SchedulerException: Problem instantiating class 'package.quartz.WsclFailureJob' - [See nested exception: java.lang.NoSuchMethodError: org.antlr.runtime.Lexer.<init>(Lorg/antlr/runtime/CharStream;Lorg/antlr/runtime/RecognizerSharedState;)V]
at org.quartz.core.JobRunShell.initialize(JobRunShell.java:147)
at org.quartz.core.QuartzSchedulerThread.run(QuartzSchedulerThread.java:364)
Caused by: java.lang.NoSuchMethodError: org.antlr.runtime.Lexer.<init>(Lorg/antlr/runtime/CharStream;Lorg/antlr/runtime/RecognizerSharedState;)V
at package.cond.antlr.CondLexer.<init>(CondLexer.java:55)
at package.cond.antlr.CondLexer.<init>(CondLexer.java:52)
at package.cond.ExpressionFactory.getValue(ExpressionFactory.java:58)
at package.core.Configuration$ConfigInternal.loadParsableParams(Configuration.java:204)
at package.core.Configuration$ConfigInternal.reload(Configuration.java:172)
at package.core.Configuration$ConfigInternal.<init>(Configuration.java:161)
at package.core.Configuration.reload(Configuration.java:56)
at package.core.Configuration.<init>(Configuration.java:47)
at package.core.Configuration.<clinit>(Configuration.java:38)
at package.core.ScenarioProcessor.<init>(ScenarioProcessor.java:71)
at package.core.ScenarioProcessor.<clinit>(ScenarioProcessor.java:58)
at package.quartz.WsclFailureJob.<init>(WsclFailureJob.java:22)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
at java.lang.Class.newInstance0(Class.java:350)
at java.lang.Class.newInstance(Class.java:303)
at org.quartz.simpl.SimpleJobFactory.newJob(SimpleJobFactory.java:55)
at org.quartz.core.JobRunShell.initialize(JobRunShell.java:140)
我也在尝试石英属性,例如:
org.quartz.scheduler.classLoadHelper.class=org.quartz.simpl.CascadingClassLoadHelper
org.quartz.scheduler.threadsInheritContextClassLoaderOfInitializer=true
org.quartz.threadPool.threadsInheritContextClassLoaderOfInitializingThread = true
【问题讨论】:
你可以想办法在代码中引入你自己的类加载器。根据您的控制程度,您可以创建一个工厂,从所需目录手动加载类 我正在考虑它,但我认为有更好的主意......它看起来像一个解决方法...... 【参考方案1】:当您有两个独立的耳朵具有相互冲突的依赖关系时,根据类加载器将它们隔离可能会有所帮助。 JBoss 4 现在被认为已经很老了,但显然从 3.0.2 开始就可以使用所需的功能:
http://www.mastertheboss.com/jboss-server/jboss-configuration/jboss-classloader-issues
【讨论】:
在同一个 JBoss 上,除了这两个 ear 应用程序之外,我还部署了其他应用程序:war & ear。所以这是4个应用程序。更重要的是,我试图通过 xml 配置来分隔类加载器,但它不起作用。我发布了我的 xml 配置 fo ear 应用程序。我无法为所有应用程序设置隔离耳朵,因为它们使用的是quartz mbeans,之后石英将无法看到作业类(我试图这样做,但出现了 NoClassLoadersFound 异常)。 我认为 Quartz 看不到类实际上可能是隔离工作的副作用。有关于此的文档和讨论(例如 goo.gl/zn8v3U ),人们建议定义 Quartz 配置属性 org.quartz.threadPool.threadsInheritContextClassLoaderOfInitializingThread=true 我更新了关于我的石英配置的问题描述。不幸的是,它对我没有帮助。使用由 JBoss 引导的隔离类加载器,quartz 看不到我的类。您可以从第二个堆栈中读取:“ 2015-04-15 17:49:00,010 TRACE [RepositoryClassLoader] loadClassLocally, org.jboss.mx.loading.UnifiedClassLoader3@13b310f2 url=null , addedOrder=25 name=package.quartz .WsclFailureJob 2015-04-15 17:49:00,010 TRACE [RepositoryClassLoader] 黑名单中的类,name=package.quartz.WsclFailureJob" 恐怕我对 JBoss 4 类加载器的了解还不够深入,抱歉。但我的赌注仍然是强制类加载器的顺序而不是其他路由:必须首先加载两个库,覆盖更高级别的类加载器。这只是我所看到的情况的逻辑。它可能会给 Quartz 带来很大的问题,否则我根本不知道它会如何工作。【参考方案2】:这是因为应用程序中可用的最新编译类和依赖 jar 的版本不同。例如:让 A 类使用依赖 jar X 编译,然后在不同的环境中编译相同的 A 类,依赖 jar X1 其中包含名为 Y 的新方法。 现在该类将被编译,因为新方法 Y 在 jar X1 中可用,当在 jar X 的环境中使用相同的类 A 时,当尝试将类加载到类内存中时,它会导致 NoSuchMethod 异常。类加载器在调用真正的执行之前在类内存中加载类之前对依赖类进行验证。
【讨论】:
好的,但我不知道如何解决它并保留两只耳朵?我决定将 ear 项目更改为第一战,但这样我使用 EJB 端点的可能性就更少了,我不得不通过我的应用程序手动使用石英(而不是通过 Jboss 容器) 这里说的两只耳朵是同一个应用程序的不同版本? 不,它们是使用同一个库的不同版本的不同应用程序,但它们的作业是由同一个容器(JBoss)控制的石英调用的,这就是问题所在。以上是关于java.lang.NoSuchMethodError 在调用在 jboss mbean 中声明的石英作业期间的主要内容,如果未能解决你的问题,请参考以下文章