4 Replies Latest reply on Oct 2, 2001 4:25 PM by Ignacio

    RH & Jetty give InstantiationException

    Ignacio Newbie

      Hi, Jboss 3.0 Alpha and Jetty working properly. On deploy everything works fine (that means that my web.xml file points to reachable classes), but when I try to execute a servlet I get an InstantiationException.

      It's quite a simple servlet (does almost nothing), though it's bundled with a fairly complex app (with security and Entity beans and so on). The beans are deployed ok and are callable from a client app. The servlet only says "Hello world" and doesn't reference any EJB nor is in any restricted area.

      Clues?

      =================

      [Jetty,WARN]
      java.lang.InstantiationException: com.canplastica.servlet.Catalogo
      at java.lang.Class.newInstance0(Native Method)
      at java.lang.Class.newInstance(Class.java:237)
      at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:439)
      at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:387)
      at org.mortbay.http.HandlerContext.handle(HandlerContext.java:1040)
      at org.mortbay.http.HandlerContext.handle(HandlerContext.java:995)
      at org.mortbay.http.HttpServer.service(HttpServer.java:683)
      at org.mortbay.http.HttpConnection.service(HttpConnection.java:732)
      at org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:889)
      at org.mortbay.http.HttpConnection.handle(HttpConnection.java:746)
      at org.mortbay.http.SocketListener.handleConnection(SocketListener.java:146)
      at org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:287)
      at org.mortbay.util.ThreadPool$PoolThreadRunnable.run(ThreadPool.java:609)
      at java.lang.Thread.run(Thread.java:484)

      [Jetty,WARN] Servlet Exception for /canplastica/catalogo
      javax.servlet.UnavailableException: Could not construct servlet

        • 1. Re: RH & Jetty give InstantiationException
          Jules Gosnell Novice

          what version of the JSDK did you compile it against ?

          Where is the Servlet class ?

          What other classes does it reference ?

          Where are they ?

          If the Servlet is so simple, could you post the source ?

          Have you tried deploying it in another web-container, e.g. jboss/tomcat to make sure that the problem is Jetty and not your webapp ?

          Jules

          • 2. Re: RH & Jetty give InstantiationException
            Ignacio Newbie

            JSDK 1.3.1, Win2k

            The servlet class used to reference other class (CanplasticaServlet) in the same package for inheritance. Trying to KISS it, I removed everything that could cause problems. They are commented.

            I'm going to try with Tomcat, but I'm not very hopeful on it. This servlet is copied from one that used to work in Tomcat (and is damn simple :).

            package com.canplastica.servlet;
            
            import com.canplastica.servlet.CanplasticaServlet;
            
            import javax.servlet.ServletException;
            import javax.servlet.http.HttpServlet;
            import javax.servlet.http.HttpServletRequest;
            import javax.servlet.http.HttpServletResponse;
            //import org.apache.log4j.Category;
            
            public abstract class Catalogo extends HttpServlet //CanplasticaServlet
            {
             public Catalogo() { System.out.println("Instantiated"); }
            
             protected void doGet(HttpServletRequest request, HttpServletResponse response)
             throws ServletException, java.io.IOException {
             processRequest(request, response);
             }
            
             protected void doPost(HttpServletRequest request, HttpServletResponse response)
             throws ServletException, java.io.IOException {
             processRequest(request, response);
             }
             protected void processRequest(HttpServletRequest request, HttpServletResponse response)
             throws ServletException, java.io.IOException
             {
             response.setContentType("text/html");
             java.io.PrintWriter out = response.getWriter();
             out.println("<html>");
             out.println("<head>");
             out.println("<title>Servlet catalogo</title>");
             out.println("</head>");
             out.println("<body>");
             out.println("Catalogo, etc");
             out.println("</body>");
             }
            
            }
            


            • 3. Re: RH & Jetty give InstantiationException
              Ignacio Newbie

              (I removed that mistype and still have the same error, InstantiationException *grin*)

              (Never, never code on drugs)

              • 4. Re: RH & Jetty give InstantiationException
                Ignacio Newbie

                But then not only restarted (two times) but also redeployed JBoss and everything worked fine (the class was at last reloaded).

                Issue solved. Bottom line: don't drink and code. Sorry for the inconvenience.

                (It's embarrasing, since I've coded 50+ servlets this far :)