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!阅读原文】。感谢您的支持!

您可能感兴趣的

浅析“远程对象调用” 作者介绍:韩伟,1999年大学实习期加入初创期的网易,成为第30号员工,8年间从程序员开始,历任项目经理、产品总监。2007年后创业4年,开发过视频直播社区,及多款页游产品。2011年后就职于腾讯游戏研发部公共技术中心架构规划组,专注...
重构系列(一) 一、背景 来公司四五个月了,一直接手会员的相关项目,其实我们知道,会员属于公共模块,由于公司项目都很老了,大部分都是ejb,但是ejb现在已经不可维护,之前的代码做了各种封装,着实沉重,基本属于没办法修改的状态,所以几年前就开始慢...
When is @TransactionAttribute &lpar... An EJB method named Aby calls another EJB method named Bob Bob is marked with @TransactionAttribute(...
Problem with EJB / JSF2.0 I'm currently practicing JSF and EJB, but right now I can't get the page to show the information requested, this have...
BEA-010213, Message-Driven EJB: MyProcessMDB’s tra... I encountered this error last week and it was quite a headache to find out what the source of the problem was. Shor...