I have a singleton that I have to instantiate in my filter and for some reason I cannot get it’s instance on couple first attempts. (The application deployed in JBoss EAP 5.1) This same solution with no modification works just fine with Jetty Application server. Greatly appreciate for your answer in advance.
Sincerely,
Roman
If you don’t want to use any dependency injection framework ( Spring, Guice ), do it the old fashion way:
Install ServletContextListener
In
contextInitialized(ServletContextEvent sce)method create your singleton and store it as an attribute onServletContextWhen your filter will be initialized you should be able to get that singleton instance from the
ServletContextthat is passed inside theFilterConfiginterface in your filter’s init method