A container can never inject anything into an unmanaged object.
In order to be able to enter into an object, the container must control the life cycle of the object or at least participate in the management of its life cycle, so that it can receive the object at an early stage, to make an injection, if the object is created and used without any impact on container (as I suppose, the Struts beans action), then nothing will ever be inserted into the container in it. The container is not magical - it cannot just detect objects created in the whole JVM and do something with them.
Mikko's answer has a good list of types of objects that will be used for injection. If the actions of beans are not one of those that don't have bone, I'm afraid.
Now, having said all this, there is light at the end of the tunnel: it is entirely possible to write an extension for Struts that handles the injection. @EJB and @Resource injections quite closely match specific JNDI searches; the extension can reflectively search for annotated fields, and then execute the corresponding JNDI queries and enter the results. CDI injection is even easier because it has an API specifically designed to write extensions. For an example of all this, take a look at the Stripes injection enricher , which adds support for @EJB, @Resource, and @Inject to the Stripes web framework.
source share