0 Replies Latest reply on Jun 19, 2014 4:33 PM by Igor Malinovskyy

    Troubles with lookup ejb bean inside other bean using session context.

    Igor Malinovskyy Newbie

      I manage succesefully to lookup remoteley beans using InvocationContext. I also manage succesefully to lookup bean using anotations. But when i tried to use sessionContext.lookup I have class cast exception. What I am doiing wrong?

      Code example:

       

      public class ZRepositoryBean implements ZRepository, ZLocalRepository {

       

        @PersistenceContext(unitName = "zert")

        private EntityManager manager;

      //works

        @Resource

        private SessionContext context;

      //works

        @EJB

        private ZLocalSecurityManager securityManager;

      //works

        @EJB

        private ZLocalQueryManager queryManager;

       

        private void invokeOtherBean() {

        Class cast exception

      ZOtherLocal other =

              (ZOtheeLocal)context.lookup("java:module/ZOtherLocalBean!"

            +ZOtherLocal.class.getName());

       

        //invokactio via ejb:// works good when i am not inside been or use it remotelly

      }