Red Hat Bugzilla – Bug 1028062
Beans from a non-CDI module are loaded when adding the module as a dependency to a Weld deployment
Last modified: 2014-07-30 13:45:50 EDT
Description of problem:
Beans from a non-CDI module are loaded when adding the module as a dependency to a Weld deployment. However, WildFly behaves differently and does not allow this.
After discussing about this difference between EAP and WildFly at #wildfly-dev, the recommendation from Jozef Hartinger was to follow WildFly behavior which seems to be the right one.
Version-Release number of selected component (if applicable):
Just try to add a non-CDI module as a dependency to a Weld deployment, and use a bean from the module in a producer method, for example.
ModuleSpecification moduleSpec = deployment.getAttachment(Attachments.MODULE_SPECIFICATION);
ModuleLoader moduleLoader = deployment.getAttachment(Attachments.SERVICE_MODULE_LOADER);
ModuleDependency nonCDIModuleDependency = new ModuleDependency(moduleLoader, NON_CDI_MODULE_IDENTIFIER, false, true, true, false);
Steps to Reproduce:
Beans from a non-CDI module are loaded even if the META-INF/beans.xml is not present inside the module.
Beans should be recognized/loaded only if META-INF/beans.xml is present inside the module.
The following repository provides all the necessary code and integration tests to see this issue in action:
The failing test is test.org.picketlink.as.subsystem.idm.integration.IdentityConfigurationProducerTestCase.
The test above uses a @Producer for a bean located at the non-CDI module (without the META-INF/beans.xml). In this case it will pass.
There is also a WildFly branch with the same code and tests:
The same test fails when using this branch, which is the expected behavior.
Currently, the behaviour seems to be consistent (and IMHO correct) on both, EAP 6.3.0.ER10 and WildFly 8.1.0.Final.
I've tested the scenario in an independent test (not the PicketLink one) and it seems to work as would be expected:
- there's a WAR deployment with:
- a test bean with an injection point for X
- a producer for X
- MANIFEST.MF declaring a dependency on the static module
- there's a non-CDI static module in the server with:
- the class X
- (NO beans.xml here)
- the producer should be able to find the class X, due to the declared class-loading dependency in MANIFEST.MF
- the class X is produced and becomes a bean (is injectable into beans in the deployment), because the producer is in a bean archive and sees class X
The test confirms these expectations in current WF and EAP.
IIUC, these expectations are in contradiction with the expectations mentioned in the first comment.
(The situation is obviously different, when also the producer is in the non-CDI static module. It then should not and does not produce a bean X.)
Is this still an issue?
It is fine now. got the same results with latest versions.
Thanks, I'll close this then.