I have the similar problem. This happens when I use a servlet along
with a bunch of JSPs and the servlet pass some class objects to the JSP.
Whenever I make change and recompile the servlet, the
ClassCastException will occur. Keep restarting Tomcat is annoying. So
I figured out a way to make my development easier:
Now I don't use servlet. I use a special JSP instead of that servlet
and moved the code from the servlet to this JSP. I moved the code in
doGet() and doPost() from the servlet into the JSP's <% ... %> area.
And moved the "import" code to <%@ page import=...%> area. And moved
all the member data and functions in a <%!...%> area. Because a JSP is
actually a servlet. So basically I had no problem to get this work.
This way I don't get the exception and don't have to restart Tomcat any
more! If someday Tomcat fixes the problem and I want to go back to servlet
approach, I can switch back to servlet very easy. But in this
JSP, I only use servlet class methods and data and avoid using JSP's
local feature.
BTW, the developers in a team had better use their own Tomcat server to
minimize the chances of stepping on toes of each other. The source
code should be controlled with a source code controller which is
shared by all. A production (maybe plus a pre-production) server
should be separate from the team's servers.
Y.
On Wed, 18 Apr 2001 12:30:07 -0400, Gerry Scheetz <[EMAIL PROTECTED]>
wrote:
>After reading some messages in the archives, I think I have an idea of what
>is
going on and why I am getting a ClassCastException. What I am looking for
is
how others handle this problem in there organizations.
>
>A quick overview of my situation. I am attempting to code a MVC web
application. I have a class called MenuItem which has two properties, a
menu
title and an action to call when that menu item is selected. In my servlet
init
method I create an array of MenuItem objects and put that array in a HashMap
object, which contains multiple menus. I then have one JSP file that is
included in other JSP pages that takes 2 parameters, menu you want and
current
page. The JSP then generates the menu. All my java classes are put in a
JAR
file and placed in the <web-context>/WEB-INF/lib directory. the JSP files
are
in the <web-context> directory. If I recreate my JAR file and overwrite the
existing file, I get a ClassCastException when trying to cast the return
from
the HashMap get command to my MenuItem array. I understand that the problem
has
to do with a classloader and I can solve the problem by restarting Tomcat.
This
is fairly easy with WinNT and the remote Server Manager. !
NOTE: All development is on NT workstations and servers. Production is on
a
RS/6000.
>
>This is not a problem when there is one developer working on a web server,
>but
in the near future our organization will have multiple developers working on
various systems. (One to three developers per system.) I could see
potential
problems with restarting Tomcat time after time and from the archive that
seemed
to be the easiest solution. So . . .
>
>1) Is there something I can do different in my webapp code to avoid the
ClassCastException?
>
>2) In organizations where there are multiple developers, how do you
>organize
your code? Do you have a central repository where code is checked out and
brought down to each developers machine?
>
>3) In organizations where there are multiple developers, how do you
>organize
your webserver? Does everyone test on one web server or does everyone have
a
web server on their individual machine.
>
>4) In organizations where there are multiple developers, do you have any
>other
advice?
>
>TIA,
>
>
>Gerry Scheetz
>Web Application Development
>Global Information Technology Division
>TRW - S&ITG
>Helena, Montana, USA
>[EMAIL PROTECTED]
>(406) 594-1878
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets