HttpServlet cannot be resolved or is not a valid superclass
staudinger May 10, 2004 12:08 PMHello,
i created a .war file with a WEB-INF/web.xml file:
<?xml version="1.0" encoding="ISO-8859-1"?> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd"> <web-app> <servlet> <servlet-name>PlainServlet</servlet-name> <servlet-class>uls.PlainServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>PlainServlet</servlet-name> <url-pattern>/servlet/*</url-pattern> </servlet-mapping> </web-app>
Now, when i want to access my servlet i get the following error:
exception javax.servlet.ServletException: Error instantiating servlet class uls.PlainServlet at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:912) at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:668) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:210) ...
and somewhat lower:
root cause java.lang.Error: Unresolved compilation problems: HttpServlet cannot be resolved or is not a valid superclass HttpServletRequest cannot be resolved (or is not a valid type) for the argument request of the method doGet HttpServletResponse cannot be resolved (or is not a valid type) for the argument response of the method doGet at uls.PlainServlet.(PlainServlet.java:17) ...
Why can't jboss find the servlet.jar? I am using the default configuration, isn't tomcat in the path by default? Should i put my servlet.jar somewhere?
Thanks in advance,
Ulrich
Here is the code for my servlet:
/* * Created on May 9, 2004 * * To change the template for this generated file go to * Window - Preferences - Java - Code Generation - Code and Comments */ package uls; import javax.servlet.*; import javax.servlet.http.*; /** * @author us * * To change the template for this generated type comment go to * Window - Preferences - Java - Code Geneqration - Code and Comments */ public class PlainServlet extends HttpServlet{ public void doGet(HttpServletRequest request, HttpServletResponse response){ try{ java.io.PrintWriter out = response.getWriter(); out.println("<html><body>hello world.</body></html>"); } catch(Exception e){ e.printStackTrace(); } } }
Of course it compiles.