servletcontextlistener

ServletContextListener does not execute on deployment

你说的曾经没有我的故事 提交于 2021-01-27 13:48:55
问题 I am trying to initialize a streaming object when my war file is deployed. I wrote an Initializer class that implements ServletContextListener and added a listener-class tag to my web.xml. The issue is that the ContextInitialized Event occurs when I make the first request to my application and NOT when the app is deployed. Is there a better way to initialize my application? EDIT: public class Initializer implements ServletContextListener{ @Override public void contextDestroyed

Hook for my Vaadin web app starting and stopping?

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-27 04:35:37
问题 How do I know when my Vaadin 7 web app first starting/launching, so I can do some initial set-up work? Likewise, how do I know when my web app is ending, getting shutdown/exiting? 回答1: ServletContextListener Vaadin is built on top of Java Servlet technology. A “context” is the technical term for your web app in Servlet terms. So the answer here is not Vaadin-specific, it applies to any Servlet -- and at the end of the day, Vaadin is just one big Servlet. Since Servlet spec version 2.3, a

Hook for my Vaadin web app starting and stopping?

让人想犯罪 __ 提交于 2020-01-27 04:33:25
问题 How do I know when my Vaadin 7 web app first starting/launching, so I can do some initial set-up work? Likewise, how do I know when my web app is ending, getting shutdown/exiting? 回答1: ServletContextListener Vaadin is built on top of Java Servlet technology. A “context” is the technical term for your web app in Servlet terms. So the answer here is not Vaadin-specific, it applies to any Servlet -- and at the end of the day, Vaadin is just one big Servlet. Since Servlet spec version 2.3, a

Objectify and TimerTask: No API environment is registered for this thread

不羁的心 提交于 2019-12-19 08:06:09
问题 I'm trying to get a TimerTask set up to remove entries from Google App Engine's dataStore periodically. So I set up a ServletContextListener with a Timer . Inside the contextInitialized , I have registered my Objectify classes: ObjectifyService.register(Person.class); However, when the task actually runs, it complains that no API environment has been set up: Exception in thread "Timer-0" java.lang.NullPointerException: No API environment is registered for this thread. at com.google.appengine

Objectify and TimerTask: No API environment is registered for this thread

与世无争的帅哥 提交于 2019-12-19 08:05:09
问题 I'm trying to get a TimerTask set up to remove entries from Google App Engine's dataStore periodically. So I set up a ServletContextListener with a Timer . Inside the contextInitialized , I have registered my Objectify classes: ObjectifyService.register(Person.class); However, when the task actually runs, it complains that no API environment has been set up: Exception in thread "Timer-0" java.lang.NullPointerException: No API environment is registered for this thread. at com.google.appengine

How to start a thread after specified time delay in java

只谈情不闲聊 提交于 2019-12-17 22:46:04
问题 I have called a method in ServletContextListener as thread ..Now as per my need i have to delay the thread for 1 minutes and then start executing the method called in the thread but i am not able to do that as i am very new in this... Here is my code ... public class Startup implements ServletContextListener { @Override public void contextDestroyed(ServletContextEvent sce) { } public void contextInitialized(ServletContextEvent sce) { // Do your startup work here System.out.println("Started...

How to register ServletContextListener in spring boot

Deadly 提交于 2019-12-17 19:18:58
问题 Hello I'm trying to rewrite my old code to use Spring Boot. I have one listener public class ExecutorListener implements ServletContextListener . How can I register this listener for Spring Boot? I've tried: @SpringBootApplication @ComponentScan public class Application extends SpringBootServletInitializer { @Override public void onStartup(ServletContext servletContext) throws ServletException { super.onStartup(servletContext); servletContext.addListener(new ExecutorListener()); } } But the