0

このエラーが発生して立ち往生していますか?!単純なXMLファイルと単純なJavaファイルがあります。

私のxml:

<web-app xmlns="http://java.sun.com/xml/ns/javaee">
<servlet>
    <servlet-name>hello</servlet-name>
    <servlet-class>test.HelloServlet</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>hello</servlet-name>
    <url-pattern>/hello/</url-pattern>
</servlet-mapping>
</web-app>

そして私のJavaは:

package test;
import java.io.*;
import javax.servlet.http.*;
import javax.servlet.*;

public class HelloServlet extends HttpServlet {

public void doGet (HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
PrintWriter out = res.getWriter();
out.println("Hello, world!");
out.close();
}
}

私のxmlはWEB-INF内に配置されます。localhost:8080を実行すると、Tomcatページが表示されます。

誰かが私を助けることができますか?

Jan 24, 2013 3:48:58 PM org.apache.catalina.startup.ContextConfig parseWebXml
SEVERE: Parse error in application web.xml file at jndi:/localhost/opdracht-les1/WEB-INF/web.xml
org.xml.sax.SAXParseException; systemId: jndi:/localhost/opdracht-les1/WEB-INF/web.xml; lineNumber: 5; columnNumber: 2; The markup in the document following the root element must be well-formed.
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$TrailingMiscDriver.next(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
    at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
    at org.apache.tomcat.util.digester.Digester.parse(Digester.java:1537)
    at org.apache.catalina.startup.ContextConfig.parseWebXml(ContextConfig.java:1878)
    at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1259)
    at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:878)
    at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:369)
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
    at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5173)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
    at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:977)
    at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1655)
    at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
    at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

Jan 24, 2013 3:48:58 PM org.apache.catalina.startup.ContextConfig parseWebXml
SEVERE: Occurred at line 5 column 2
Jan 24, 2013 3:48:58 PM org.apache.catalina.startup.ContextConfig configureStart
SEVERE: Marking this application unavailable due to previous error(s)
Jan 24, 2013 3:48:58 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Error getConfigured
Jan 24, 2013 3:48:58 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Context [/opdracht-les1] startup failed due to previous errors
Jan 24, 2013 3:53:09 PM org.apache.catalina.startup.HostConfig deleteRedeployResources
INFO: Undeploying context [/opdracht-les1]
Jan 24, 2013 3:53:29 PM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive E:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\opdracht-les1.war
4

1 に答える 1

0

Javaサーブレットのデプロイメント記述子には、もう少し名前空間宣言が必要です。

<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemalocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">  
于 2013-01-24T15:23:55.297 に答える