EJB: Using EntityManager in PostConstruct method

后端 未结 2 2131
孤独总比滥情好
孤独总比滥情好 2021-02-04 16:50

After constructing the bean, I want to retrieve data from the database, using the EntityManager. It is not possible in the constructor, because the EntityManager is injected aft

2条回答
  •  花落未央
    2021-02-04 17:08

    Based on your requirement please try the following

    • Remove @Stateful [CAN'T use both at a time]

    • @Startup will initialize singleton bean during APPLICATION INIT [Please note the application was NOT fully initialized]. This might caused some issue in loading EntityManager and i assume the EntityManager bridge was not completely initialized. Try to call the init after complete application startup [i.e.,] Remove @Startup

提交回复
热议问题