[英]Tomcat Server fails to start
Problem: 问题:
When I try to add following code to context.xml of Tomcat 7 It gives this error. 当我尝试将以下代码添加到Tomcat 7的context.xml中时,出现此错误。
(NOTE: I'm adding this code from inside the Eclipse) (注意:我是从Eclipse内部添加此代码的)
<?xml version="1.0" encoding="UTF-8"?>
<Context>
<!-- Default set of monitored resources -->
<WatchedResource>WEB-INF/web.xml</WatchedResource>
<Resource
name="jdbc/UsersDB"
auth="Container"
type="javax.sql.DataSource"
maxActive="100"
maxIdle="30"
maxWait="10000"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/usersDB"
username="root"
password="secret"
/>
</Context>
Error: 错误:
Could not load the Tomcat server configuration at \\Servers\\Tomcat v7.0 Server at localhost-config. 无法在localhost-config的\\ Servers \\ Tomcat v7.0 Server上加载Tomcat服务器配置。 The configuration may be corrupt or incomplete. 配置可能已损坏或不完整。 Element type "Resource" must be followed by either attribute specifications, ">" or "/>" . 元素类型“ Resource”之后必须是属性规范“>”或“ />” 。
And when I remove this code and save context.xml , Server starts successfully without doing anything (Refreshing and all). 当我删除此代码并保存context.xml时,Server会成功启动而无需执行任何操作(刷新和全部)。
What I have tried: 我尝试过的
Referred This question: publishing failed with multiple errors eclipse 引荐这个问题: 发布失败,出现多个错误
Nothing is working. 什么都没用。
What should I try Now? 我现在应该尝试什么?
UPDATE: 更新:
Tomcat server started successfully. Tomcat服务器成功启动。 I just typed everything in context.xml rather than copy paste the code. 我只是在context.xml中键入了所有内容,而不是复制粘贴代码。 It could be some encoding problem I guess in copy pasting the code directly into eclipse file. 我猜可能是一些编码问题,直接将代码粘贴到eclipse文件中。
This is how it should look . 这就是它的外观。 Resource should be properly enclosed within the Context. 资源应正确包含在上下文中。 Like: 喜欢:
<?xml version="1.0" encoding="UTF-8"?>
<Context antiJARLocking="true" path="/webAppName">
<Resource
name="jdbc/UsersDB"
auth="Container"
type="javax.sql.DataSource"
maxActive="100"
maxIdle="30"
maxWait="10000"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/usersDB"
username="root"
password="secret" />
</Context>
I have similar thing working. 我有类似的工作。 All the difference - I have one single row, not multiple lines like you have. 所有的不同-我只有一行,而不是像您一样的多行。 Try it in a single row. 单行尝试。 Plus before you copy it to eclipse, try copy it to notepad, or another simple editor to remove invalid chars. 另外,在将其复制到Eclipse之前,请尝试将其复制到记事本或其他简单的编辑器中以删除无效字符。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.