I have an multi-module maven project with three projects. First ejb project with shared data test-base
. A second ejb project test-timer
which should be deployed on a glassfish 4.x application server to run periodic tasks (@Scheduel
) and depend on test-base
. And finally a third war project test-webapp
with simple webapp which also depend on test-base
and is also going to be separately deployed to glassfish 4.x application server.
In the test-base
project is a CDI bean. The poject contains beans.xml.
test-webapp
works like a charm. But if I try to deploy test-timer
I get a deployment exception.
org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for type [MyCdiBean] with qualifiers [@Default] at injection point [[BackedAnnotatedField] @Inject private org.test.MyTimer.bean]
After searching the net (i. e. here or here), I thought it has something to do with the beans.xml
. test-base
contains a beans.xml
and webapp is running just fine. As with test-timer
it makes no difference whether I have a beans.xml
or not.
beans.xml
is generated by netbeans ide and looks like the following.
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
</beans>
I also tried to change the bean-discovery-mode="all"
both in test-base
and test-timer
but nothing changed.
Here is my project structure.
test-parent
|--test-base
|--src
|--main
|--java
|--org/test/MyCdiBean.java
|--resources
|--META-INF
|--beans.xml
|--test
|--pom.xml
|--test-timer
|--src
|--main
|--java
|--org/test/MyTimer.java
|--resources
|--META-INF
|--beans.xml
|--test
|--pom.xml
|--test-webapp
|--src
|--main
|--java
|--org/test/WebAppBean.java
|--resources
|--META-INF
|--beans.xml
|--webapp
|--WEB-INF
|--web.xml
|--index.xhtml
|--test
|--pom.xml
|--pom.xml
Any hints on what I am doing wrong are appreciated.
I can attach source if necessary.
EDIT Additional information as requested in comment.
New beans.xml
is now.
<?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"
bean-discovery-mode="annotated">
</beans>
Still does not work.
I am using WELD Version WELD-000900 2.0.0 (SP1)
and also tested it with WELD-000900: 2.2.13 (Final)
MyCdiBean.java in test-base
@javax.inject.Named
@javax.enterprise.context.RequestScoped
//@javax.enterprise.context.Dependent /* also tried with */
public class MyCdiBean {
public void doSomething() {
System.out.println("Hello World!");
}
}