做一个积极的人

编码、改bug、提升自己

我有一个乐园,面向编程,春暖花开!

今天发现一个错误,简单记录一下,运行一个项目一直启动不了,发现控制台报错了。

首先说明一下这是一个Spring boot 集成Quartz做任务调度的项目,版本信息就不贴了,因为和本文最终的解决方案没有什么关系。

错误信息如下:

2019-09-05 09:56:23.993  WARN [web-scheduler-localhost,,,] 5324 --- [ender@21a0676f}] s.c.a.AnnotationConfigApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'eurekaRibbonClientConfiguration': Unsatisfied dependency expressed through field 'clientConfig'; nested exception is org.springframework.beans.factory.BeanCreationNotAllowedException: Error creating bean with name 'eurekaClientConfigBean': Singleton bean creation not allowed while singletons of this factory are in destruction (Do not request a bean from a BeanFactory in a destroy method implementation!)
2019-09-05 09:56:23.997  INFO [web-scheduler-localhost,,,] 5324 --- [           main] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]
2019-09-05 09:56:24.003  WARN [web-scheduler-localhost,,,] 5324 --- [ost-startStop-1] o.a.c.loader.WebappClassLoaderBase       : The web application [ROOT] appears to have started a thread named [RxIoScheduler-1 (Evictor)] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
 sun.misc.Unsafe.park(Native Method)
 java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:215)
 java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2078)
 java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1093)
 java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:809)
 java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1067)
 java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1127)
 java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
 java.lang.Thread.run(Thread.java:745)

根据平时的看错误经验:

Error creating bean with name 'eurekaRibbonClientConfiguration': Unsatisfied dependency expressed through field 'clientConfig'; nested exception is org.springframework.beans.factory.BeanCreationNotAllowedException: Error creating bean with name 'eurekaClientConfigBean': Singleton bean creation not allowed while singletons of this factory are in destruction (Do not request a bean from a BeanFactory in a destroy method implementation!)

错误不就是这个吗,但事实貌似不是这样,排查代码和配置,没有发现代码和配置有任何的问题。

于是就耐心看整个启动日志的输出,发现在了下面这一句异常(控制台上 这一句异常信息和其他日志一样,没有任何突出之处)。

Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: 
Error creating bean with name 'quartzScheduler' defined in class path resource [org/springframework/boot/autoconfigure/quartz/QuartzAutoConfiguration.class]: 
Invocation of init method failed; 
nested exception is org.quartz.JobPersistenceException: Couldn't retrieve job: Table 'xyz.QRTZ_JOB_DETAILS' doesn't exist 
[See nested exception: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'xyz.QRTZ_JOB_DETAILS' doesn't exist]

从这句异常Error creating bean with name 'quartzScheduler' defined in class path resource之后发现容器开始关Quartz线程开始停止,容器也开始关闭。那分析就是这句异常导致服务不能重启的。上面的那个异常不是罪魁祸首,而是受害者。

知道了核心问题那就开始解决吧。Couldn't retrieve job: Table 'xyz.QRTZ_JOB_DETAILS' doesn't exist ,看出是xyz库中没有QRTZ_JOB_DETAILS,这个表,于是我打开navicat,连上数据库打开xyz ,发现这个QRTZ_JOB_DETAILS是存在的,只不过是小写,不是日子提示的大写。

这种情况我立马想到之前整理的过一篇文章,不是它嘛。一个因MySQL大小写敏感导致的问题

到这里 这个问题就结束了,我之所以记录这篇文章:

有一些错误,能够通过提示就找到原因。这个错误就是罪魁祸首。
而有一些错误,它只是受害者。而真正的错误原因隐藏在另一个地方。需要耐心寻找并发现它!

希望遇到类似情况的伙伴看到这篇能够有所收获。 peace&love

Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐