java 错误:文档中根元素后面的标记必须格式正确

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11584950/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 05:41:12  来源:igfitidea点击:

Error : The markup in the document following the root element must be well-formed

javajakarta-eetomcatcontext.xmlmeta-inf

提问by Suhail Gupta

The following is my context.xmlfile in the META-INFdirectory of my project :

以下是我的项目目录中的context.xml文件META-INF

<?xml version="1.0" encoding="UTF-8"?>
<Context antiJARLocking="true" path="/poll"/>

<Resource name="jdbc/PollDatasource" auth="Container" type="javax.sql.DataSource"
 driverClassName="org.apache.derby.jdbc.ClientDriver"
 url="jdbc:derby://localhost:1527/poll database;create=true"
 username="suhail" password="suhail"
 maxActive="20" maxIdle="10" maxWait="-1" />

But when I try to deploy/run the project netbeans produces the following error :

但是当我尝试部署/运行项目 netbeans 时会产生以下错误:

[Fatal Error] :4:2: The markup in the document following the root element must be 
well-formed.
W:\UnderTest\NetbeansCurrent\poll\nbproject\build-impl.xml:721: Deployment error: 
Tomcat configuration file 
W:\UnderTest\NetbeansCurrent\poll\web\META-INF\context.xml seems to be broken.
Please make sure it is parseable and valid.
See the server log for details.

Why do I get this error ? I have added the database information in the context.xml.

为什么会出现此错误?我已经在context.xml.

enter image description here

在此处输入图片说明

回答by Hoogles

In your context.xml, take out the / right before the > in your Context tag and add the end tag after the Resource. Your Resource should be defined withinyour Context.

在您的 context.xml 中,取出 Context 标记中 > 之前的 / 并在 Resource 之后添加结束标记。你的资源应该你的上下文中定义。

<Context antiJARLocking="true" path="/poll" >

    <Resource name="jdbc/PollDatasource" auth="Container" type="javax.sql.DataSource"
     driverClassName="org.apache.derby.jdbc.ClientDriver"
     url="jdbc:derby://localhost:1527/poll database;create=true"
     username="suhail" password="suhail"
     maxActive="20" maxIdle="10" maxWait="-1" />

</Context>

Hope this helps!

希望这可以帮助!