tomcat - 我在 netbeans IDE 中添加 tomcat 服务器但发生错误

标签 tomcat netbeans

CATALINA_HOME 的值 = 'C:\Program Files\Apache Software Foundation\Tomcat 7.0

value of CATALINA_HOME = 'C:\Program Files\Apache Software Foundation\Tomcat 7.0'. click here to see

i want to add server to the netbeans IDE but when im going to add the server then i get an error message that the server.xml file in the config folder is seems to be corrupted. i add an screenshot for better understanding my problem of the error which im facing. and also the code of the server.xml file as the text format.

<?xml version="1.0" encoding="UTF-8"?>
-<Server shutdown="SHUTDOWN" port="8005">
<Listener className="org.apache.catalina.startup.VersionLoggerListener"/>
<Listener className="org.apache.catalina.core.AprLifecycleListener" 
SSLEngine="on"/>
<Listener className="org.apache.catalina.core.JasperListener"/>
<Listener 
className="org.apache.catalina.core.JreMemoryLeakPreventionListener"/>
<Listener 
className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"/>
<Listener 
className="org.apache.catalina.core.ThreadLocalLeakPreventionListener"/>
-<GlobalNamingResources>
<Resource pathname="conf/tomcat-users.xml" 
factory="org.apache.catalina.users.MemoryUserDatabaseFactory" 
description="User 
database that can be updated and saved" 
type="org.apache.catalina.UserDatabase" auth="Container" 
name="UserDatabase"/>
</GlobalNamingResources>
-<Service name="Catalina">
<Connector port="8080" redirectPort="8443" connectionTimeout="20000" 
protocol="HTTP/1.1"/>
<Connector port="8009" redirectPort="8443" protocol="AJP/1.3"/>
-<Engine name="Catalina" defaultHost="localhost">
-<Realm className="org.apache.catalina.realm.LockOutRealm">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm" 
 resourceName="UserDatabase"/>
</Realm>
-<Host name="localhost" autoDeploy="true" unpackWARs="true" 
appBase="webapps">
<Valve className="org.apache.catalina.valves.AccessLogValve" pattern="%h %l 
%u %t &quot;%r&quot; %s %b" suffix=".txt" prefix="localhost_access_log" 
directory="logs"/>

</Host>

</Engine>

</Service>

</Server>

最佳答案

我通过从您的 server.xml 复制单个更改,在工作的 Tomcat 配置上重现了您的错误:

corruptServerXml

更改是从 pattern 复制的<Valve> 的属性(property)server.xml 屏幕截图中的元素:

pattern="%h %l %u %t "%r" %s %b"

该值是无效的 XML,因为它包含嵌套引号 ("%r")。

修复很简单:用 character entity reference 替换嵌套引号等价物,因此 pattern属性看起来像这样:

pattern="%h %l %u %t &quot;%r&quot; %s %b"

完成更改后,您应该能够添加 Tomcat 服务器。

附注我在您的 server.xml 文件中注意到的另一个不相关的差异是 prefix 的值<Valve> 的属性元素是 "localhost_access_log."但是 Tomcat 9 默认是 "localhost_access_log" (没有尾随句点)。

关于tomcat - 我在 netbeans IDE 中添加 tomcat 服务器但发生错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51022270/

相关文章:

tomcat - 通过身份验证转发到另一个 webapp

JSF Tomcat 容器管理身份验证和附加登录按钮

java - Tomcat强制关闭可以通过异常类型的catch block 捕获吗

java - Java IDE (NetBeans) 的奇怪行为

java - 如何在 Netbeans 中构建 Web 应用程序后运行 .war 文件

java - Tomcat 7 Jersey Jackson 200 OK 但有效载荷被剥离

java - 我的 REST 程序出错

java - Netbeans 找不到 java.io.InputStream

c++ - 如何使用 Clion 或 Netbeans 正确导入 Tensorflow 源代码

regex - 用正则表达式替换netbeans