java.lang.IllegalStateException: Cannot initialize context because there is already a root application context present
@Controller
@ComponentScan
@Configuration
@EnableScheduling
@EnableAutoConfiguration(exclude={DataSourceAutoConfiguration.class, DataSourceTransactionManagerAutoConfiguration.class, RedisAutoConfiguration.class, MybatisAutoConfiguration.class})
@ImportResource(locations = {"classpath*:app.xml"})
public class AppMain extends SpringBootServletInitializer implements ApplicationContextAware {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
// return super.configure(builder);
return builder.sources(AppMain.class);
} @Override
public void onStartup(ServletContext servletContext) throws ServletException {
servletContext.setInitParameter("logSystem","log4j,logback");
servletContext.setInitParameter("loggingLevel", "INFO");
servletContext.setInitParameter("loggingCharset", "UTF-8");
servletContext.setInitParameter("contextConfigLocation", "<NONE>");
super.onStartup(servletContext);
}
}
For anyone with a similar problem - turns out that spring-jersey used in the project was setting up its own context. My context and the spring-jersey one were initialized in random order apparently. More info here:
https://java.net/jira/browse/JERSEY-2038
https://java.net/projects/jersey/lists/users/archive/2014-03/message/124
The suggested solution of adding:
servletContext.setInitParameter("contextConfigLocation", "<NONE>");
In WebAppInitializer implementation didn't work reliably due to initialization order. What solved the problem was adding its xml equivalent:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value></param-value>
</context-param>
as the firt parameter in web.xml, ensuring that its set before the context is initialized.
java.lang.IllegalStateException: Cannot initialize context because there is already a root application context present的更多相关文章
- java.lang.IllegalStateException: ApplicationEventMulticaster not initialized - call 'refresh' before multicasting events via the context 错误
spring boot 项目启动报错:原因一般是注入了相同名字的service -- :: com.gxcards.mes.MainWwwWeb: logStartupProfileInfo INFO ...
- tomcat启动时检测到循环继承而栈溢出的问题:Caused by: java.lang.IllegalStateException: Unable to complete the scan for annotations for web application [/test] due to a StackOverflowError. Possible root causes include
最近在公司更新一个老项目的时候,发现部署项目后tomcat报错,错误如下: Caused by: java.lang.IllegalStateException: Unable to complete ...
- Caused by: java.lang.IllegalStateException: Unable to complete the scan for annotations for web application [/Cppcc] due to a StackOverflowError. Possible root causes include a too low setting for -Xs
解决办法:(1)修改D:\Java\apache-tomcat-7.0.88\conf\catalina.properties (122line) (2)如org.apache.catalina.st ...
- tomcat启动报错:java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException:
tomcat日志: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start com ...
- spring低版本报错:java.lang.IllegalStateException: Context namespace element ‘annotation-config’ and its parser class [*] are only available on
参考来源:http://blog.csdn.net/sunxiaoyu94/article/details/50492083 使用spring低版本(2.5.6),使用jre 8发现错误: Unexp ...
- nested exception is java.lang.IllegalStateException: Context namespace element 'annotation-config' a
公司还用的是spring低版本,今天用jre 8测试了一下,发现错误: Unexpected exception parsing XML document from class path resour ...
- scw——01 java.lang.IllegalStateException: Could not initialize plugin: interface org.mockito.plugins.MockMake
错误: java.lang.IllegalStateException: Could not initialize plugin: interface org.mockito.plugins.Mock ...
- java.lang.IllegalStateException: class utils.filter.ContentFilter is not a javax.servlet.Filter
1.错误描写叙述 2016-01-12 11:27:01.787:WARN:oejuc.AbstractLifeCycle:FAILED ContentFilter: java.lang.Illega ...
- eclipse启动报错java.lang.IllegalStateException: LifecycleProcessor not initialized - call 'refresh' befo
报错: java.lang.IllegalStateException: LifecycleProcessor not initialized - call 'refresh' before invo ...
随机推荐
- todolist形式的搜索框,分开组件写的,点击上下键时,框内显示当前选中的内容
### 首先 安装react 脚手架 cnpm install create-react-app -g //只需要在电脑上安装一次就好了,以后不用再下载了 ### 创建项目 crea ...
- laydate时间控件:开始时间,结束时间最大最小值
时间控件地址及插件下载链接:https://www.layui.com/doc/modules/laydate.html 填充时间已两个功能为例: 1.添加功能 :时间 规则:选择开始时间后,点击结束 ...
- cadence 16.3 安装教程
http://wenku.baidu.com/link?url=mGICX2QxuxVcYGNEaOIUOK1t0LQFN4m8cp_bJF0XmvZp0TLn8OoMxjmXa-8mTa0_V0YV ...
- 【VS开发】【数据库开发】libevent简单入门和介绍
libevent是一个基于事件触发的网络库,memcached底层也是使用libevent库,今天学习下. 总体来说,libevent有下面一些特点和优势: * 统一数据源, 统一I/O事件,信号和定 ...
- SpringBoot开发
创建一个Spring Boot,可以直接使用构建工具(Maven或Gradle)创建,也可以使用spring.io网站创建,一般会选择使用spring.io创建 使用IDEA创建一个Spring Bo ...
- Redis内存数据库的基本语法
Redis: - nosql数据库,非关系型数据库 - 支持5大数据类型 (字符串String,列表list.字典hash,集合set,zset) - 与之相似的有memcache,但memcache ...
- [学习笔记] Blender 模型编辑-挤出
按TAB键进入模型编辑模式,再次按TAB键退出编辑模式. 或者在菜单按 Modeling 也会进入编辑模式. 进入编辑模式之后,会显示如下额外的工具栏: 下面分别对应点.线.面三种选择方式:选择了两个 ...
- JDBC 注册驱动,获取连接
jdbc 动力节点视频教程 JDBC编程六步 1.注册驱动(作用:告诉Java程序,即将要连接的是哪个品牌的数据库) 2.获取连接 (表示JVM进程和数据库进程之间的通道打开了,属于进程间的通信,重量 ...
- C++Primer 5th Chap9 Sequential Container
vector 可变大小数组,支持快速随机访问(在除了尾部之外部分插入删除元素很慢) deque 双端队列,支持快速随机访问(在头尾插入删除元素很快) list 双向链表,仅支持双向顺序访问(在任何位置 ...
- 13_日期时间、Math、枚举
日期时间.Math.枚举 日期时间 计算机如何表示时间? GMT时间指格林尼治所在地的标准时间,也称为时间协调时(UTC),其他地区的时间都是相对于GMT时间的偏移. 北京位于东八区 = UTC ...