1 Reply Latest reply on Jul 15, 2005 4:19 PM by pabry

    Why doesn't @PersistenceContext work for me?

    pabry

      I use JBoss AS 4.0.3RC1 and I have two session beans with the following classes:

      @Local public interface MyManager
      @Stateless public class MyManagerBean implements MyManager
      @Remote public interface Tester
      @Stateless public class TesterBean implements Tester

      The first session bean just have one business method that returns a string.
      The second session bean also have one business method that calls the method on the first bean.

      My question is: In the Tester bean, why doesn't

      @PersistenceContext private static MyManager myManager;

      work for me? I get the following exception:
      Exception in thread "main" java.lang.RuntimeException: Failed in setting EntityManager on setter field: private static mytest.bean.MyManager mytest.bean.TesterBean.myManager

      However, the following construct works:
      private static MyManager myManager;
      static
      {
       try
       {
       InitialContext ctx = new InitialContext();
       myManager = (MyManager) ctx.lookup(MyManager.class.getName());
       }
       catch (NamingException e)
       {
       e.printStackTrace();
       }
      }



      Anybody knows?
      /Patrik