I have an EAR file containing multiple ejb-jar and war. In an ejb-jar, I inject multiple implementations of an interface like this :
@Inject
@Any
private Instance<ConfigurationProviderLocal> providerEjb;
An implementation of this interface is defined in a war. This implementation deploys fine.
In the glassfish v3.1 log I see:
Infos: Portable JNDI names for EJB FormConfigurationProviderBean :
[java:global/com.dialog.edialog_eservices_ear_1.0.1-SNAPSHOT/checkout-form-1.0-SNAPSHOT
/FormConfigurationProviderBean,
java:global/com.dialog.edialog_eservices_ear_1.0.1-SNAPSHOT/checkout-form-1.0-SNAPSHOT
/FormConfigurationProviderBean!com.dialog.sbsm.talisker.core.config.api.ConfigurationProviderLocal]
But in the iteration of my implementations:
for (ConfigurationProviderLocal provider : providerEjb) {
[...]
}
The implementation FormConfigurationProviderBean is never iterated. I have no message in log that could explain this.
Also, when I deploy the war in stand alone (not inside ear, with dependencies embedded inside it), the injection work correctly.
Is CDI supported when implementation is defined inside a war? Is there a classloader issue?
This should work, provided that the setup is correct (which probably is the case).
I had a similar issue in the JBoss World (on AS 6) where different artifacts in an EAR could not see each other. I solved it by re-configuring the JBoss classloading-mechanism, but this was plain (and proprietary) JBoss stuff.
What I would do as a first debug step: Query the BeanManager about what beans are really around. This might give you a hint. A small CDI-extension which dumps the initial bean processing could be helpful as well.
If it still looks like a CL-issue you might find configuration options for that in the Glassfish documentations. Probably worthwhile to check with the GlassFish developers if that is a known problem / issue…