<struts-newbie-warning/>

Hi folks,

I have been having some problems developing multiple similar applications with regards 
to classloaders.

I'm using Tomcat 4.1.18, and struts 1.1b3 (b2 was the same).

What I have discovered is that everything is fine if I package all of the struts Jars 
in each of my applications, but that there are problems if I put the struts jars in 
the tomcat $CATALINA_HOME/shared/lib.

I have two (actually multiple) applications (app1 and app2) that are extremely similar 
and happen to define Form classes which have the same class name (say "FormA").  These 
form classes are used as fields of a DynaActionForm.  

When the struts jars are shared I get classloader issues with symptoms such as:
"Object of type FormA cannot be assigned to variable of type FormA"

Now if I'm following correctly, this is because the first application that tomcat 
discovers is initialised and it's struts-config is read.  The dyna-form is created in 
the parent (shared) class loader, and is using the class definition for FormA as found 
by the child classloader for app1.  Afterwards, app1 can be used successfully.  As 
tomcat continues the initialisation, it reads the config for app2 and attempts to init 
a dyna-form, but finds it already has one so uses that (?).  When I attempt to use 
app2 I get the above error because although the two FormA classes are byte for byte 
identical, they were loaded by different child classloaders.

Is there any way around this problem, other than by including all of the struts jars 
in each of my applications?  What are the minimum jars I could get away with?

Packaged without struts each of my little apps is around 120KB.
Packaged with struts each of my little apps is around 1.5MB.

I know disk space is cheap these days, but I was trying to keep things as lightweight 
as possible for each new application we add to the server.

(thankfully I seem to be able to share my 4MB jacorb corba library rather than 
packaging that with each web-app!)

Is there a way to share the struts libraries so that what I am trying to do will work?

Thanks,

        Kev

---
Dr. Kevin Palfreyman  
Apama (UK) Ltd,  Cambridge, UK

Reply via email to