Uploaded image for project: 'Struts 1'
  1. Struts 1
  2. STR-1856

Special circumstances which struts fails to return the same class in the war file giving a class cast exception

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Incomplete
    • 1.1.0
    • None
    • Website
    • None
    • Operating System: other
      Platform: Other
    • 24994

    Description

      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

      Attachments

        Activity

          People

            Unassigned Unassigned
            notzippy@hotmail.com notzippy
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: