Yeh that was just a dodgy hack to get around my initial errors when using javac. I found out later the reason why javac wasn't working on my servlet class was because servlet-api.jar wasn't on the classpath, after adding that I was able to compile it the normal way. Also the solution is NOT to put it in the WEB-INF folder, you need to have your .class file in the build/classes/<Yourpackage> folder.
Pid * wrote: > > On 10/06/2010 03:20, Vitalstatistix wrote: >> >> >> SOLVED: >> >> There was no HelloServlet.class file so I had to put an empty main method >> into the HelloServlet.java class and run it to generate the >> HelloServlet.class file, then I placed the class file in the WEB-INF >> folder >> and it all worked fine. > > Er, what? > > 1. There's no need for an empty main method. > 2. We usually just compile a .java file to get a .class > > > p > >> Vitalstatistix wrote: >>> >>> Hey, I've just been working on this tutorial here: >>> >>> http://www.ibm.com/developerworks/opensource/library/os-eclipse-tomcat/index.html >>> >>> It has been pretty good and I've got the jsp page to show the time but >>> when I try going to the >>> HelloServlet I get the error 500. >>> >>> http://www.ibm.com/developerworks/opensource/library/os-eclipse-tomcat/index.html >>> >>> Error Report >>> type Exception report >>> >>> message >>> >>> description The server encountered an internal error () that prevented >>> it >>> from fulfilling this request. >>> >>> exception >>> >>> javax.servlet.ServletException: Wrapper cannot find servlet class >>> com.example.servlets.HelloServlet or a class it depends on >>> >>> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) >>> >>> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298) >>> >>> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852) >>> >>> org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588) >>> org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) >>> java.lang.Thread.run(Unknown Source) >>> >>> >>> root cause >>> >>> java.lang.ClassNotFoundException: com.example.servlets.HelloServlet >>> >>> org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1516) >>> >>> org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1361) >>> >>> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) >>> >>> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298) >>> >>> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852) >>> >>> org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588) >>> org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) >>> java.lang.Thread.run(Unknown Source) >>> >>> >>> web.xml file generated in my Eclipse web project >>> >>> <?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>FirstWebProject</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>HelloServlet</display-name> >>> <servlet-name>HelloServlet</servlet-name> >>> <servlet-class>com.example.servlets.HelloServlet</servlet-class> >>> </servlet> >>> <servlet-mapping> >>> <servlet-name>HelloServlet</servlet-name> >>> <url-pattern>/HelloServlet</url-pattern> >>> </servlet-mapping> >>> </web-app> >>> >>> >>> Sorry I don't know how to add code tags in this forum. I'm using Tomcat >>> 6. >>> I've >>> made no changes to ANY web.xml files, I simply followed that short basic >>> tutorial step by step. My HelloServlet.java class is exactly the same as >>> in the tutorial and is in the same package. >>> Could you please tell me why it can't seem to find the class? >>> >>> Thanks heaps, >>> >>> :) >>> >>> >>> >>> >>> >>> >>> >>> >>> >>> >> > > > > > -- View this message in context: http://old.nabble.com/Tomcat-in-Eclipse-Error-500-java.lang.ClassNotFoundException-tp28830890p28851220.html Sent from the Tomcat - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org