Lifecycle Module vs. glassfish.api.Startup

49 views
Skip to first unread message

njakob

unread,
Oct 25, 2019, 8:43:08 AM10/25/19
to Payara Forum
Hello everyone,

for our JavaEE application we have some code which needs to be executed during application (server) startup and during (/before) shutdown. At the moment we are maximally confused how to realize this with the Payara server. On a Weblogic server we implement an ApplicationLifecycleListener which runs in the application context.
On paper it sounds as if we should write a lifecycle module, however this seems to be executed in via a classloader which cannot "see" the .ear file and its content. Additionally the documentation states that lifecycle listeners are deprecated and that one should implement the org.glassfish.api.Startup instead. For that one we cannot find any documentation on the web whatsoever :-(

Can anybody help us out?

Best regards

Rudy De Busscher

unread,
Oct 31, 2019, 3:52:16 AM10/31/19
to Payara Forum
Hi,

I'm not sure I completely understand what you are trying to do.

You mention that you want to execute some code when the server starts up but it needs to be able to access the deployed EAR. So maybe you want to perform some action when the EAR is started (and not the server)?

Executing code during startup and shutdown of the application can be done through an Initializing Singleton bean within your application.

@Singleton
@Startup
public class AtStartupAndShutdown {

   @PostConstruct
   public void atStartup() {}

   @PreDestroy
   public void atShutdown() {}
}

Regards
Rudy
Reply all
Reply to author
Forward
0 new messages