Producer is not available in Arquillian process
ruddy32 Sep 21, 2015 11:45 AMHi,
The project is using Arquillian 1.1.9-Final with Arquiillian GF Embedded 3.1 plugin and GF Embedded 4.1 as a manage container.
While running a unit test with Arquillian using Glassfish embedded plugin, I get the following CDI error :
2015-09-18 06:25:24,376 DEBUG | main | org.jboss.weld.Reflection sept. 18, 2015 6:25:24 AM com.sun.enterprise.v3.server.ApplicationLifecycle deploy GRAVE: Exception during lifecycle processing org.glassfish.deployment.common.DeploymentException: CDI deployment failure:WELD-001408: Unsatisfied dependencies for type Set<Locale> with qualifiers @SupportedLocales at injection point [BackedAnnotatedParameter] Parameter 1 of [BackedAnnotatedConstructor] @Inject protected com.MyClass(@SupportedLocales Set<Locale>) at com.MyClass.<init>(MyClass.java:0)
Set<Locale> with qualifier @SupportedLocales is defined in a module deployed in the tested WebArchive. The Archive content is :
/WEB-INF/ /WEB-INF/lib/ /WEB-INF/lib/shiro-web-1.2.3.jar /WEB-INF/lib/ShiroCurrentLocaleInjectionTest.jar /WEB-INF/lib/commons-cdi-1.0.0-SNAPSHOT.jar /WEB-INF/lib/shiro-core-1.2.3.jar /WEB-INF/lib/deltaspike-core-api-1.5.0.jar /WEB-INF/lib/deltaspike-core-impl-1.5.0.jar /WEB-INF/beans.xml
This object is provided by a producer method located in <common-cdi> module. The same module provide CDI extension feature like ThreadScoped. This producer is not discovered by Weld during test startup and Weld does not discover beans from <commons-cdi> module. How is it possible? Can we provide CDI extension features and CDI bean in the same module ?
@SupportedLocales is declares in <commons-cdi> with:
@Qualifier @Target({ ElementType.TYPE, ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD }) @Retention(RetentionPolicy.RUNTIME) public @interface SupportedLocales { }
The producer is declared in <commons-cdi> with:
@Dependent public class I18NProducer { @Produces @Singleton @Default @SupportedLocales public Set<Locale> getSupportedLocales() { Set<Locale> supportedLocales; supportedLocales = new HashSet<Locale>(); supportedLocales.add(Locale.US); return supportedLocales; } }
Is there something wrong in declaration ?