• Post Reply Bookmark Topic Watch Topic
  • New Topic

Class.forName and ClassCastException

 
Josiel Oliveira
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, All.
I have the following piece of code in a servlet.
Object classObj=Class.forName(beanName).newInstance();
iErrorCode=((BeanModel)classObj).handleRequest(request);
Sometimes I got a ClassCastException after compiling the project.
I inspected the variables in the JB7 debugger and it�s ok. I tried the expression="classObj instanceof BeanModel" in the evaluate window and returns true. I can ever cast to the interface and call methods in the evaluate, but in the code I get a exception!
Somebody knows how can I locate this problem?
JBuilder 7, Tomcat 4.0.3(embedded), W2K SP2
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it possible that there are different versions of the class file floating around on your system, one seen by the JB7 and the other by Tomcat?
Bill
 
Josiel Oliveira
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmmm... maybe.
I�ll try separating the classes and the
pages of the application and cleaning
it up.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!