在eclipse中获取错误:SEVERE:ContainerBase.addChild:start:org.apache.catalina.LifecycleException:

时间:2014-09-05 15:28:43

标签: java tomcat servlets eclipse-kepler

我正在使用apache-tomcat-7.0.55和java 1.7.0_67从Dynamic Web Project eclipe kepler SR2运行servlet文件 运行XmlServlet.java时在eclipse中的服务器控制台中收到以下错误。我在PC和项目中使用相同版本的Java运行时。

此外,我没有采用相同的方式。

[控制台出错,浏览器中有404]

    Sep 05, 2014 9:04:14 PM org.apache.catalina.core.AprLifecycleListener init

    INFO: The APR based Apache Tomcat Native library which allows optimal performance in        

    production  environments was not found on the java.library.path: 

    C:\Program Files\Java\jre7\bin;C:\Windows\Sun\Java\bin;

    C:\Windows\system32;C:\Windows;

    C:/Program  Files/Java/jre7/bin/client;C:/Program Files/Java/jre7/bin;

    C:/Program Files/Java/jre7/lib/i386;C:\Windows\system32;C:\Windows;
    C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;F:\Techie\Jee_Kepler;;.
    Sep 05, 2014 9:04:14 PM org.apache.coyote.AbstractProtocol init
    INFO: Initializing ProtocolHandler ["http-bio-8080"]
    Sep 05, 2014 9:04:14 PM org.apache.coyote.AbstractProtocol init
    INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
    Sep 05, 2014 9:04:14 PM org.apache.catalina.startup.Catalina load
    INFO: Initialization processed in 952 ms
    Sep 05, 2014 9:04:14 PM org.apache.catalina.core.StandardService startInternal
    INFO: Starting service Catalina
    Sep 05, 2014 9:04:14 PM org.apache.catalina.core.StandardEngine startInternal
    INFO: Starting Servlet Engine: Apache Tomcat/7.0.55
    Sep 05, 2014 9:04:15 PM org.apache.catalina.util.SessionIdGenerator createSecureRandom
    INFO: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [163]       milliseconds.
Sep 05, 2014 9:04:15 PM org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deploying configuration descriptor    F:\Techie\Jee_Kepler\WorkSpace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\conf\Catalina\loca   lhost\educate.xml
    Sep 05, 2014 9:04:15 PM org.apache.catalina.startup.SetContextPropertiesRule begin
    WARNING: [SetContextPropertiesRule]{Context} Setting property 'source' to
    'org.eclipse.jst.jee.server:educate' did not find a matching property.
    Sep 05, 2014 9:04:15 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
    WARNING: [SetPropertiesRule]{Context/Loader} Setting property 'useSystemClassLoaderAsParent'
    to  'false' did not find a matching property.

    Sep 05, 2014 9:04:15 PM org.apache.catalina.core.ContainerBase addChildInternal
    SEVERE: ContainerBase.addChild: start: 
    org.apache.catalina.LifecycleException: Failed to start component 
    [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/educate]]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
    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:649)
    at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:672)
    at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1862)
    at java.util.concurrent.Executors$RunnableAdapter.call(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)

Caused by: java.lang.IllegalArgumentException: Invalid <url-pattern> XmlServletPath in servlet      mapping

at org.apache.catalina.core.StandardContext.addServletMapping(StandardContext.java:3298)
at org.apache.catalina.core.StandardContext.addServletMapping(StandardContext.java:3273)
at org.apache.catalina.deploy.WebXml.configureContext(WebXml.java:1438)
at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1344)
at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:876)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:374)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5378)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    ... 10 more

    Sep 05, 2014 9:04:15 PM org.apache.catalina.startup.HostConfig deployDescriptor
    SEVERE: Error deploying configuration descriptor        F:\Techie\Jee_Kepler\WorkSpace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\conf\Catalina\loca   lhost\educate.xml
java.lang.IllegalStateException: ContainerBase.addChild: start:     org.apache.catalina.LifecycleException: Failed to start component   [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/educate]]
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:904)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:649)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:672)
at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1862)
at java.util.concurrent.Executors$RunnableAdapter.call(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)

Sep 05, 2014 9:04:15 PM org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deployment of configuration descriptor    F:\Techie\Jee_Kepler\WorkSpace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\conf\Catalina\loca   lhost\educate.xml has finished in 261 ms
Sep 05, 2014 9:04:15 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
Sep 05, 2014 9:04:15 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Sep 05, 2014 9:04:15 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 1174 ms

[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" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>educate</display-name>

<servlet>
        <servlet-name> xmlServlet </servlet-name>
        <servlet-class> com.schoolmanager.handler.MyXmlServlet </servlet-class>
</servlet>

    <servlet-mapping>
        <servlet-name> xmlServlet </servlet-name>
        <url-pattern>XmlServletPath</url-pattern>
    </servlet-mapping>

</web-app>

[Servlet文件:XmlServlet.java]

package com.schoolmanager.handler;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class XmlServlet extends javax.servlet.http.HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp)
            throws ServletException, IOException {
        // TODO Auto-generated method stub
        System.out.println("check servlet");
    }
}

1 个答案:

答案 0 :(得分:0)

您只需进行一次修改

<servlet-mapping>
    <servlet-name>XmlServlet</servlet-name>
    <url-pattern>/XmlServlet</url-pattern>
  </servlet-mapping>

在url-pattern中的Xml Servlet之前添加一个反斜杠并检查。