Question

I have a utility jar that has a logger producer, and I am working on another project using Arquillian for testing. In the project, I have a class with @Inject Logger logger. When I run tests with Arquillian, I got an error saying that org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for type Logger with qualifiers @Default at injection point. I have successfully used producer from current project to produce a logger bean before, but this is the first time I have tried to use a producer from another jar (or a dependency). So, I am wondering if producers have to be in the same project or they can be in other jars. Thank you in advance.

Was it helpful?

Solution

I think see the issue-- This is not wrong with Arquillian.

Explicit jar contain the beans.xml file, that can be an empty, either it contain no version number, or contain the version number 1.1 with the bean-discovery-mode attribute set to all. such as:

For JavaEE7

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee 
                           http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"
       version="1.1" bean-discovery-mode="all">

</beans>

CDI will not manage and inject those beans which are annotated with @Voted

Another one is implicit bean archive,that contains some beans annotated with a scope type, contains no beans.xml files or contains a beans.xml file with the bean-discovery-mode attribute set to annotated.

CDI can only manage and inject beans annotated with a scope type in an implicit archive.

Refer Java Tutorial

Packaging CDI Applications

Weld-Doc

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top