quartz + spring 启动项目时,报错The web application [] appears to have started a thread named.........
只是想记录自己的错误信息,下次再出现就知道怎么操作,不用再查找资料
解决办法:
package com.wqq.quartz_test.schedule; import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener; import org.springframework.web.context.WebApplicationContext; /**
* @author wangqq
* @version 创建时间:2018年9月14日 上午9:49:29
* 类说明
*/
public class QuartzContextListener implements ServletContextListener { @Override
public void contextInitialized(ServletContextEvent sce) {
// TODO Auto-generated method stub } @Override
public void contextDestroyed(ServletContextEvent arg0) {
// TODO Auto-generated method stub
WebApplicationContext webApplicationContext = (WebApplicationContext) arg0
.getServletContext()
.getAttribute(
WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE);
org.quartz.impl.StdScheduler startQuertz = (org.quartz.impl.StdScheduler) webApplicationContext
.getBean("startQuertz");
if(startQuertz != null) {
startQuertz.shutdown();
}
try {
Thread.sleep();
} catch (InterruptedException e) {
e.printStackTrace();
}
} }
其中
"startQuertz" 是在spring-quartz.xml中
<bean id="startQuartz" lazy-init="false" autowire="no"
class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers">
<list>
<ref bean="jobTriggerA"/>
<ref bean="jobTriggerB"/>
</list>
</property>
<property name="quartzProperties">
<props>
<prop key="org.quartz.scheduler.instanceName">buy_it_now</prop>
<prop key="org.quartz.threadPool.threadCount"></prop>
<prop key="org.quartz.plugin.shutdownhook.class">org.quartz.plugins.management.ShutdownHookPlugin</prop>
<prop key="org.quartz.plugin.shutdownhook.cleanShutdown">true</prop>
<prop key="org.quartz.threadPool.threadsInheritContextClassLoaderOfInitializingThread">true</prop>
</props>
</property>
<property name="configLocation" value="classpath:quartz/quartz.properties"></property>
<property name="applicationContextSchedulerContextKey" value="applicationContext" />
</bean>
然后在web.xml中配置
<listener>
<listener-class>com.wqq.quartz_test.schedule.QuartzContextListener</listener-class>
</listener>
虽然不报错了,但是把这个注释掉,也不报错了,不知道程序发什么疯,可能有些原理还不知道
quartz + spring 启动项目时,报错The web application [] appears to have started a thread named.........的更多相关文章
- 已解决: idea创建并部署SpringMVC项目时 报错 java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
用IDEA创建并运行SpringMVC项目时,最初发现没有Servlet包,这个问题已在上篇解决,然而当我们尝试去运行此时的SpringMVC项目时,发现仍然有错误.ClassNotFoundExce ...
- spring+hibernate整合:报错org.hibernate.HibernateException: No Session found for current thread
spring+hibernate整合:报错信息如下 org.hibernate.HibernateException: No Session found for current thread at o ...
- 启动tomcat时,报错:IOException while loading persisted sessions: java.io.EOFException解决方法
报错原因:加载持久化session错误,tomcat加载时读取的文件是是*.ser,session序列化文件,文件的位置是tomcat\work\Catalina\localhost,找到sessio ...
- idea 创建的maven+spring+mybatis项目整合 报错无法创建bean
报错如下: Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with n ...
- tomcat报错this web application instance has been stopped already问题
上网搜了下,大部分的报错原因:重启时候 之前的tomcat未正常关闭 ,导致在重启时候 报了这个问题.mac下解决: ps -ef|grep tomcat 找到在进行的tomcat ,kill -9 ...
- idea 创建运行web项目时,报错: Can not issue executeUpdate() for SELECTs解决方案
最近在做一个Web课程设计的时候遇到了如下的问题. java.sql.SQLException: java.lang.RuntimeException: java.sql.SQLException: ...
- tomcat部署项目时 报错Tomcat version 7.0 only supports J2EE 1.2, 1.3, 1.4, and Java EE 5 and 6 Web modules
Tomcat version 7.0 only supports J2EE 1.2, 1.3, 1.4, and Java EE 5 and 6 Web modules 解决方法: 找到文件 .set ...
- linux下启动tomcat时卡在Deploying web application directory
找到jdk1.x.x_xx/jre/lib/security/Java.security文件,在文件中找到securerandom.source这个设置项,将其改为: securerandom.sou ...
- 非root用户启动redis容器报错mkdir: cannot create directory '/bitnami/redis': Permission denied
问题:使用docker启动容器时,报错如下 zh@debian:~/testPath$ docker-compose up redis Starting testpath_redis_1 ... do ...
随机推荐
- vs2017 创建项目推送到Git上
地址 在从本地往云上推送的时候遇到了这样的问题 将分支推送到远程存储库时遇到错误: rejected Updates were rejected because the remote contains ...
- Verification之PSL之intro
1 PSL - Property specification language 1.1 Property - Characteristics of the designs/verification e ...
- windows下安装Python-Whl文件
原文链接:http://blog.sciencenet.cn/home.php?mod=space&uid=1181151&do=blog&id=865515 Note1. 整 ...
- react构建前端项目方法汇总
react简介: 一.使用react 创建一个PC端的项目 (a):使用 yemon 创建一个 webpack 的 react 的项目 控制台安装并且产看 yemon 的版本 yo -v (b): 全 ...
- Golang实现常用排序算法
主函数package main import ( "fmt" "math/rand" "sort" "time") co ...
- SharePoint Designer 2013 开启新式验证(Modern Authentication)
首先安装office 2013全家桶 再安装SharePoint Designer 2013 安装完之后,去windows检查更新,并把所有需要更新的都更新了 (更新之后我还通过KMS激活了offic ...
- 【ubuntu子系统】使用windows自带的ubuntu子系统
在windows10系统中,自带了一款ubuntu子系统,就像是一个应用程序,一款软件,提供ubutnu的terminal窗口,可以使用对应的命令行模式.最重要的是,可以直接用来连接linux服务 ...
- Spring Cloud系列(三) 应用监控与管理Actuator
Spring Cloud系列(二) 应用监控与管理Actuator 前言:要想使用Spring Cloud ,Spring Boot 提供的spring-boot-starter-actuator模块 ...
- 2.3 SVN在myeclipse中的使用
一.将svn插件文件夹复制到myeclipse的dropins目录下,并重启myeclipse 二.从SVN中检查项目到myeclipse 2.打开myeclipse,点击window的show v ...
- flask-sqlalchemy 配置 mysql (转载的文章)
一.当然是把必备的包给安装上才行: Flask-SQLAlchemy pip install flask-sqlalchemy MySQL windows下64位压缩包的安装方式可以参考: http: ...