4 Replies Latest reply on Apr 17, 2004 9:10 AM by calffin

    My first servlet can't run! Help me!

    calffin

      Hi,I am using jboss3.0.8_tomcat4.1.24 in the eclipse. I use lomboz to develop servlet. I just write a servlet to response to the invoke and write "hello world" in the browser .But I found that the lomboz can't generate the class file for the servlet in the web-info/classes directory(I don't know why,but no error informaiotn emerged) . When I typed the url:"http://localhost:8080/webmodule,the default string "welcome" can be seen in the browser.But if I typed the url:http://localhost:8080/webmodule/accountlet,the error information emerged:

      14:18:22,937 ERROR [Engine] ErrorDispatcherValve[localhost]: Exception Processing ErrorPage[errorCode=404, location=/error.jsp]
      java.net.SocketException: Connection reset by peer: socket write error
      at java.net.SocketOutputStream.socketWrite0(Native Method)
      at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
      at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
      at org.apache.coyote.http11.InternalOutputBuffer$OutputStreamOutputBuffer.doWrite(InternalOutputBuffer.java:668)
      at org.apache.coyote.http11.filters.ChunkedOutputFilter.doWrite(ChunkedOutputFilter.java:171)
      at org.apache.coyote.http11.InternalOutputBuffer.doWrite(InternalOutputBuffer.java:523)
      at org.apache.coyote.Response.doWrite(Response.java:524)
      at org.apache.coyote.tomcat4.OutputBuffer.realWriteBytes(OutputBuffer.java:384)
      at org.apache.tomcat.util.buf.ByteChunk.flushBuffer(ByteChunk.java:439)
      at org.apache.coyote.tomcat4.OutputBuffer.flush(OutputBuffer.java:345)
      at org.apache.coyote.tomcat4.CoyoteResponse.flushBuffer(CoyoteResponse.java:555)
      at org.apache.coyote.tomcat4.CoyoteResponseFacade.flushBuffer(CoyoteResponseFacade.java:227)
      at org.apache.catalina.valves.ErrorDispatcherValve.status(ErrorDispatcherValve.java:329)
      at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:181)
      at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
      at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
      at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:509)
      at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
      at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
      at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
      at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
      at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:594)
      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:392)
      at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:565)
      at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:619)
      at java.lang.Thread.run(Thread.java:534)


      Can anyone help me?
      Thank you very much.
      Best regards

        • 1. Re: My first servlet can't run! Help me!
          mannef

          Hi there,

          You seem to be using the wrong url to access the servlet, because jboss tries to redirect you to the error page. The error code 404 means "File not found".

          Check the servlet mappings in web.xml

          Good luck!

          Manne

          • 2. Re: My first servlet can't run! Help me!
            calffin

            Hi,ManneF,thank you for your help! I only had one servlet in my project . My web module is called"WebModule". My web.xml is below:


            <servlet-name>accountlet</servlet-name>
            <servlet-class>server.web.Accountlet</servlet-class>

            <servlet-mapping>
            <servlet-name>accountlet</servlet-name>
            <url-pattern>/*.account</url-pattern>
            </servlet-mapping>
            <welcome-file-list>
            <welcome-file>index.jsp</welcome-file>
            </welcome-file-list>
            <error-page>
            <error-code>404</error-code>
            /error.jsp
            </error-page>
            </web-app>


            So I use the url :http://localhost:8080/WebModule/accountlet to access my servlet. Is that anything wrong with the url or something else? What's more , what confused me is that there is no class file in the web-info diretory, what on earth happened?

            • 3. Re: My first servlet can't run! Help me!
              mannef

              You should use an url ending in .account (e.g: /WebModule/edit.account)to access the servlet.

              Your class file should be in WEB-INF/classes/server/web or somewhere else on the classpath; if not you'll not be able to find it.

              It may be a good idea to read up a bit on how servlets work before asking a lot of questions in these forums. Check out this page, for instance:

              http://www.apl.jhu.edu/~hall/java/Servlet-Tutorial/

              Regards,
              Manne

              • 4. Re: My first servlet can't run! Help me!
                calffin

                Hi ,Mannef, thank you for your help ! The url " /WebModule/*.account" didn't work at all. And as for as I know, the url"/WebModule/accountlet " should have the same function with the url"/WebModule/*.account". Is that right?
                I can get a WebModule.war file in %JBOSS_HOME%\server\all\deploy directory and I can get the class file in the directory designated by the lomboz for eclipse. My web.xml is below:

                <servlet-name>accountlet</servlet-name>
                <servlet-class>server.web.Accountlet</servlet-class>
                <servlet-mapping>
                <servlet-name>accountlet</servlet-name>
                <url-pattern>/*.account</url-pattern>
                </servlet-mapping>
                <welcome-file-list>
                <welcome-file>index.jsp</welcome-file>
                </welcome-file-list>
                <error-page>
                <error-code>404</error-code>
                /error.jsp
                </error-page>
                </web-app>


                when I start the jboss server in the eclipse. The jboss can automatically deploy the WebModule.war in the last few steps of the start proccess. after the server is invoked, I open the browser and type the url:"http://localhost:8080/WebModule", the default string "Welcome" can be seen and the url changed to "http://127.0.0.1:8080/WebModule/index.jsp". But If I type the url:"http://127.0.0.18080/WebModule/accountlet" or "http://127.0.0.1:8080/WebModule/edit.account" , the browser said it can't find the server.And the error information emerged on the eclipse console:
                ERROR [Engine] ErrorDispatcherValve[localhost]: Exception Processing ErrorPage[errorCode=404, location=/error.jsp]
                It seemed that the problem resides in the url. I viewed some posts in the forum .It seemed that the jboss-tomcat bundled package disable the configuration file of tomcat . So I don't know where I can edit to solve this problem.
                Please give me some sugesstion !Any idea would be highly appreciated.
                Thank you a lot!
                Best regards.