Uploaded image for project: 'XWork'
  1. XWork
  2. XW-180

Validation XML file loading does not work with CGLIB proxy class

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.0.5
    • Validators
    • None

    Description

      The code used by the com.opensymphony.xwork.validator.ActionValidatorManager to load the validation.xml files relies on the class name value returned by the action class instance. However, when using xwork in combination with the Spring AOP framework I found that the CGLIB proxy mechanism appends a runtime generated extension to the class (e.g. $$EnhancerByCGLIB$$7fba325b). As a result the ActionValidatorManager is unable to locate the context specific validation xml files since it attempts to load the file using a name like MyActionClass$$EnhancerByCGLIB$$7fba325b-myactionalias-validation.xml rather than MyActionClass-myactionalias-validation.xml.

      What I found in debugging was that the default validation files like MyActionClass-validation.xml will still get loaded because the method 'private static List buildValidators(Class clazz, String context, boolean checkFile)' traverses the class hierarchy and apparently the CGLIB generated proxy is viewed as a subclass of the actual action class. Unfortunatley this does not work for the context specific validation files since they are generated based on calls to the method 'private static List buildAliasValidators(Class aClass, String context, boolean checkFile)' which attempts to load the xml filename based on the class name of the CGLIB proxy.

      I dont know if you want to view this as a bug or not, but since the combination of xwork and Spring (or some othe AOP framework) seems to be popular I think this issue will come up again.

      regards

      Attachments

        Activity

          People

            Unassigned Unassigned
            dmj666 Michael Jordan
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: