我正在使用带有eclipse web工具的Tomcat 6来发布应用程序.当我部署j2ee应用程序时,我通过tomcat日志收到此错误:
Feb 18, 2010 9:50:33 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\jdk1.6.0_17\bin;.;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;c:\Program Files\Microsoft SQL Server\90\Tools\binn\;Pñ
Feb 18, 2010 9:50:33 PM org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
Feb 18, 2010 9:50:33 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 443 ms
Feb 18, 2010 9:50:33 PM org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
Feb 18, 2010 9:50:33 PM org.apache.catalina.core.StandardEngine start …Run Code Online (Sandbox Code Playgroud) 我正在尝试进入Java Web开发,但似乎遇到了Tomcat和一个非常简单的servlet的奇怪问题.每当我尝试加载应用程序时,catalina日志就会出现这种情况:
Caused by: java.lang.IllegalArgumentException: Servlet mapping specifies an unknown servlet name MyServlet
at org.apache.catalina.core.StandardContext.addServletMapping(StandardContext.java:2393)
at org.apache.catalina.core.StandardContext.addServletMapping(StandardContext.java:2373)
... 40 more
Mar 4, 2009 10:37:58 AM org.apache.catalina.startup.ContextConfig applicationWebConfig
SEVERE: Parse error in application web.xml file at jndi:/localhost/mywebapp/WEB-INF/web.xml
java.lang.IllegalArgumentException: Servlet mapping specifies an unknown servlet name MyServlet
Run Code Online (Sandbox Code Playgroud)
做得体面.它似乎找不到我的servlet.但是,servlet似乎在正确的位置.我可以在WEB-INF/classes/MyServlet.class中清楚地看到它
作为参考,这是我目前使用的web.xml文件:
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app 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_2_5.xsd" version="2.5">
<description>My first web app in Java.</description>
<display-name>My Web App</display-name>
<servlet>
<servlet-name>MyServlet</servlet-name>
<servlet-class>MyServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>MyServlet</servlet-name>
<url-pattern>/myservlet</url-pattern>
</servlet-mapping>
</web-app>
Run Code Online (Sandbox Code Playgroud)
正如你所看到的,我保持简单......但它不断抛出这个异常.一个简陋的Web应用程序在Java中是什么样的,我错过了哪些组件?
更新
为了绝对确定它不是某种神器,我启动了一个新的Tomcat副本并再次尝试.这样做后,这开始出现在日志文件中:
SEVERE: …Run Code Online (Sandbox Code Playgroud)