The boot pot is not called

综合编程 2018-01-08 阅读原文

I created a Java Web Application Project in NetBeans, and created a startup bean in it:

package malibu.util;

import javax.annotation.PostConstruct;
import javax.ejb.EJB;
import javax.ejb.Stateless;
import javax.ejb.LocalBean;

@Stateless
@LocalBean
@javax.ejb.Startup
public class Startup {
    @EJB
    private ProviderEJB providerEJB;

    @PostConstruct
    public void onStartup() {
        System.err.println("Initialization success.");
    }
}

But the code is not called after I deploy the application. What can cause this?

Try the following set of annotations:

@Singleton
@Startup
public class Startup {
    @EJB
    private ProviderEJB providerEJB;

    @PostConstruct
    public void onStartup() {
        System.err.println("Initialization success.");
    }
}

You will find more details here
and in this book
(chapter 2).

Hello, buddy!

责编内容by:Hello, buddy!阅读原文】。感谢您的支持!

您可能感兴趣的

AMIS Technology blog: Performance optimization for... This blog describes a way to optimize performance of a custom ACM/BPM API wor...
Enabling SAML-based SSO with Remote EJB through Pi... Lets suppose that you have a remote Enterprise JavaBeans (EJB) application wh...
EJB Annotations cheatsheet for JBoss AS or WildFly Details Published: 26 June 2017 There is a vast numb...
重构系列(一) 一、背景 来公司四五个月了,一直接手会员的相关项目,其实我们知道,会员属于公共模块,由于公司项目都很老了,大部分都是ejb,但是ejb现在已经不可维护...
Separate JSF and EJB applications How do I use a deployed EJB app from a separate JSF application? I'm attemptin...