You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Paul Dumais <pd...@planetfred.com> on 2001/04/10 14:56:25 UTC

Tomcat 4 ClassLoader possible bug?

Hi Everyone,

I seam to have a discovered a problem in Tomcat 4.0 Beta 3 with the
ClassLoader.  Whenever I try to load a class using another thread other than
the servlet's request thread, the class is not found.  Here is an example
servlet which reproduces this problem.

If anyone has any ideas on why this is happening or knows of a possible fix
or workaround please let me know.

Thank you,

Paul Dumais
pdumais@planetfred.com



/**************************************************************************/
// servlet is registered with load-on-startup

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class LoadingBug extends HttpServlet {

    public void init() throws ServletException {

        //new DummyClass();  // uncomment this line and it finds the class

         Thread thread = new Thread() {
            public void run() {
                try {
                    System.out.println("waiting 10 seconds");
                    sleep(10000);
                    System.out.println("trying to load dummy class");

                    new DummyClass();  // class not found here
                }
                catch (Exception e) {
                    e.printStackTrace();
                }
            }
         };

         thread.start();

    }

    public void doGet(HttpServletRequest request, HttpServletResponse
response)
            throws ServletException, IOException {
    }

    public void doPost(HttpServletRequest request, HttpServletResponse
response)
            throws ServletException, IOException {
    }
}

class DummyClass {
}