2 Replies Latest reply on Jun 26, 2008 3:33 AM by Tomas Cerny

    Create New Instance of Session Bean via @In or by Component

    Tomas Cerny Novice

      In the documentation is noted that I cannot use new operator for creating a new instance for session bean.

      I am supposed to use either @In(create=true) or Component.getInstance("...",true);

      Well I had this:

      @Out(value = "reservationActionManager", required=false)
          private ReservationActionManager reservationActionManager  = new ReservationActionManager();

      to fix it I tried to use:

      @In(value = "reservationActionManager",create=true)



      but my transaction fails immediately so it did not instantiate it.

      So I tried this: 

      Object instance = Component.getInstance("reservationActionManager", true);

      But I get Object that I cannot re-type in (ReservationActionManager), well it is proxy, but for instantiated components I am receiving Object that I can re-type in their type.

      So I need an instance of reservationActionManager in the current session bean what is the right solution to this.
      It is not in examples or documentation.

      Could you provide me with an example where one session bean creates in its constructor another sessions bean?