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

您可能感兴趣的

重构系列(一) 一、背景 来公司四五个月了,一直接手会员的相关项目,其实我们知道,会员属于公共模块,由于公司项目都很老了,大部分都是ejb,但是ejb现在已经不可维护,之前的代码做了各种封装,着实沉重,基本属于没办法修改的状态,所以几年前就开始慢...
SSL secured EJB with Elytron Details Published: 17 April 2018 Elytronsecurity framework enables developers to use an...
25th Airhacks Q&A: EJB future, Java EE 8, Asyn... 2 years of airhacks.tv . This Monday, 15.4, at 6 pm CET I will discuss the following topics : Ask questio...
AMIS Technology blog: Performance optimization for... This blog describes a way to optimize performance of a custom ACM/BPM API worklist client implementation. This is opt...
《Spring 5 官方文档》整合EJB 原文链接 25.1 介绍 作为一个轻量级的容器,Spring通常被认为是EJB的替代品。我们相信对域大多数就算不是最多的应用和用例来说,Spring作为一个容器结合其丰富的在事物,ORM和JDBC访问方面的支持...