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

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

    enda

      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)



      or


      @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?


      Thanks
                

        • 1. Re: Create New Instance of Session Bean via @In or by Component
          enda

          So I have figured out that I am supposed to have an interface there
          ReservationActionManager -> IReservationActionManager this seems to be more successful.


          but now I have an issue with redirects after this...


          I do not understand this part (from debugger):


          this component was already instantiated by seam


          "Component.getInstance("teamActionManager",true);"=TeamActionManager  (id=24770)     
          
          edu.baylor.icpc.session.team.TeamActionManager@1833123



          this by me inside the component teamActionManager


          "Component.getInstance(ReservationActionManager.class, true)"= Object_$$_javassist_32  (id=24817)       
          
          ReservationActionManager:3j001-8en841-fhwn9wbu-1-fhwnrbgp-2l
          
          




          I see this is a proxy, but why is not the first one too?

          • 2. Re: Create New Instance of Session Bean via @In or by Component
            enda

            Ok the interface was it.


            The navigation was deprecated start-state ;D