-
1. Re: @Inject @Any does not work with @Stateless beans anymore
nickarls May 31, 2016 3:58 AM (in response to caarlos0)Where does @com.foo.reportgenerator.ReportGeneratorQualifier(value=ITEM_SALE_PER_CUSTOMER) come from as it looks like it's included in the match(?)
-
2. Re: @Inject @Any does not work with @Stateless beans anymore
caarlos0 May 31, 2016 8:48 AM (in response to nickarls)Yeah, it happens for all impls apparently.
Anyways, the impl is like this:
@Stateless
@ReportGeneratorQualifier(ITEM_SALE_PER_CUSTOMER)
public class ItemSalePerCustomerReportGenerator extends AbstractReportGenerator {
@EJB
protected SaleItemsReportService saleItemsReportService;
@EJB
protected NotaFiscalItemsReportService notaFiscalItemsReportService;
-
3. Re: @Inject @Any does not work with @Stateless beans anymore
nickarls May 31, 2016 9:03 AM (in response to caarlos0)Lets assume the interface and factory is OK. Take out all the implementations. Do a simple POJO
public class PojoReportGenerator implements ReportGenerator {
...
}
Does the injection see one implementation?
Add a
public class PojoReportGenerator2 implements ReportGenerator {
...
}
Does the injection see two implementations?
Make both implementations @Stateless
Still two implementations? Then add qualifiers etc. Also, make sure you use correct javax. imports for annotations and qualifiers etc.
-
4. Re: @Inject @Any does not work with @Stateless beans anymore
caarlos0 May 31, 2016 9:18 AM (in response to nickarls)I think the problem may be with the .ear deployment.
tree -L 1
.
├── META-INF
├── foo-business.jar
├── foo-public.war
├── foo-presentation.war
└── lib
The foo-business.jar has the classes cited, and the foo-presentation.war has a @Resource that injects the ReportGeneratorFactory.
The application.xml looks like:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE application PUBLIC
"-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN"
"http://java.sun.com/dtd/application_1_3.dtd">
<application>
<display-name>foo</display-name>
<module>
<web>
<web-uri>foo-public.war</web-uri>
<context-root>/pub</context-root>
</web>
</module>
<module>
<web>
<web-uri>foo-presentation.war</web-uri>
<context-root>/</context-root>
</web>
</module>
<module>
<ejb>foo-business.jar</ejb>
</module>
</application>
beans.xml are all empty.
jboss-ejb-client.xml is:
<?xml version="1.0"?>
<jboss-ejb-client xmlns="urn:jboss:ejb-client:1.0">
<client-context>
<ejb-receivers local-receiver-pass-by-value="false"/>
</client-context>
</jboss-ejb-client>
Maybe something has changed in the ear deployment in wildfly 9?