tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Chirossel, Oliver" <OChiros...@siris.fr>
Subject RE: ClassCastException after ant build in getting object from Ser vletContext
Date Mon, 08 Apr 2002 08:02:48 GMT
I enountered the same problem,

First, i put a hack with the reflect API (class Method, method invoke).
In a second time , i found the problem : the  javax.servlet package used is
differerent when i compiled and when i run tomcat, so the signature of the
class is not the same and this explain the Cast problem.
Be sure that the jdbc2-ext.jar is take when you compile, normaly you are not
oblige to declare in your CLASSPATH the jar of the jdbc provider.


Olivier   

 




> -----Message d'origine-----
> De:	braswell [SMTP:simon@berk.com]
> Date:	lundi 1 avril 2002 23:27
> À:	tomcat-user@jakarta.apache.org
> Objet:	ClassCastException after ant build in getting object from
> ServletContext
> 
> 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
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message