[wildfly-dev] BeanManager usage in EAR deployments
Martin Kouba
mkouba at redhat.com
Thu Dec 3 08:55:41 EST 2015
Hi James,
first of all Weld follows the deployment structure and corresponding
visibility rules.
The CdiEarWithAllDependenciesTest works because EAR/lib directory is a
single module by default. And it seems WildFly treats this module as a
regular sub-deployment. So if ear-subdeployments-isolated is set to
false (default) all the sub-deployments can see other sub-deployments
within the EAR (of course except for WARs which have isolated
classloaders - Camel will not see beans from any WAR).
As for the CdiEarWithModularizedDependenciesTest - I'm no
WildFly/Modules expert but I would expect that resources from a module
will only see the module contents and its dependencies. So the test
failure makes sense to me - HelloBean from the ejb jar is not available
for injection in the camel module.
Also note that this is a gray area - the CDI spec does only work on the
application level and "external bean archives" are not supported.
Martin
Dne 3.12.2015 v 11:34 James Netherton napsal(a):
> Hi all,
>
> I'm using Apache Camel with its CDI component (which uses DeltaSpike). Can anyone help to clarify the behavior I see with the CDI BeanManager in the following deployment scenarios.
>
> If I deploy my Camel application as an EAR deployment with the camel dependencies contained in the EAR archive lib directory:
>
> - my-application.ear
> |--- lib
> |--- camel-cdi-2.16.1.jar
> |--- camel-core-2.16.1.jar
> |--- deltaspike-core-api-1.5.1.jar
> |--- deltaspike-core-impl-1.5.1.jar
> |--- my-module.jar
> |--- META-INF
> |--- beans.xml
> |--- com.myapplication
> |--- Bootstrap.class
> |--- HelloBean.class
>
> Camel is capable of resolving beans that I have annotated with @Named through this BeanManager used by the Camel CDI extension:
>
> Weld BeanManager for my-camel-cdi-app.ear.external.jar:file:/home/james/.m2/repository/org/apache/camel/camel-cdi/2.16.1/camel-cdi-2.16.1.jar!/META-INF/beans.xml [bean count=42]
>
> However, if I deploy an EAR with a JAR sub-deployment and modularize my Camel dependencies like this:
>
> - my-application.ear
> |--- my-module.jar
> |--- META-INF
> |--- beans.xml
> |--- com.myapplication
> |--- Bootstrap.class
> |--- HelloBean.class
>
>
> - module: org.apache.camel.cdi:main
> |-- camel-cdi-2.16.1.jar
> |-- camel-core-2.16.1.jar
> |-- deltaspike-core-api-1.5.1.jar
> |-- deltaspike-core-impl-1.5.1.jar
>
> The BeanManager assigned to the Camel CDI extension is no longer capable of resolving my @Named annotated beans (HelloBean.class). Is this the expected behavior in this deployment scenario? There's some test cases which may explain things better here:
>
> https://github.com/jamesnetherton/camel-cdi-ear-tests
>
> Any help to clarify would be appreciated.
>
> Cheers,
>
> James
>
> _______________________________________________
> wildfly-dev mailing list
> wildfly-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/wildfly-dev
>
--
Martin Kouba
Software Engineer
Red Hat, Czech Republic
More information about the wildfly-dev
mailing list