We currently have a very weird problem with a web application running inside Open Liberty 18.0.0.4. We are injecting a Mongo database connection into a JAX-RS request handler. The producer for the injected value simply returns a member variable that can never get null once its initialized. The service runs fine for many hours, sometimes even days and then suddenly any access to the injected Mongo database throws a NPE. Here's a rough sketch of the code:
@ApplicationScoped
public class BackingServiceConnectionFactory {
private MongoDatabase m_mongoDatabase = ...;
@Produces
public MongoDatabase getMongoDatabase() {
return m_mongoDatabase;
}
}
@Path("repository")
public class RepositoryImpl {
@Inject
private MongoDatabase m_database;
@GET
public Response foo() {
MongoCollection<Document> workflows = m_database.getCollection("workflows"); // <== NPE
}
}
Once the injected variable is null all subsequent injections will also lead to null rendering the service unusable. Any idea what the problem could be or how to debug it?