users@glassfish.java.net

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

From: <glassfish_at_javadesktop.org>
Date: Wed, 23 Apr 2008 10:40:38 PDT

This gets weirder and weirder.

So now I've removed all references to @PersistenceContext; that is, my AbstractStateless session bean has a field declaration like this:[code]protected EntityManager entityManager;[/code]I attempt to inject an EntityManager into it using the XML syntax in the relevant ejb-jar.xml that refers to my concrete subclass (so now we're not talking about overriding, just about using XML for injection instead of annotations). That part of the ejb-jar.xml file looks like this:[code] <persistence-context-ref>
        <description>Persistence context for Factory.</description>
        <persistence-context-ref-name>foo.bar.AbstractStatelessSessionBean/entityManager</persistence-context-ref-name>
        <persistence-unit-name>SomeExistingPUName</persistence-unit-name>

        <injection-target>
          <injection-target-class>foo.bar.AbstractStatelessSessionBean</injection-target-class>
          <injection-target-name>entityManager</injection-target-name>
        </injection-target>
        
      </persistence-context-ref>[/code]Now, this "goes through" just fine--no warnings, no deployment problems, no problems of any kind that I can see.

But the first request that comes in to my concrete subclass shows that the (inherited) entityManager field is now null.

Shouldn't the system have told me if it couldn't inject an EntityManager properly?

I am now quite concerned--I'm kind of banking on being able to use XML injection to allow the persistence unit to be customized by end customers--could someone give me a rundown on the status of issue 4457?

(Of course it's JavaOne time so I suppose that's not likely to happen quickly... :-))

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

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