users@jersey.java.net

RE: [Jersey] Injectable in Jersey

From: saturon <netbeans_at_vtxfree.ch>
Date: Wed, 24 Dec 2008 14:40:42 +0100

Hi Sam,

As you see, from my messages posted recently regarding Jersey and JPA I
also have serious issues getting JPA & Jersey to work.

I am relieved at least some seem to have similar problems and its not
really an issue in my particular configuration.

I would really appreciate if someone could elaborate on how to use JPA
and Jersey. Especially in a "standard" configuration with Glassfish
v2/prelude v3 and toplink-essentials/eclipselink.

Although I believe it is more related to Jersey than to the
configuration.

Any JPA experts out there? Paul?

Thanks a lot!


-----Original Message-----
From: Sam Pullara [mailto:sam_at_sampullara.com]
Sent: Mittwoch, 24. Dezember 2008 03:46
To: users_at_jersey.dev.java.net
Subject: [Jersey] Injectable in Jersey


Hi All,

I'm trying to use Injectable in Jersey 1.0.1 to pass in my JPA
EntityManager. Based on all the stuff that I have read I was lead to
believe that something like this would work:

     @Provider
     public static class EntityManagerProvider extends
PerRequestTypeInjectableProvider<Context, EntityManager> {

         public EntityManagerProvider() {
             super(EntityManager.class);
         }

         public Injectable<EntityManager>
getInjectable(ComponentContext ic, Context context) {
             return new Injectable<EntityManager>() {
                 public EntityManager getValue() {
                     return ems.get();
                 }
             };
         }
     }

When it starts up it does find it and register it:

INFO: Provider classes found:
   class com.sampullara.chatservice.web.JPAFilter$EntityManagerProvider

And even instantiates an instance of it. However, when my Resource
gets constructed:

     public Users(@Context EntityManager em) {
         this.em = em;
         entity = "User";
     }

It just passes in null and I never get a callback. What am I doing
wrong?

Thanks,
Sam



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
For additional commands, e-mail: users-help_at_jersey.dev.java.net