异常java.lang.ClassNotFoundException:Servlet-但是Servlet存在;而且web.xml是绝对正确的 [英] EXCEPTION java.lang.ClassNotFoundException: servlet - But the Servlet is present; And web.xml is absolutely correct

查看:416
本文介绍了异常java.lang.ClassNotFoundException:Servlet-但是Servlet存在;而且web.xml是绝对正确的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

只需使用Eclipse 6月4.2创建一个全新的项目
使用Google App Engine SDK 1.7.4

Just created a brand new project with Eclipse June 4.2 Use Google App Engine SDK 1.7.4

Eclipse创建Servlet

Eclipse create a Servlet

public class ClockServlet extends HttpServlet {
    public void doGet(HttpServletRequest req, HttpServletResponse resp)
            throws IOException {
        resp.setContentType("text/plain");
        resp.getWriter().println("Hello, world");
    }
}

和一个简单的web.xml

and a simple web.xml

    <servlet>
    <servlet-name>Clock</servlet-name>
    <servlet-class>clock.ClockServlet</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>Clock</servlet-name>
    <url-pattern>/clock</url-pattern>
</servlet-mapping>
<welcome-file-list>
    <welcome-file>index.html</welcome-file>
</welcome-file-list>

当我部署它时,我得到了通用的HTML错误页面:错误:服务器错误
并从日志中得到:

When i deploy it i get the generic HTML error page: Error: Server Error and from the logs i get:

    EXCEPTION java.lang.ClassNotFoundException: clock.ClockServlet
at com.google.appengine.runtime.Request.process-0925dcee3db2e16a(Request.java)

servlet存在并且web.xml是正确的
我在哪里错了?

But the servlet exists and the web.xml is correct Where am i wrong?

tnx

推荐答案

好吧,
似乎Servlet和Web.xml是正确的,但是缺少一个标记,这是使用Google App Engine所必需的。我想知道为什么没有在文档中使用下划线和大写字母。

Well, seems that Servlet and Web.xml were correct but there was missing a tag that is a must for using Google App Engine. I wonder why it is not underlined and written with capital letters inside documentation.

标记为< on-start-startup> 1< / load -on-startup>

请参阅 Java应用程序配置

每个自定义servlet必须在启动时加载,以让GA Engine实例化该类并接受要求。
这是用于在GAE中部署应用程序的最终web.xml。

Each custom servlet must be loaded on startup to let GA Engine instatiate the class and accept requests. Here is the final web.xml to use for deploying the application in GAE

    <servlet>
    <servlet-name>Clock</servlet-name>
    <servlet-class>clock.ClockServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>Clock</servlet-name>
    <url-pattern>/clock</url-pattern>
</servlet-mapping>
<welcome-file-list>
    <welcome-file>index.html</welcome-file>
</welcome-file-list>

这篇关于异常java.lang.ClassNotFoundException:Servlet-但是Servlet存在;而且web.xml是绝对正确的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆