Hi, The class itself and web.xml look fine (though we usually tell people to put servlet-name before url-pattern in the servlet-mapping element, for backwards compatibility and/or historical reasons). There's no reason it should work in a jar. Webapps/test/WEB-INF/lib is the right place to put that jar. What are tomcat:tomcat permissions? The permissions should be such that the server user can read the jar.
Yoav Shapira Millennium Research Informatics >-----Original Message----- >From: Michael Labhard [mailto:[EMAIL PROTECTED] >Sent: Thursday, May 27, 2004 12:39 PM >To: [EMAIL PROTECTED] >Subject: n00b cannot get jar files to work. > >How do I get jar files to work? > >Learning Tomcat I have a simple "HelloServlet" class. When compiled and >the >class file is inserted into the directory > > /opt/tomcat/webapps/test/WEB-INF/classes/example > >and the web.xml file given below is placed in > > /opt/tomcat/webapps/test/WEB-INF/ > >and tomcat is restarted then the url > >http://localhost:8080/test/hello > >page reads: > > Hello, world! > >But if the same class is placed in a jar file and this jar file is inserted >into any of the following directories and given permissions tomcat:tomcat > > /opt/tomcat/webapps/test/WEB-INF/lib > /opt/tomcat/common/lib > /opt/tomcat/shared/lib > >when tomcat is restarted and the same url is addressed first there is > > < Blank page > > >the second time the page is refreshed there is > > Status 500: > javax.servlet.ServletException: Wrapper cannot find servlet class > > example.HelloServlet or a class it depends on > >and the third and all subsequent times the page is refreshed there is > > Status 400: > Servlet hello is not available > >How do I get jar files to work? Thank you. > >-- Michael > >Appendix: > >web.xml file: > ><?xml version="1.0" encoding="ISO-8859-1"?> > ><web-app xmlns="http://java.sun.com/xml/ns/j2ee" > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee >http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" > version="2.4"> > <servlet> > <servlet-name>hello</servlet-name> > <servlet-class>example.HelloServlet</servlet-class> > </servlet> > > <servlet-mapping> > <url-pattern>/hello</url-pattern> > <servlet-name>hello</servlet-name> > </servlet-mapping> ></web-app> > > >HelloServlet.java: > >package example; > >import java.io.*; >import java.util.*; > >import javax.servlet.http.*; >import javax.servlet.*; > >public class HelloServlet extends HttpServlet { > public void doGet ( > HttpServletRequest req, > HttpServletResponse res > ) throws ServletException, IOException > { > res.setContentType("text/html"); > PrintWriter pw = res.getWriter(); > > pw.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 >Transitional//EN\">"); > pw.println(); > pw.println("<head>"); > pw.println("<meta http-equiv=\"Content-Type\" content=\"text/html; >charset=ISO-8859-1\">"); > pw.println(); > pw.println("<!-- The Servlet expression tags interpolate script >variables >into the HTML -->"); > pw.println(); > pw.println("<title>Hello, world!</title>"); > pw.println("</head>"); > pw.println(); > pw.println("<body bgcolor=white>"); > pw.println(); > pw.println("<h1>Hello, world!</h1>"); > pw.println(); > pw.println("</body>"); > pw.close(); > } > > public HelloServlet() {} >} > > >--------------------------------------------------------------------- >To unsubscribe, e-mail: [EMAIL PROTECTED] >For additional commands, e-mail: [EMAIL PROTECTED] This e-mail, including any attachments, is a confidential business communication, and may contain information that is confidential, proprietary and/or privileged. This e-mail is intended only for the individual(s) to whom it is addressed, and may not be saved, copied, printed, disclosed or used by anyone else. If you are not the(an) intended recipient, please immediately delete this e-mail from your computer system and notify the sender. Thank you. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
