一 错误地方
2018-09-17 14:34:30,474 [localhost-startStop-1] WARN org.apache.catalina.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) 2018-09-17 14:34:30,475 [localhost-startStop-1] WARN org.apache.catalina.loader.WebappClassLoaderBase - The web application [ROOT] appears to have started a thread named [globalEventExecutor-2-2] 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.LinkedBlockingQueue.poll(LinkedBlockingQueue.java:467) io.netty.util.concurrent.GlobalEventExecutor.takeTask(GlobalEventExecutor.java:90) io.netty.util.concurrent.GlobalEventExecutor$TaskRunner.run(GlobalEventExecutor.java:230) io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:144) java.lang.Thread.run(Thread.java:745) Disconnected from the target VM, address: '127.0.0.1:55751', transport: 'socket' Process finished with exit code 1
遇见这种错误,我的心就拔凉拔凉的,以前遇到这种不报具体错误的,只得用排除法一步一步的排查!
1.出现这种错误的可能原因: 循环调用,导致堆栈溢出;
解决办法:把自己刚写的代码利用排除法,一步一步的排除;
2.出现这种错误的可能原因: 配置文件获取不到;
有的是用SpringCloud搭建的框架,有个config-server 来获取配置文件,这种有个坑 不同的局域网内,是获取不到配置文件的,比如你把config-server部署到阿里云上,你在你本地是获取不到配置文件的,再比如,你把配置中心部署到华南地区,那么阿里云在华北地区的是获取不到配置文件的 坑。。。。。。。。。。。。。。
3.经过排除法才找到这样的一个错:
/**
* 每天凌晨3点执行
*/
@Scheduled(cron = "0 0 3 * * * ?")
public void deleteOverdueFile(){
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Calendar calendar = Calendar.getInstance();
calendar.setTime(new Date());
calendar.add(Calendar.DATE,-30);
log.debug("过期时间:"+sdf.format(calendar.getTime()));
weixinChatUploadLogService.deleteOverdueFile(calendar.getTime());
}
咋眼一看没啥问题,可是你万万想不到 定时任务的时间表达式写错了 此处应该有个捂脸的表情!
/** * 每天凌晨3点执行 */ @Scheduled(cron = "0 0 3 * * ?") //这样才是对的 public void deleteOverdueFile(){ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Calendar calendar = Calendar.getInstance(); calendar.setTime(new Date()); calendar.add(Calendar.DATE,-30); log.debug("过期时间:"+sdf.format(calendar.getTime())); weixinChatUploadLogService.deleteOverdueFile(calendar.getTime()); }
在此给大家教一种排除错误的办法 那就是 最常用的 排除法!
当你不知道问题出在哪里时。你把你最近写的代码,有可能出错的地方注释掉,然后慢慢的缩小错误范围 !
哈哈 这样慢慢的你就是排雷小能手!
此处应该有掌声!