1 Reply Latest reply on Jan 18, 2006 11:14 AM by acoliver

    PersistenceContext from XMBean or MBean

    acoliver

      I tried using service beans but they were too limiting for JBMS. We need users to be able to create multiple instances of some services and to change their dependency injection. However converting these to XMBeans is also problematic as right now this results in a null session. Is there any way to inject persistence context into a normal MBean or XMBean or POJO?

        • 1. Re: PersistenceContext from XMBean or MBean
          acoliver

          This dirty hack seems to work:

          try {
          InitialContext ctx = new InitialContext();
          session = ((EntityManager)ctx.lookup("java:/EntityManagers/mail"));
          System.out.println("*********************looked up session and it is "+session);
          } catch (Exception e) {
          e.printStackTrace();
          }

          however I can't then use it as a straight HibernateSession, I have to used it as a EntityManager... This is okay though.. I'll think about making this into an aspect for AOP...