I assume that, strictly speaking, you want to instantiate an object as soon as your servlet is loaded by Tomcat. (In fact, it would not make sense to modify Tomcat for application-specific functions).
In this case, your Servlet class can override / implement the init(ServletConfig config) method init(ServletConfig config) . This is caused by the servlet container (Tomcat in this case) when the servlet is initialized, and this is exactly where you need to execute the static startup logic, such as the view you are talking about here.
In fact, the servlet won't even be able to receive connections until its init method returns, so you can guarantee that the ontology will be fully loaded before the sensor observations arrive.
source share