5 Replies Latest reply on Jul 16, 2009 8:02 AM by Ondrej Medek

    Error deploying simple servlet

    Andy Peer Newbie

      Hi all,
      I have just installed jboss 5.1.0.GA and set it as a server in eclipse (in which I also installed the jboss tools). I made a new web project and wrote a simple servlet, only to see if it is all ok, but the response of jboos when I called my servlet was an exception report:

      javax.servlet.ServletException: non-HTTP request or response
      javax.servlet.http.HttpServlet.service(HttpServlet.java:845)
      org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)


      The code of my servlet is:

      package coreservlets;
      
      import java.io.*;
      import javax.servlet.ServletException;
      import javax.servlet.http.HttpServletRequest;
      import javax.servlet.http.HttpServletResponse;
      
      
       public class MiaServlet extends javax.servlet.http.HttpServlet implements javax.servlet.Servlet {
       static final long serialVersionUID = 1L;
      
       protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
       PrintWriter out = response.getWriter();
       out.println("Hello");
       }
      
       protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
      
       }
      }
      



      The web.xml is:

      <?xml version="1.0" encoding="UTF-8"?>
      <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">
       <display-name>test</display-name>
       <welcome-file-list>
       <welcome-file>index.html</welcome-file>
       <welcome-file>index.htm</welcome-file>
       <welcome-file>index.jsp</welcome-file>
       <welcome-file>default.html</welcome-file>
       <welcome-file>default.htm</welcome-file>
       <welcome-file>default.jsp</welcome-file>
       </welcome-file-list>
       <servlet>
       <description></description>
       <display-name>MiaServlet</display-name>
       <servlet-name>MiaServlet</servlet-name>
       <servlet-class>coreservlets.MiaServlet</servlet-class>
       </servlet>
       <servlet-mapping>
       <servlet-name>MiaServlet</servlet-name>
       <url-pattern>/MiaServlet</url-pattern>
       </servlet-mapping>
      </web-app>
      



      What could be the problem?

      Another little question: in eclipse do I have to re-export the project as a war file and put it in deploy dir ALL THE TIME? Is there a faster method to test the web app?

      Thanks


        • 1. Re: Error deploying simple servlet
          Andy Peer Newbie

          I fixed my problem, I upgraded eclipse to 3.5 and JBoss Tools 3.1 and now it's all ok.

          It remains the issue of how to "hot run" the app without export every time a war.

          • 2. Re: Error deploying simple servlet
            Ondrej Medek Apprentice

            Hi,

            is you are using WPT plugin (and I guess you are) then a "hot run" should be working for you. Don't export your project. Just deploy it. If you do not see it in the list of the deployable stuff, then you have probably made just plain Java project. You have to make Java Web project.

            Whey you deploy your project directly, then hot run should work fine for JSPs, HTMLs, etc. You can double click on the JBoss server in the server view and set the "Publishing interval" to 0sec if you are impatient.

            But if you change some Java code, you have to redeploy the whole application. The redeploy is made via touching the web.xml file. There's a special button in Eclipse top tool bar for this - such a white hand with index finger pointing up, tooltip is "Touch descriptors". Or you can right click on the war node in Jboss server and chose "Full redeploy"

            Other possibility is to use JBoss Tools Archiver. Then you may have just plain Java project. Just pack your project by JBoss archiver and chose automatic archive update or update it manually by pressing one button.

            Cheers
            Andy

            • 3. Re: Error deploying simple servlet
              Andy Peer Newbie

              I use eclipse 3.5 Java EE edition (with wtp).
              The project I created was a "Dynamic web project", but I don't see any "Deploy" button. What do you mean exactly when you say "just deploy"?

              • 4. Re: Error deploying simple servlet
                Andy Peer Newbie

                I solved it :D
                In the server configuration overview, in the deployment section, it was selected "Use workspace metadata"; I selected insted "Use the JBoss deploy folder" and it works.

                But when I modify java code and click "Touch descriptor" nothing happens and changes are not effective.

                • 5. Re: Error deploying simple servlet
                  Ondrej Medek Apprentice

                  Set "Publishing interval" to 0 sec. Otherwise you may "Touch descriptor" before your changes are copied into the deploy dir.

                  One more gotcha is, that the "Touch descriptor" is for the selected project in the "Navigator or Packages or Project Explorer". So, you may have selected other project then the currently edited file belongs to.