I am switching from a single to a multi-tenant database. I wanted to make use of the ‘@TenantId’ annotation in hibernate 6. In order to use hibernate 6 I needed to upgrade from java ee to jakarta ee. Which also required me to update Tomcat from 9 to 10.1.24. In addition I also upgraded from Java 8 to 21. Everything is working for me except for context dependency injection (CDI) which is RETURNING NULL to anything I’m trying to inject.
I am using a resource like so-
@Path("my-resource")
@ApplicationScoped
public class MyResource {
@Inject
private MyService myService;
@Path("")
@GET
@Produces(MediaType.APPLICATION_JSON)
public Response getList() {
try {
return Response.ok(myService.findAll(false)).build();
} catch (Exception e) {
return Response.serverError().entity("Error: This is where myService was null").build();
}
}
My service starts like so –
@ApplicationScoped
public class MyService implements Serializable { // followed by the function that never gets reached
Some things I’ve tried-
1.Added an empty beans xml with discovery mode all
2.Have tried both weld-servlet-shaded and openwebbeans pom dependencies
3.Have tried using an open webbeans listener inside the context xml
4.Have tried different types of annotations such as @RequestScoped or @ApplicationScoped
Looking for any suggestions or people who have updated their dev stack and might know of a few changes I missed.