users@glassfish.java.net

Re: Specification question related to overriding annotations

From: <glassfish_at_javadesktop.org>
Date: Wed, 19 Mar 2008 07:24:52 PST

Hi, Ken; I spoke too soon.

I fully understand what you're conveying here, but unfortunately it doesn't work.

The scenario:

Abstract class called foo.bar.AbstractStatelessSessionBean has a @PersistenceContext-annotated entityManager field with no attributes (no name, no unitName). Packaged in its own jar. In an .ear setting, goes in the lib directory.

Concrete EJB (biz.baw.FrobnicatorBean) that extends AbstractStatelessSessionBean. Has an ejb-jar.xml. I put in the persistence context ref name as foo.bar.AbstractStatelessSessionBean/entityManager, per your suggestion. Then I put in the persistence unit name of "Fred", just to get started.

When I verify the ear, the verifier says that it can't find a persistence unit with name [null]. If I deliberately add a "unitName" attribute to the @PersistenceContext annotation with the value xyz, then the verifier tells me it can't find a persistence unit with the name [xyz]. This proves that the verifier obviously does find the @PersistenceContext annotation.

Next, I tried changing the @PersistenceContext annotation to @PersistenceContext(name="InjectedContext"), and updating the ejb-jar.xml to have its persistence-context-ref-name to also be "InjectedContext". That didn't work either. In this very odd case, the verifier tells me, once again, that it can't find a persistence unit named [null].

Anyhow, I proceeded through several other permutations and was unable to get any of them to work.

Now, to be fair, I haven't deployed the ear; I've just been verifying it with the verifier. Do you know if this is a bug in the verifier, or am I still missing something?

Thanks,
Laird
[Message sent by forum member 'ljnelson' (ljnelson)]

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