I added in pom.xml
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>8.0</version>
<scope>provided</scope>
</dependency>
And normally CDI should just be provided by this dependency.
I deploy my war on a Payara micro server.
But all the @Inject annotations are not working. All the objects are still null.
For example I have this class:
@ApplicationScoped
public class GreetingService {
public String getGreetingTemplate(String language) {
String result = "Hello %s";
switch (language) {
case "fr":
result = "Bonjour %s";
break;
case "de":
result = "Willkommen, %s";
break;
}
return result;
}
}
Then I do
@Stateless
public class MyClassImpl implements MyClass {
@Inject
private GreetingService greetingService;
:
Whatever I do greetingService always is null. I have beans.xml even I read since Java EE 7 it is no longer required. I even set it to bean-discovery-mode="all" .
It already gives me headache. I really have not a single clue.