开发者

tomcat 6 webapp deployment

I wrote a little servlet that I need to deploy with tomcat. My server is tomcat 6. I first tried just dragging the war file and it unpacked, put I can't access the url (404 error). Then I even deleted the deploy and tried using the tomcat manager. When I click deploy is says 'OK' but doesn't show up in the list of applications deployed.

I used Eclipse (ganymede) to create the war file. The unpacked directory structure looks good. I am running on localhost:8080. Here is my web.xml. Perhaps there is something wrong here?

<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">

    <servlet>
        <servlet-name>Auth</servlet-name>
        <servlet-class>serv.Authenticate</servlet-class>
      </servlet>
      <servlet-mapping>
        <servlet-name>Auth</servl开发者_Python百科et-name>
        <url-pattern>/authenticate</url-pattern>
      </servlet-mapping>
    </web-app>

I've read that maybe I need to do something to server.xml. But I looked around in there and there are no entries for any of tomcat's default web apps. How do I register my app so that tomcat serves it up like the others?


The web.xml look good but it is impossible to know why you are getting a 404 without knowing more about your environment.

The problem might be that the servlet is not loaded or if it is being loaded, that the servlet cannot find the URL.

To see if your servlet is being loaded add a log statement (System.out will do) to the init method of the servlet. Add the following line to your servlet element as well so that the servlet will not load on demand but at startup:

<load-on-startup>0</load-on-startup>

Then you can check that the servlet is being recognized and loaded.

Then add a log statement to the doGet/doPost etc methods to output the .getPathInfo of the request object. It might help to add a wildcard to the servlet mapping as well just to test:

<url-pattern>/authenticate/*</url-pattern>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜