tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "braswell" <si...@berk.com>
Subject ClassCastException after ant build in getting object from ServletContext
Date Mon, 01 Apr 2002 21:26:49 GMT
Been working on a connection pool to make is to we do not need to bounce
tomcat all the time.  Initially we had it setup so tomcat would start and
stop the connection pool when the server started.  I have created an admin
servlet that starts and stops
the connection pool the same way starting and stopping tomcat did it...

been getting a lot of class cast exceptions with the following call:
dbPoolConnServlet obj =(dbPoolConnServlet)
context.getAttribute(dbPoolConnServlet.KEY);

i know for a fact that context.getAttribute(dbPoolConnServlet.KEY) returns a
dbPoolConnServlet object because i have the following line of code before i
do the cast ( i print out the object id and number)

ie
Object obja = context.getAttribute(dbPoolConnServlet.KEY);
System.out.println("obj " + obja);

produces:
obj dbPoolConnServlet@439a20

this indicates that obja is in-fact a dbPoolConnServlet and should cast
without a problem...

this is  a strange error since i have not changed any code in going from
tomcat starting the pool to this new servlet. I get this error after i do a
ant build.  IF i stop tomcat and restart --> then hit the servlet, there is
not
problem.
IF i then do an ant build --> then hit the servlet
 It only appears to be a problem if it has been loaded in memory
once.  After a build, i get this error everytime...

--error --

java.lang.ClassCastException: dbPoolConnServlet
        at tmplLogin.getConnectionPool_pcs(tmplLogin.java:392)




--
To unsubscribe:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands: <mailto:tomcat-user-help@jakarta.apache.org>
Troubles with the list: <mailto:tomcat-user-owner@jakarta.apache.org>


Mime
View raw message