I have two maven projects.
<?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"
>
<?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>
These are then packaged into a single ear.
In my ejb project, I have a class Banana
, and in the war project, I have a class Monkey
.
I then try to run this in WAS 8.5, so it'll use JEE 6
However, when I try to @Inject Banana cdiBanana
in the Monkey
class, it fails.
It gives the message
javax.enterprise.inject.UnsatisfiedResolutionException: Api type [org.food.Banana] is not found with the qualifiers
Qualifiers: [@javax.enterprise.inject.Default()]
When I make the Banana
a @Stateless
EJB, and give the Monkey
a @EJB Banana ejbBanana
it works.
Why wouldn't this work? And what should I do or try to make it work?
Maybe related to CDI: Why are there unsatisfied dependencies in the following setup? ?
For now, I'll close this question. It looks like the problem is the JEE6 spec.
Apparently, @Inject a bean from another Ejb-jar gives problems for the container. When you use @EJB it works fine.