我在eclipse中创建了一个主要为空的动态web项目。了解tomcat中的context.xml 6
它
- 没有servlet的
- 没有jsp文件
的web.xml文件是
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>testprojekt</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
</web-app>
,我增加了一个context.xml
其META-INF
文件夹
<?xml version="1.0" encoding="UTF-8"?>
<Context>
<Parameter name="companyName" value="My Company, Incorporated" override="false"/>
</Context>
我将此项目导出为WAR文件。具有以下结构:
[email protected]:$ tree
.
|-- META-INF
| |-- MANIFEST.MF
| `-- context.xml
`-- WEB-INF
|-- classes
|-- lib
`-- web.xml
4 directories, 3 files
当我将项目部署到本地tomcat(Apache Tomcat/6.0.20)时,一切都按预期工作。意思是,context.xml被复制到/ conf/Catalina/localhost并重命名为testprojekt.xml。
当我编辑testprojekt.xml到:
<?xml version="1.0" encoding="UTF-8"?>
<Context>
<Parameter name="companyName" value="My BLAH Company, Incorporated" override="false"/>
</Context>
我看到catalina.out的输出如下:
02.11.2009 13:21:35 org.apache.catalina.startup.HostConfig checkResources
INFO: Undeploying context [/testprojekt]
02.11.2009 13:21:35 org.apache.catalina.core.StandardContext resourcesStart
SCHWERWIEGEND: Error starting static Resources
java.lang.IllegalArgumentException: Document base /opt/tomcat6/webapps/testprojekt does not exist or is not a readable directory
at org.apache.naming.resources.FileDirContext.setDocBase(FileDirContext.java:142)
at org.apache.catalina.core.StandardContext.resourcesStart(StandardContext.java:4048)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4217)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:526)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:630)
at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:556)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:491)
at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1274)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:296)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1337)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1601)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1610)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1590)
at java.lang.Thread.run(Thread.java:619)
02.11.2009 13:21:35 org.apache.catalina.core.StandardContext start
SCHWERWIEGEND: Error in resourceStart()
02.11.2009 13:21:35 org.apache.catalina.core.StandardContext start
SCHWERWIEGEND: Error getConfigured
02.11.2009 13:21:35 org.apache.catalina.core.StandardContext start
SCHWERWIEGEND: Context [/testprojekt] startup failed due to previous errors
02.11.2009 13:21:35 org.apache.catalina.core.StandardContext stop
INFO: Container org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/testprojekt] has not been started
这是为什么?这是预期的结果吗?在context.xml
中更改参数的正确方法是什么?
预先感谢您。 Regards,
我不明白这个问题。我认为你在“当我编辑testprojekt.xml到:”部分后遗漏了一些解释性文本。至少我可以说这个异常信息是相当自我解释的。从字面上理解。 – BalusC 2009-11-02 12:54:07
请逃脱您的代码示例,以便我们可以看到它们。 – 2009-11-02 12:55:00
请仔细看看两个testprojekt.xml文件。我在第二个的值中添加了一个BLAH字符串。我希望,在我改变了这个值之后,我的web应用程序可以访问这些新的值。但我甚至没有来到这个部分,因为我保存后得到一个异常。我真的不明白这个例外,或者我的方法有什么问题。 – Carsten 2009-11-02 13:25:18