struts-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "gui (JIRA)" <>
Subject [jira] [Created] (WW-4215) CDI plugin does not allow constructor injection
Date Thu, 03 Oct 2013 08:20:41 GMT
gui created WW-4215:

             Summary: CDI plugin does not allow constructor injection
                 Key: WW-4215
             Project: Struts 2
          Issue Type: Bug
          Components: Plugin - CDI
    Affects Versions:
            Reporter: gui

I'm converting some actions from spring injection to CDI injection. 
The beans have a non empty constructor that can be used by CDI (constructor is annotated with
@Inject). I don't want to switch to field injection, since i like to use final fields for
dependencies that don't change. 

However, cdi-plugin insists on having a no-arg constructor: 

Caused by: Action class [com.mycompany.MyClass] does not have a public no-arg constructor
- action - file:/struts.xml:22:106
        at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.verifyAction(
        at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addAction(
        at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addPackage(
        at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadPackages(
        at org.apache.struts2.config.StrutsXmlConfigurationProvider.loadPackages(
        at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(
        at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(

After looking at the code, i created my own ObjectFactory that overrides the 'isNoArgConstructorRequired'

public class MyCdiObjectFactory extends CdiObjectFactory {

    public boolean isNoArgConstructorRequired() {
        return false;

Using this objectfactory, all works as expected. It would be good to have this in the standard

This message was sent by Atlassian JIRA

View raw message