English 中文(简体)
两名EJB Beans——只有一名获得一名注射器的人
原标题:two nested EJB Beans - only the first get an entiy manager injected

I ve a stateful and a singelton EJBBean.

The stateful bean uses the entity manager (injected) and calls the singelton bean. The singelton bean uses the entity manager (injected).

If i try to call the singelton bean from the stateful bean, the singelton bean doesn t get an entity manager injected.

Is it not possible to get an entity manager in both beans at the same time?

EJB Bean

@Singleton
@LocalBean
public class AllocationPlanController implements AllocationPlanControllerRemote {

@PersistenceContext
private EntityManager em;

EJB Bean 2

@Stateful
@LocalBean
public class AllocationController implements AllocationControllerRemote {

@PersistenceContext
private EntityManager em;

private Allocation allocation;
private AllocationPlan allocationPlan;

AllocationPlanController allocationPlanController = new AllocationPlanController();
最佳回答

。 由于你是创建<代码>的“manually”的代号:AlpositionPlanController的例。 您应将<代码>AlpositionPlanController注入 bean,让该集装箱管理其生命周期。

问题回答

不要通过其建筑商创建新的分配方案管理员,而是试图将其理解为:

@EJB
AllocationPlanController allocationPlanController;

然后,该集装箱将把该信标注入,而且由于该集装箱将注入其制造的灯塔,该集装箱本已注入其灭pen剂,因此你将发现em的非核值。





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签