A StackOverflow exception is usually caused by a recursive call in your code
that keeps calling itself and calling itself until it runs out of room.  In your
particular case, this seems to be happening at line 37 of the ConnectionPool
class.  Check the code there to see why it keeps calling itself instead of
returning an instance value.

Craig McClanahan



"Bragg, James" wrote:

> I have my ConnectionPool object stored into my ServletContext; however, I
> get an ClassCastException:
>
>       pool = (ConnectionPool)getServletContext().getAttribute("pool");
>
> Then, I tried writing ConnectionPool object to use an instance of itself
> instead of the object itself; however, now I get an exception in my
> StartupServlet loading my ConnectionPool instance
>
> (ConnectionPool object)
> ...
>   protected static ConnectionPool instance;
>
>   private ConnectionPool ( )
>                 throws SQLException, ClassNotFoundException {
>
>       // Load the specified driver class
>       Class.forName( ... );
>       connections = new Hashtable ();
>
>       // Put our pool of Connections in the Hashtable
>       // The FALSE value indicates they are unused.
>
>       for (int i = 0; i < initialConnections; i++) {
>          connections.put (DriverManager.getConnection(dbURL, user,
> password), Boolean.FALSE);
>
>       }
>    }
>
>    public static ConnectionPool getinstance() {
>       if (instance == null){
>               instance =  ConnectionPool.getinstance();
>       }
>       return instance;
>     }
> ...
>
> (StartupServlet init )
> ...
>         public void init (ServletConfig config) throws ServletException {
>
>              super.init(config);
>              context = config.getServletContext();
>
>              try {
>                 // Load the JDBC driver and register it
>                 pool = ConnectionPool.getinstance ();
>              }
>
>              catch(Exception e) {
>                 throw new UnavailableException (this, "Could not create
> connection pool");
>              }
>         }
> ...
>
> So now I'm getting:
>
> [03/Jul/2000:15:02:59] failure (  190): Internal error: unexpected exception
> thrown from the servlet init function (servlet class=StartupServlet):
> java.lang.StackOverflowError, Stack: java.lang.StackOverflowError
>         at java.io.PrintStream.println(PrintStream.java:551)
>         at ConnectionPool.getinstance(ConnectionPool.java:36)
>         at ConnectionPool.getinstance(ConnectionPool.java:37)
>         .... (about 60+ more of the above line..)
>         at ConnectionPool.getinstance(ConnectionPool.java:37)
>         at ConnectionPoo[03/Jul/2000:15:02:59] warning (  190): Internal
> error: Failed to load servlet (servlet=StartupServlet)
>
> Any ideas or suggestion would be greatly appreciated.
>
> -------------------------------------------------------------------------
> James C. Bragg
> Senior Software Consultant
> Computer Associates International Inc
>
> ___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to