In our project we did some Maven pom.xml cleanup and dependency injection stopped working. For example, this used to work but works no longer:
@Inject
private ItemService itemService;
public void whatever() {
itemService.whatever();
}
The itemService
is null when we run whatever()
, no error/warning message present in log. There's only one bean implementing the interface:
public interface ItemService { ... }
@ContainerManaged
@TransactionAttribute(TransactionAttributeType.REQUIRED)
public class ItemServiceBean implements ItemService { ... }
We tried putting all the dependencies back in the project where this error occurs, but that didn't help. I don't know where to start looking. Any of these would be helpful:
Include the following dependency in your pom.xml
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
</dependency>