You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bu...@apache.org on 2002/08/17 01:02:42 UTC
DO NOT REPLY [Bug 11784] New: -
Failure in loading class with destroy method of Servlet
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=11784>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND
INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=11784
Failure in loading class with destroy method of Servlet
Summary: Failure in loading class with destroy method of Servlet
Product: Tomcat 4
Version: 4.0.4 Final
Platform: PC
OS/Version: Windows 9x
Status: NEW
Severity: Normal
Priority: Other
Component: Catalina
AssignedTo: tomcat-dev@jakarta.apache.org
ReportedBy: dibyendu@mazumdar.demon.co.uk
We are implementing Tomcat in our Production environment (on AIX 4.3.3), and
have been facing a problem. In our Servlet init() function, we load a class
dynamically using Class.forName(). The class being loaded resides in our WEB-
INF/classes directory. The init() method works fine. But when we load another
class in our destroy() method, we get a ClassNotFoundException. Both classes
reside in the same WEB-INF/classes directory.
This problem occurs only when the classes are in WEB-INF/classes directory. If
we put the classes in a JAR file and place the JAR file in WEB-INF/lib, the
problem goes away.
I managed to reproduce the problem on my PC (running on Windows 98) by creating
a small test servlet. The code for the servlet and the helper classes are given
below:
Try class:
----------
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class Try extends HttpServlet {
public void init() throws ServletException {
getServletContext().log("Try initialized");
try {
Class.forName("Test1");
}
catch(Exception e) {
getServletContext().log("Caught exception" + e);
}
}
public void destroy() {
getServletContext().log("Try destroyed");
try {
Class.forName("Test2");
}
catch(Exception e) {
getServletContext().log("Caught exception" + e);
}
}
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
response.setContentType("text/plain");
PrintWriter writer = response.getWriter();
writer.println("Hello World");
}
}
Test1 class:
------------
public class Test1 {
public void sayHello() {
System.out.println("In Test1");
}
}
Test2 class:
------------
public class Test2 {
public void sayHello() {
System.out.println("In Test2");
}
}
Output from log file:
---------------------
2002-08-16 23:39:09 StandardHost[localhost]: Installing web application at
context path /dm from URL file:C:\Program Files\Apache Tomcat 4.0\webapps\dm
2002-08-16 23:39:09 WebappLoader[/dm]: Deploying class repositories to work
directory C:\Program Files\Apache Tomcat 4.0\work\Standalone\localhost\dm
2002-08-16 23:39:09 StandardManager[/dm]: Seeding random number generator class
java.security.SecureRandom
2002-08-16 23:39:09 StandardManager[/dm]: Seeding of random number generator
has been completed
2002-08-16 23:39:09 ContextConfig[/dm]: Missing application web.xml, using
defaults only
2002-08-16 23:39:09 ContextConfig[/dm]: Added certificates -> request attribute
Valve
2002-08-16 23:39:09 StandardWrapper[/dm:default]: Loading container servlet
default
2002-08-16 23:39:09 default: init
2002-08-16 23:39:09 StandardWrapper[/dm:invoker]: Loading container servlet
invoker
2002-08-16 23:39:09 invoker: init
2002-08-16 23:39:09 jsp: init
2002-08-16 23:39:09 Internal Error: File /WEB-INF/web.xml not found
2002-08-16 23:39:18 org.apache.catalina.INVOKER.Try: init
2002-08-16 23:39:18 Try initialized
2002-08-16 23:39:45 StandardHost[localhost]: Removing web application at
context path /manager
2002-08-16 23:39:45 StandardHost[localhost]: Removing web application at
context path /dm
2002-08-16 23:39:45 Try destroyed
2002-08-16 23:39:45 Caught exceptionjava.lang.ClassNotFoundException: Test2
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>