web.xml <context-param>只能放一对<param-name>和<param-value>

在tomcat里配置多个实例时,不能使用默认的webAppRootKey,需要明确在web.xml里配置webAppRootKey值,否则在启动时会报错,报错如下示

严重: Exception sending context initialized event to listener instance of class ch.qos.logback.ext.spring.web.LogbackConfigListener
java.lang.IllegalStateException: Web app root system property already set to different value: ‘webapp.root‘ = [C:\apache-tomcat-8.0.32\webapps\weblearn\] instead of [C:\apache-tomcat-8.0.32\webapps\weblearn3\] - Choose unique values for the ‘webAppRootKey‘ context-param in your web.xml files!
	at org.springframework.web.util.WebUtils.setWebAppRootSystemProperty(WebUtils.java:162)
	at ch.qos.logback.ext.spring.web.WebLogbackConfigurer.initLogging(Unknown Source)
	at ch.qos.logback.ext.spring.web.LogbackConfigListener.contextInitialized(Unknown Source)
	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4812)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5255)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
	at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725)
	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701)
	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
	at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:585)
	at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1794)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)

所以在web.xml里配置了webAppRootKey,因为之前配置了logback的配置,于是将webAppRootKey的配置与logback的配置放在一起,如下示.

	<context-param>
		<param-name>logbackConfigLocation</param-name>
		<param-value>/WEB-INF/config/logback3.xml</param-value>
		<param-name>webAppRootKey</param-name>
		<param-value>weblearn3.root</param-value>
	</context-param>

重启服务器后发现没有上面的报错了,但是服务器日志却不生成到文件里了,于是判断context-param只能放一对param-name和param-value,最后修改如下

	<context-param>
		<param-name>webAppRootKey</param-name>
		<param-value>weblearn3.root</param-value>
	</context-param>
	<context-param>
		<param-name>logbackConfigLocation</param-name>
		<param-value>/WEB-INF/config/logback3.xml</param-value>
	</context-param>

问题解决

时间: 2024-08-26 17:05:07

web.xml <context-param>只能放一对<param-name>和<param-value>的相关文章

Spring项目的配置文件们(web.xml context servlet springmvc)

我们的spring项目目前用到的配置文件包括1--web.xml文件,这是java的web项目的配置文件.我理解它是servlet的配置文件,也就是说,与spring无关.即使你开发的是一个纯粹jsp页面的web项目,你也必须配置这个文件.我们的java web项目肯定写了很多servlet代码,这些servlet需要运行在servlet容器中,这个容器就是tomcat的重要组件.也就是,你的web项目需要运行在tomcat中,那么你必须提供一个web.xml文件作为配置文件.在这个文件中,通过

【web.xml】报错java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener

今天搭建新的项目,虽然在web.xml中配置了ContextLoaderListener以及IntrospectorCleanupListener 如下: web.xml中部分代码: 1 <!-- 监听servletContext,启动contextConfigLocation中的spring配置信息 --> 2 <listener> 3 <listener-class>org.springframework.web.context.ContextLoaderListe

Tomcat部署web项目,虚拟目录,上下文(Context),WEB-INF,web.xml,servlet

Web项目的uri模型大致如下: http://localhost:8080 (/context) (/resource) 站点/上下文/资源 一. Tomcat中指定上下文(Context) 方法一,位于webapps文件夹中的web项目,无需指定Context,Tomcat默认解析为该web项目根文件夹的名称,即为真实目录名称. 方法二,在server.xml中指定Context. 编辑conf\server.xml文件,在元素之间加入子元素,内容如下: <Context docBase=”

Context域从web.xml获取数据学习笔记

web.xml配置文件 <?xml version="1.0" encoding="UTF-8"?> <web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="h

Web.xml详解(转)(Filter,context,listener)

web.xml 详细解释!!(链接) web.xml加载过程(步骤) 首先简单说一下,web.xml的加载过程. 当我们去启动一个WEB项目时,容器包括(JBoss.Tomcat等)首先会读取项目web.xml配置文件里的配置,当这一步骤没有出错并且完成之后,项目才能正常地被启动起来. 启动web项目时,先读取web.xml中的节点: <listener></listener> 和 <context-param></context-param> 容器创建一个

SpringMVC的三个XML(web.xml、application-context.xml、context-dispatcher.xml)

现代Web应用程序广泛使用MVC(model.view.controller,记得在专升本的考试中还考过这个定义,当时并不能使用流畅的语言解释)模式,那么SpringMVC就恰好可以轻松帮我们搭建一个Web开发环境.而要搭好开发环境,熟知SpringMVC的三个XML(web.xml.application-context.xml.context-dispatcher.xml)就显得必不可少.而我呢,虽然前前后后左左右右也大见过三次Web框架,但每次都纠结的要了老命,那么痛定思痛,我决定下功夫把

[从零搭网站五]http网站Tomcat配置web.xml和server.xml

点击下面连接查看从零开始搭网站全系列 从零开始搭网站 上一章我们在CentOS下搭建了Tomcat,但是还是没有跑起来...那么这一章就把最后的配置给大家放上去. 有两种方式:一种是用 rm -f 给这两个文件删掉,再用vim建新的出来.另一种是vim编辑,输入:set nu 显示行号,再输入:1,最后一行的行号d 把全文删掉. 然后再复制粘贴我给你们的配置文件就行. web.xml  , 完全不用修改,直接复制就行了: <?xml version="1.0" encoding=

web.xml的配置中&lt;context-param&gt;配置作用

<context-param>的作用: web.xml的配置中<context-param>配置作用1. 启动一个WEB项目的时候,容器(如:Tomcat)会去读它的配置文件web.xml.读两个节点: <listener></listener> 和 <context-param></context-param> 2.紧接着,容器创建一个ServletContext(上下文),这个WEB项目所有部分都将共享这个上下文. 3.容器将&l

[转载] web.xml之&lt;context-param&gt;与&lt;init-param&gt;的区别与作用

原文地址: http://www.cnblogs.com/hzj-/articles/1689836.html <context-param>的作用:web.xml的配置中<context-param>配置作用1. 启动一个WEB项目的时候,容器(如:Tomcat)会去读它的配置文件web.xml.读两个节点: <listener></listener> 和 <context-param></context-param> 2.紧接着,