Reputation: 3748
I'm using Weblogic 12c, I need to run app before/with the web app starts. the app should fetch information and write it to db. I read that in previous versions of WL programmers used to work with ApplicationLifecycleListener, but it is deprecated now.
I'm compiling the project to ear file. I also tried to use ejb3.2 eager singleton, but it didn't worked.
Is there any working alternative?
Upvotes: 0
Views: 386
Reputation: 3748
I solved the issue by creating EJB as the following:
@Singleton
@Startup
public class StartupBean {
@PostConstruct
private void startup() { ... }
@PreDestroy
private void shutdown() { ... }
...
}
Creating the EJB Singleton instances is one of the Weblogic life cycle init calls, I put my java code under startup() method.
Upvotes: 0