users@glassfish.java.net

Re: Specification question related to overriding annotations (issue 4457)

From: <glassfish_at_javadesktop.org>
Date: Wed, 23 Apr 2008 14:39:30 PDT

As long as I'm talking to myself I figure I might as well use this forum to store the results I found....

Could the issue be a race condition--perhaps one that is permitted or sanctioned by the specification?

There appears to be no guarantee that the code that takes an ejb-jar.xml's <persistence-context-ref-name> and binds it into JNDI actually will finish before injection occurs.

If I remove injection--but leave the persistence context ref name elements exactly as they were before--and do a SessionContext#lookup() call instead, everything works fine. Any attempt to use XML injection of an EntityManager fails, and fails in different ways on repeated startup. So sometimes the deployer reports that it couldn't find one particular persistence context, and other times it reports that it couldn't find another one.

So to make this work--but to permit customization of the persistence [i]unit[/i] injected into each session bean that I'm using, I've had to dispense with dependency injection altogether, because I cannot get it to work in the presence of more than one persistence unit.

I hope this helps the Glassfish team get to the root of issue 4457.

Thanks,
Laird

Now perhaps this is only XML-based--I don't know. But bypassing injection entirely
[Message sent by forum member 'ljnelson' (ljnelson)]

http://forums.java.net/jive/thread.jspa?messageID=270835