DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://nagoya.apache.org/bugzilla/show_bug.cgi?id=24994>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=24994 Special circumstances which struts fails to return the same class in the war file giving a class cast exception Summary: Special circumstances which struts fails to return the same class in the war file giving a class cast exception Product: Struts Version: 1.1 Final Platform: Other OS/Version: Other Status: NEW Severity: Normal Priority: Other Component: Web Site AssignedTo: [EMAIL PROTECTED] ReportedBy: [EMAIL PROTECTED] Context 1 contains beta of testApp which has this form defined <form name="joe" type="ca.one.two"> </form> Context 2 contains Omega of testApp which has enhancements to this form defined <form name="joe" type="ca.one.two"> </form> Context 1 and context 2 have been compiled at different times so they will have different compiled versions of ca.one.two class When user 1 goes into context 1 the following actions are performed The request processor is retrieved the processors processActionForm is called The RequestUtils.createActionForm is called If the form does not exist and it is a DynaActionForm the DynaActionFormClass.createDynaActionFormClass In this method the static dynaClasses hashmap is checked for an instance of the object keyed by name of the form and the module configuration name If this cannot be found a new instance of DynaActionFormClass is created and configured with the form. This class is stored in the hasmap under the key. A new instance of the form is created by calling DynaActionFormClass.newInstance() - this method performs the following actions This calles the RequestUtils.applicationClass(). This loads the class using Thread.currentThread().getContextClassLoader() This then creates a new instance of the class loaded by performing a class.newInstance(); Now user 2 goes into context 2 the following actions are performed The request processor is retrieved the processors processActionForm is called The RequestUtils.createActionForm is called If the form does not exist and it is a DynaActionForm the DynaActionFormClass.createDynaActionFormClass In this method the static dynaClasses hashmap is checked for an instance of the object keyed by name of the form and the module configuration name. ** Since user 1 already created a dynclass of this type a new instance is NOT created. A new instance of the form is created by calling DynaActionFormClass.newInstance() - this method performs the following actions ** Since user 1 already loaded the form class it is NOT reloaded. This then creates a new instance of the class loaded by performing a class.newInstance(); A new instance of the form is returned to the user The next step in the process then hits the executeAction method of the servlet. This attempts to cast the new form (created by context 1's class) to a class created by context 2's class. This results in a class cast exception because the 2 classes are not compatable with eachother. Note ==== If Omega is restarted and user 2 access the form before user 1 then the reverse occurs. This is due to us calling DynaActionFormClass.clear() in the initialization of the servlet. Solution ======== It be nice if DynaActionFormClass was context relative --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]