The code the EJB3 Reverse engineer generated triggered a bug in glass fish.
2. Now about the bug in the user’s test case:
This test case is using the PU name “cis” twice, viz: 1)in the EJBs where it is
injecting a PersistenceContext, 2)in EntityManagerHelper as shown below:
private static final EntityManagerFactory emf; ^M
static {
emf = Persistence.createEntityManagerFactory(“cis”);
}
This emf is never closed, and this is exactly the kind of application described
earlier in this comment. A look at the test source code reveals that emf is
never used, so it can be safely removed without affecting the functionality.
The fix they suggested is as follows
Your EJBs are using container managed persistence
context, so you don’t have to worry about opening and closing any em or emf. All
you need to do is to fix your EntityManagerHelper.class, which is calling
Persistence.createEMF(). Why do you need to create an emf again in this class?
You are only using the log() method of this class in your EJBs. The static
variable emf and threadLocal are not used anywhere. You can remove them and you
will not hit the bug.