Error deploying simple servlet
andy00 Jul 12, 2009 10:31 AMHi 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