ClassCastException -- Can't find the error
i've searched through the forums regarding this error, and i can't pinpoint why i'm getting this error.
i'm using a <jsp:useBean> tag with scope=application to declare a database connection pool. when the webserver starts, everything works fine for about 5 min, then i get the following error:
java.lang.ClassCastException: DBConnectionPool
at _0002faccount_0005flogIn_0002ejspaccount_0005flogIn_jsp_0._jspService(_0002faccount_0005flogIn_0002ejspaccount_0005flogIn_jsp_0.java:68)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jasper.servlet.JspServlet$JspCountedServlet.service(JspServlet.java:130)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:282)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:429)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:500)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:405)
at org.apache.tomcat.core.Handler.service(Handler.java:287)
at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:797)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)
at org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:213)
at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:501)
at java.lang.Thread.run(Thread.java:484)
is my DBConnectionPool timing out? i KNOW the pool is working, since i'm able to access data in the DB for about 5 min. I could really use some help here. thanks everyone.
[2053 byte] By [
wireframe] at [2007-9-26 2:38:52]

thanks for the replies. here's the code in my login page:
<!-- Connection Pool to User Database -->
<jsp:useBean id="connPoolUser" scope="page" class="DBConnectionPool" >
<jsp:setProperty name="connPoolUser" property="driver" value="interbase.interclient.Driver" />
<jsp:setProperty name="connPoolUser" property="url" value="jdbc:oracle:thin:@ip:host" />
<jsp:setProperty name="connPoolUser" property="username" value="user" />
<jsp:setProperty name="connPoolUser" property="password" value="user" />
</jsp:useBean>
<!-- Connection Pool to Product Database -->
<jsp:useBean id="connPoolProduct" scope="page" class="DBConnectionPool" >
<jsp:setProperty name="connPoolProduct" property="driver" value="interbase.interclient.Driver" />
<jsp:setProperty name="connPoolProduct" property="url" value="jdbc:oracle:thin:@ip:host" />
<jsp:setProperty name="connPoolProduct" property="username" value="user" />
<jsp:setProperty name="connPoolProduct" property="password" value="user" />
</jsp:useBean>
<jsp:useBean id="user" scope="session" class="User">
</jsp:useBean>
does it matter that i'm trying to declare 2 instances of the connection Pool? also, inside my pages that use the connection pool, i do the following:
<jsp:useBean id="objConn" scope="page" class="DBConnection"></jsp:useBean>
if (objConn.getConnection( connPoolProduct ) )
{
perform my operations here
}
sometimes, i also get an error:
variable connPoolProduct undefined.
wierd since it's an application variable. any suggestions?
why are you doing
<jsp:useBean id="connPoolUser" scope="page" class="DBConnectionPool" >
</jsp:useBean>
I thought the syntax is:
<jsp:useBean id="connPoolUser" scope="page" class="DBConnectionPool" />
Anyways, have you re-compiled the pool object after starting the server? That sometimes would give an error like that. Prolly not but just had to ask :)
also, are you using tomcat? If so, check which line is giving the error. Sometimes it helps. The code generated for you jsp page is in the "work" dir in your tomcat dir, and the file it is in shows in the stacktrace along with the line number where the error is at. In this case it would be line 68 in a file named
_0002faccount_0005flogIn_0002ejspaccount_0005flogIn_jsp_0._jspService(_0002faccount_0005flogIn_0002ejspaccount_0005flogIn_jsp_0.java
-t
teka at 2007-6-29 10:10:25 >

you can use the </jsp:useBean> tag if you want to set variables when the object is created. if you do setParameter inbetween the <jsp:useBean> tag and the </jsp:useBean> tag, the values will ONLY be set when the object is first created. if you do setParameter outside of the <jsp:useBean> - </jsp:useBean> tags, the variables will be set each time the page is hit. since these are application variables, i only wanted to declare and set the variables once throughout the life of the object.
thanks for the advice about the tomcat directory. i'll look into it, and see if i can find anything in there. so far, it seems like the variable is just loosing it's scope, because i'm getting hit "sometimes" with a "variable Undefined" error. so, i've got to try and track down why that's happening.