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

can't autowire actions with no public no-arg constructor (fix suggestion)

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Critical
    • Resolution: Fixed
    • 1.1
    • 1.1.1
    • None
    • None
    • windows 2000, tomcat 5.5, webwork 2.2-beta-4
    • Patch

    Description

      I've been having trouble with the autowiring in Spring. I'm using the SpringObjectFactory, but when I try to use the autodetect strategy, I get:

      13:16:51,078 FATAL ActionMapperFactory:38 - Could not create ActionMapper: WebWork will not work!
      java.lang.IllegalArgumentException: Just constants AUTOWIRE_BY_NAME and AUTOWIRE_BY_TYPE allowed
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireBeanProperties(AbstractAutowireCapableBeanFactory.java:195)
      at com.opensymphony.xwork.spring.SpringObjectFactory.autoWireBean(SpringObjectFactory.java:151)
      at com.opensymphony.xwork.spring.SpringObjectFactory.buildBean(SpringObjectFactory.java:138)

      On the other hand, if I leave the autowire as AUTOWIRE_BY_TYPE or AUTOWIRE_BY_NAME, I get:

      13:18:11,812 ERROR XmlConfigurationProvider:201 - Action class [com.cw.portal.webwork.CommonAction] does not have a public no-arg constructor, skipping action [welcome]
      java.lang.NoSuchMethodException: com.cw.portal.webwork.CommonAction.<init>()
      at java.lang.Class.getConstructor0(Unknown Source)
      at java.lang.Class.getConstructor(Unknown Source)
      at com.opensymphony.xwork.config.providers.XmlConfigurationProvider.verifyAction(XmlConfigurationProvider.java:194)
      at com.opensymphony.xwork.config.providers.XmlConfigurationProvider.addAction(XmlConfigurationProvider.java:158)

      I noticed that the XmlConfiguratorProvider asks the object factory if it requires an empty constructor. In Revision 1.37, line 189:
      if (ObjectFactory.getObjectFactory().isNoArgConstructorRequired())

      Since the SpringObjectFactory doesn't overload the method, the response I get comes from the superclass, ObjectFactory. In Revision 1.15, line 66:

      public boolean isNoArgConstructorRequired() {
      return true;
      }

      Since the SpringObjectFactory already autowires by constructor all teh beans it creates, it should overload the method isNoArgConstructorRequired to answer "false" instead.

      This used to work when the spring integration code was on a separate jar.

      No patch because I don't have the resources to do it, sorry!

      Attachments

        Activity

          People

            rainerh Rainer Hermanns
            dukejeffrie Tiago Silveira
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: