Java EE Eclipse Servlet Tomcat 7错误:名为[...]的servlet都映射到不允许的url-pattern [...]

时间:2016-01-22 18:44:34

标签: eclipse tomcat servlets

我刚开始使用Eclipse Servlet,在尝试在服务器上运行动态Web项目时出现此错误:

Jan 22, 2016 7:16:51 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
    WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:couchfriendslsrs' did not find a matching property.
    Jan 22, 2016 7:16:51 PM org.apache.catalina.startup.VersionLoggerListener log
    INFO: Server version:        Apache Tomcat/7.0.67
    Jan 22, 2016 7:16:51 PM org.apache.catalina.startup.VersionLoggerListener log
    INFO: Server built:          Dec 7 2015 13:07:11 UTC
    Jan 22, 2016 7:16:51 PM org.apache.catalina.startup.VersionLoggerListener log
    INFO: Server number:         7.0.67.0
    Jan 22, 2016 7:16:51 PM org.apache.catalina.startup.VersionLoggerListener log
    INFO: OS Name:               Windows 8.1
    Jan 22, 2016 7:16:51 PM org.apache.catalina.startup.VersionLoggerListener log
    INFO: OS Version:            6.3
    Jan 22, 2016 7:16:51 PM org.apache.catalina.startup.VersionLoggerListener log
    INFO: Architecture:          amd64
    Jan 22, 2016 7:16:51 PM org.apache.catalina.startup.VersionLoggerListener log
    INFO: Java Home:             C:\Program Files\Java\jdk1.8.0_71\jre
    Jan 22, 2016 7:16:51 PM org.apache.catalina.startup.VersionLoggerListener log
    INFO: JVM Version:           1.8.0_71-b15
    Jan 22, 2016 7:16:51 PM org.apache.catalina.startup.VersionLoggerListener log
    INFO: JVM Vendor:            Oracle Corporation
    Jan 22, 2016 7:16:51 PM org.apache.catalina.startup.VersionLoggerListener log
    INFO: CATALINA_BASE:         C:\Programming Files\EclipseJEE\.metadata\.plugins\org.eclipse.wst.server.core\tmp0
    Jan 22, 2016 7:16:51 PM org.apache.catalina.startup.VersionLoggerListener log
    INFO: CATALINA_HOME:         C:\Program Files\Apache Tomcat\apache-tomcat-7.0.67-windows-x64\apache-tomcat-7.0.67
    Jan 22, 2016 7:16:51 PM org.apache.catalina.startup.VersionLoggerListener log
    INFO: Command line argument: -Dcatalina.base=C:\Programming Files\EclipseJEE\.metadata\.plugins\org.eclipse.wst.server.core\tmp0
    Jan 22, 2016 7:16:51 PM org.apache.catalina.startup.VersionLoggerListener log
    INFO: Command line argument: -Dcatalina.home=C:\Program Files\Apache Tomcat\apache-tomcat-7.0.67-windows-x64\apache-tomcat-7.0.67
    Jan 22, 2016 7:16:51 PM org.apache.catalina.startup.VersionLoggerListener log
    INFO: Command line argument: -Dwtp.deploy=C:\Programming Files\EclipseJEE\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps
    Jan 22, 2016 7:16:51 PM org.apache.catalina.startup.VersionLoggerListener log
    INFO: Command line argument: -Djava.endorsed.dirs=C:\Program Files\Apache Tomcat\apache-tomcat-7.0.67-windows-x64\apache-tomcat-7.0.67\endorsed
    Jan 22, 2016 7:16:51 PM org.apache.catalina.startup.VersionLoggerListener log
    INFO: Command line argument: -Dfile.encoding=Cp1252
    Jan 22, 2016 7:16:51 PM org.apache.catalina.core.AprLifecycleListener lifecycleEvent
    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\jdk1.8.0_71\bin;C:\windows\Sun\Java\bin;C:\windows\system32;C:\windows;C:/Program Files/Java/jre1.8.0_71/bin/server;C:/Program Files/Java/jre1.8.0_71/bin;C:/Program Files/Java/jre1.8.0_71/lib/amd64;C:\ProgramData\Oracle\Java\javapath;C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\MATLAB\R2014a\bin;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files\nodejs\;C:\Program Files (x86)\Skype\Phone\;C:\Users\s142966\AppData\Local\atom\bin;C:\Users\s142966\AppData\Roaming\npm;C:\Program Files\eclipse-jee-kepler-R-win32-x86_64;;.
    Jan 22, 2016 7:16:51 PM org.apache.coyote.AbstractProtocol init
    INFO: Initializing ProtocolHandler ["http-bio-8080"]
    Jan 22, 2016 7:16:51 PM org.apache.coyote.AbstractProtocol init
    INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
    Jan 22, 2016 7:16:51 PM org.apache.catalina.startup.Catalina load
    INFO: Initialization processed in 479 ms
    Jan 22, 2016 7:16:51 PM org.apache.catalina.core.StandardService startInternal
    INFO: Starting service Catalina
    Jan 22, 2016 7:16:51 PM org.apache.catalina.core.StandardEngine startInternal
    INFO: Starting Servlet Engine: Apache Tomcat/7.0.67
    Jan 22, 2016 7:16:51 PM org.apache.catalina.core.ContainerBase startInternal
    SEVERE: A child container failed during start
    java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/couchfriendslsrs]]
        at java.util.concurrent.FutureTask.report(FutureTask.java:122)
        at java.util.concurrent.FutureTask.get(FutureTask.java:192)
        at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1122)
        at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:819)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1574)
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1564)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
    Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/couchfriendslsrs]]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
        ... 6 more
    Caused by: java.lang.IllegalArgumentException: The servlets named [action_edit_profile] and [ro.lsrs.couchfriends.controllers.ActionEditProfile] are both mapped to the url-pattern [/action_edit_profile] which is not permitted
        at org.apache.catalina.deploy.WebXml.addServletMapping(WebXml.java:293)
        at org.apache.catalina.startup.ContextConfig.processAnnotationWebServlet(ContextConfig.java:2443)
        at org.apache.catalina.startup.ContextConfig.processAnnotationsStream(ContextConfig.java:2118)
        at org.apache.catalina.startup.ContextConfig.processAnnotationsFile(ContextConfig.java:2079)
        at org.apache.catalina.startup.ContextConfig.processAnnotationsFile(ContextConfig.java:2072)
        at org.apache.catalina.startup.ContextConfig.processAnnotationsFile(ContextConfig.java:2072)
        at org.apache.catalina.startup.ContextConfig.processAnnotationsFile(ContextConfig.java:2072)
        at org.apache.catalina.startup.ContextConfig.processAnnotationsFile(ContextConfig.java:2072)
        at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1304)
        at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:889)
        at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:386)
        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:5479)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
        ... 6 more

    Jan 22, 2016 7:16:51 PM org.apache.catalina.core.ContainerBase startInternal
    SEVERE: A child container failed during start
    java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost]]
        at java.util.concurrent.FutureTask.report(FutureTask.java:122)
        at java.util.concurrent.FutureTask.get(FutureTask.java:192)
        at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1122)
        at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:300)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
        at org.apache.catalina.core.StandardService.startInternal(StandardService.java:443)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
        at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:739)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
        at org.apache.catalina.startup.Catalina.start(Catalina.java:693)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:497)
        at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:294)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:428)
    Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost]]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1574)
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1564)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
    Caused by: org.apache.catalina.LifecycleException: A child container failed during start
        at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1130)
        at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:819)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
        ... 6 more

    Jan 22, 2016 7:16:51 PM org.apache.catalina.startup.Catalina start
    SEVERE: The required Server component failed to start so Tomcat is unable to start.
    org.apache.catalina.LifecycleException: Failed to start component [StandardServer[8005]]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
        at org.apache.catalina.startup.Catalina.start(Catalina.java:693)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:497)
        at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:294)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:428)
    Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardService[Catalina]]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
        at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:739)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
        ... 7 more
    Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina]]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
        at org.apache.catalina.core.StandardService.startInternal(StandardService.java:443)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
        ... 9 more
    Caused by: org.apache.catalina.LifecycleException: A child container failed during start
        at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1130)
        at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:300)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
        ... 11 more

    Jan 22, 2016 7:16:51 PM org.apache.coyote.AbstractProtocol pause
    INFO: Pausing ProtocolHandler ["http-bio-8080"]
    Jan 22, 2016 7:16:51 PM org.apache.coyote.AbstractProtocol pause
    INFO: Pausing ProtocolHandler ["ajp-bio-8009"]
    Jan 22, 2016 7:16:51 PM org.apache.catalina.core.StandardService stopInternal
    INFO: Stopping service Catalina
    Jan 22, 2016 7:16:51 PM org.apache.coyote.AbstractProtocol destroy
    INFO: Destroying ProtocolHandler ["http-bio-8080"]
    Jan 22, 2016 7:16:51 PM org.apache.coyote.AbstractProtocol destroy
    INFO: Destroying ProtocolHandler ["ajp-bio-8009"]

信息:

  • jdk1.8.0_71 上运行项目和服务器。
  • C:\ PathToWorkspace.metadata.plugins \ org.eclipse.wst.server.core \ tmp0 \ wtpwebapps显示项目名称。
  • 关于url错误:The servlets named [action_edit_profile] and [ro.lsrs.couchfriends.controllers.ActionEditProfile] are both mapped to the url-pattern [/action_edit_profile] which is not permitted,因此设置了web.xml文件(错误地给出了servlet的示例):

    <servlet>
        <servlet-name>action_edit_profile</servlet-name>
        <servlet-class>ro.lsrs.couchfriends.controllers.ActionEditProfile</servlet-class>
    </servlet>
    
    <servlet-mapping>
       <servlet-name>action_edit_profile</servlet-name>
       <url-pattern>/action_edit_profile</url-pattern>
    </servlet-mapping>
    

    编辑:关于this问题的可能重复,这不是同一个问题。我的问题是url冲突(映射是在xml和java类中设置的)。相反,this问题帮助我解决了问题。

2 个答案:

答案 0 :(得分:0)

java.lang.ClassNotFoundException: HttpServletRequest

试试这个。

tomcat是否在未部署应用程序的情况下启动?

答案 1 :(得分:0)

实际上,正如评论中所提到的,问题在于servlet被映射到相同的url模式中。我必须在web.xml中注释多个<servlet-mapping>块,以便运行服务器。

此问题也得到了回答here,其中answerer解释了web.xml和java类中的映射都会导致此错误。