×

Loading...
Ad by
  • 最优利率和cashback可以申请特批,好信用好收入offer更好。请点链接扫码加微信咨询,Scotiabank -- Nick Zhang 6478812600。
Ad by
  • 最优利率和cashback可以申请特批,好信用好收入offer更好。请点链接扫码加微信咨询,Scotiabank -- Nick Zhang 6478812600。

You need to turn on the "invoker" servlet in your <TOMCAT_HOME>/conf/web.xml

by default , the invoker servlet is be commented out , turn on it ,like this "
<servlet>
<servlet-name>invoker</servlet-name>
<servlet-class>
org.apache.catalina.servlets.InvokerServlet
</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>0</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>

<servlet-mapping>
<servlet-name>invoker</servlet-name>
<url-pattern>/servlet/*</url-pattern>
</servlet-mapping>"

then you can call your servlets in a browser ,like "http://localhost:8080/servelt/myServletClass"
Report

Replies, comments and Discussions:

  • 工作学习 / IT技术讨论 / 求助:Tomcat 4.1,我的servlet的程序编译好了却总也访问不到,无论放在WEB-INF或者classes目录下面,错误号码是404,程序肯定没问题,在学校的Tomcat上能访问
    • 检查一下,访问日志
      如题,检查一下,看LOG文件,一般都能定位问题。
      • 谢谢DX,这里是最后一次启动之后到关闭的log,看了半天还是比较蒙,我建了一个目录叫myWeb,不过无论那个.class文件放在ROOT的还是myWeb都不行,请帮忙看看我的Log,谢谢
        本文发表在 rolia.net 枫下论坛2005-01-26 18:46:41 HostConfig[localhost]: Deploying configuration descriptor admin.xml
        2005-01-26 18:46:43 HostConfig[localhost]: Deploying configuration descriptor manager.xml
        2005-01-26 18:46:43 WebappLoader[/manager]: Deploying class repositories to work directory C:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\manager
        2005-01-26 18:46:43 ContextConfig[/manager]: Configured an authenticator for method BASIC
        2005-01-26 18:46:43 StandardManager[/manager]: Seeding random number generator class java.security.SecureRandom
        2005-01-26 18:46:43 StandardManager[/manager]: Seeding of random number generator has been completed
        2005-01-26 18:46:43 StandardWrapper[/manager:default]: Loading container servlet default
        2005-01-26 18:46:43 StandardWrapper[/manager:invoker]: Loading container servlet invoker
        2005-01-26 18:46:43 HostConfig[localhost]: Deploying web application directory myWeb
        2005-01-26 18:46:43 StandardHost[localhost]: Installing web application at context path /myWeb from URL file:C:\Program Files\Apache Group\Tomcat 4.1\webapps\myWeb
        2005-01-26 18:46:43 WebappLoader[/myWeb]: Deploying class repositories to work directory C:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\myWeb
        2005-01-26 18:46:43 WebappLoader[/myWeb]: Deploy class files /WEB-INF/classes to C:\Program Files\Apache Group\Tomcat 4.1\webapps\myWeb\WEB-INF\classes
        2005-01-26 18:46:43 StandardManager[/myWeb]: Seeding random number generator class java.security.SecureRandom
        2005-01-26 18:46:43 StandardManager[/myWeb]: Seeding of random number generator has been completed
        2005-01-26 18:46:43 StandardWrapper[/myWeb:default]: Loading container servlet default
        2005-01-26 18:46:43 StandardWrapper[/myWeb:invoker]: Loading container servlet invoker
        2005-01-26 18:46:43 HostConfig[localhost]: Deploying web application directory ROOT
        2005-01-26 18:46:43 StandardHost[localhost]: Installing web application at context path from URL file:C:\Program Files\Apache Group\Tomcat 4.1\webapps\ROOT
        2005-01-26 18:46:44 WebappLoader[]: Deploying class repositories to work directory C:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\_
        2005-01-26 18:46:44 WebappLoader[]: Deploy class files /WEB-INF/classes to C:\Program Files\Apache Group\Tomcat 4.1\webapps\ROOT\WEB-INF\classes
        2005-01-26 18:46:44 StandardManager[]: Seeding random number generator class java.security.SecureRandom
        2005-01-26 18:46:44 StandardManager[]: Seeding of random number generator has been completed
        2005-01-26 18:46:44 StandardWrapper[:default]: Loading container servlet default
        2005-01-26 18:46:44 StandardWrapper[:invoker]: Loading container servlet invoker
        2005-01-26 18:46:44 HostConfig[localhost]: Deploying web application directory tomcat-docs
        2005-01-26 18:46:44 StandardHost[localhost]: Installing web application at context path /tomcat-docs from URL file:C:\Program Files\Apache Group\Tomcat 4.1\webapps\tomcat-docs
        2005-01-26 18:46:44 WebappLoader[/tomcat-docs]: Deploying class repositories to work directory C:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\tomcat-docs
        2005-01-26 18:46:44 StandardManager[/tomcat-docs]: Seeding random number generator class java.security.SecureRandom
        2005-01-26 18:46:44 StandardManager[/tomcat-docs]: Seeding of random number generator has been completed
        2005-01-26 18:46:44 StandardWrapper[/tomcat-docs:default]: Loading container servlet default
        2005-01-26 18:46:44 StandardWrapper[/tomcat-docs:invoker]: Loading container servlet invoker
        2005-01-26 18:46:44 HostConfig[localhost]: Deploying web application directory webdav
        2005-01-26 18:46:44 StandardHost[localhost]: Installing web application at context path /webdav from URL file:C:\Program Files\Apache Group\Tomcat 4.1\webapps\webdav
        2005-01-26 18:46:44 WebappLoader[/webdav]: Deploying class repositories to work directory C:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\webdav
        2005-01-26 18:46:44 StandardManager[/webdav]: Seeding random number generator class java.security.SecureRandom
        2005-01-26 18:46:44 StandardManager[/webdav]: Seeding of random number generator has been completed
        2005-01-26 18:46:44 StandardWrapper[/webdav:default]: Loading container servlet default
        2005-01-26 18:46:44 StandardWrapper[/webdav:invoker]: Loading container servlet invoker
        2005-01-26 18:58:55 StandardHost[localhost]: Removing web application at context path /admin
        2005-01-26 18:58:55 StandardHost[localhost]: Removing web application at context path /webdav
        2005-01-26 18:58:55 StandardHost[localhost]: Removing web application at context path /examples
        2005-01-26 18:58:55 StandardHost[localhost]: Removing web application at context path /tomcat-docs
        2005-01-26 18:58:55 StandardHost[localhost]: Removing web application at context path /myWeb
        2005-01-26 18:58:55 StandardHost[localhost]: Removing web application at context path
        2005-01-26 18:58:55 StandardHost[localhost]: Removing web application at context path /manager更多精彩文章及讨论,请光临枫下论坛 rolia.net
    • up
    • 进来
      1. 检查 ...Tomcat/webapps/myMeb/WEB-INF/web.xml,应该和下面的配置差不多:

      <servlet>
      <servlet-name>HelloWorldServlet</servlet-name>
      <servlet-class>com.x86.HelloWorldServlet</servlet-class>
      </servlet>

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

      2. 确保你的HelloWorldServlet.class放在 ...Tomcat/webapps/myWeb/WEB-INF/classes/com/x86/ 下

      3. 再试再报
      • 照做了,这回不同的message,
        browser显示错误500,javax.servlet.ServletException: Error allocating a servlet instance, root cause是java.lang.NoClassDefFoundError: com/x86/HelloWorldServlet (wrong name: HelloWorldServlet)
        • Then
          检查你的HelloWorldServlet.java第一行是不是这么写的:
          package com.x86;
          如果不是,加上后重新编译,生成新的class,再试。

          或者,按照你的package name更改你的<servlet-class>,使其吻合。然后把class文件放在相应的 ...Tomcat/webapps/myWeb/WEB-INF/classes/下。
          • 终于搞定了!!!严重感谢流水DX,哈哈哈哈哈
    • You need to turn on the "invoker" servlet in your <TOMCAT_HOME>/conf/web.xml
      by default , the invoker servlet is be commented out , turn on it ,like this "
      <servlet>
      <servlet-name>invoker</servlet-name>
      <servlet-class>
      org.apache.catalina.servlets.InvokerServlet
      </servlet-class>
      <init-param>
      <param-name>debug</param-name>
      <param-value>0</param-value>
      </init-param>
      <load-on-startup>2</load-on-startup>
      </servlet>

      <servlet-mapping>
      <servlet-name>invoker</servlet-name>
      <url-pattern>/servlet/*</url-pattern>
      </servlet-mapping>"

      then you can call your servlets in a browser ,like "http://localhost:8080/servelt/myServletClass"
      • 明白了,这个说明很专业,谢谢。
      • 这是个基本的修改啊。你连这个都没有做?
        昨天我也想到的可能是这个问题,但想想,你以前都调通过,应该不会。呵
        ,这老哥水平不错。现在还在做这个行业吗?唉,国内搞这个搞了很长时间,来这里,找一份类似的活,不容易。我对APACHE的东西,都很感兴趣,多多交流!