users@glassfish.java.net

Re: Dependency Injection is not working

From: Noah White <emailnbw_at_gmail.com>
Date: Sun, 28 Feb 2010 20:02:47 -0500

You certainly should be able to inject a PersistenceContext/PU in
there. If that isn't working for you (NPE) a common problem can be
that either your persistence.XML file is packaged incorrectly or there
is a problem with the content for example invoking a provider class
which isn't in your applications classpath or miss configured
container resource like connection pool etc.

-Noah

On Feb 28, 2010, at 5:59 PM, glassfish_at_javadesktop.org wrote:

> Hi,
>
> I found no way to get Dependency Injection working in Glassfish v3.
> I have this little test-bean:
>
> @Stateless
> public class CalcSessionBean implements CalcSessionBeanRemote,
> CalcSessionBeanLocal {
>
> @Resource
> SessionContext sessctx;
>
> public Integer add(int a, int b) {
> System.out.println("ctx:" + sessctx);
> return a + b;
> }
> }
>
> But the injected Context is null. In another bigger Bean I also get
> no EntityManager or EntityManagerFactory injected (with
> @PersistentContext/_at_PersistenceUnit). The only one Injection that is
> working is @EJB to get References to other SessionBeans. Is this a
> problem in the Glassfish-Configuration?
>
> Which log-layer should be set finer to look at this problem? I tried
> to set all to FINEST, but this is giving far too many output to read.
>
> I hope someone can help me.
> Greets
> [Message sent by forum member 'homer86' (baltasar86_at_web.de)]
>
> http://forums.java.net/jive/thread.jspa?messageID=389255
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>