Stateless Session Bean


EJB design: Stateless Session Bean

  1. Stateless Session Bean (9 messages)

    Can a stateless session bean have 2 create() methods, one with a parameter and another without a parameter ?

    Threaded Messages (9)

  2. Stateless Session Bean[ Go to top ]

    Hi Vino,
       Why not u write a simple stateless bean and find out for urself?. Once done, kindly let me know whether it is possible to have more than one create method in a stateless session bean. I also need this info.

    (ahamed at aztec dot soft dot net)

  3. Stateless Session Bean[ Go to top ]

    hi priya,

    yes a statless session bean can have 2 create methods one with a paramater and one without one. in fact any EJB (Session or entity) can have as many number of create (which we call factory methods) methods. u can map them to ur constructors of ur pure java vanilla classes.

    hope this helps, lemme know


  4. Stateless Session Bean[ Go to top ]

    Hi Kapil,
       I tried with 2 create methods for a stateless session bean under weblogic. The jar file is NOT getting generated. 'weblogic.ejbc' is giving the error, "stateless session bean must have 1 create method without any parameters". Why not u try with ur app.server and come-up with a concrete answer.

    (ahamed at aztec dot soft dot net)
  5. Stateless Session Bean[ Go to top ]

    From the EJB 1.1 spec
    Section 6.8 Stateless session beans
    (page 67)
    paragraph 3:

    The home interface of a stateless session bean must have one create method that takes no arguments and returns the session bean's remote interface. The can be no other create methods in the home interface. The session bean class must define a single ejbCreate method that takes no arguments.
  6. Stateless Session Bean[ Go to top ]

    Hi kapil ,Stateless session bean can have only one create method with no arguments,i tried with weblogic and also with websphere it's giving the same message saying that it should not have create method with any arguments.
    I agree with Hasan in this issue.
  7. Stateless Session Bean[ Go to top ]

     EJB1.1 spec. says the home interface of a SLSB can have only the parameterless create() method. and it cannot have any create methods with parameters.

     I think its very logical for SLSB. The reason is,

    1. The container calls ejbCreate() on the bean when it creates a new instance of an SLSB.
    2. It is not necessary that every create() call from a client would create a corresponding instance by the container.
    3. Thus, a create() call by the client need not reflect as an ejbCreate() on the bean. (pls refer to page no. 68, section 6.8.1 under fig.12. for confirmation.).

     If u have agreed on this point, (that client's create()in SLSB doesn't necessarily lead to an ejbCreate() on the bean), its very logical that an SLSB should not have create() method with parameters.

     wud like to listen all ur comments about this.

    Also i understand that, the container may choose to create new instances of the bean depending upon the number of instances already available, number of clients accessing, and the maximum number of beans in the pool. A container can use any algorithm for implementing this.

    [email protected]
  8. Stateless Session Bean[ Go to top ]

    well thanks guys ............. i think u were right on this

    but Manohar, bout ur comments on whether ejbCreate() on the bean instance will be called everytime or not. i dont agree with u on this. well it has to be called everytime i.e ejbCreate will be called. since bean instance r pooled. the container will use pooled instance for one of those calls. but yes u r right no new bean wud be instantiated if theres one available in the pool.
  9. Stateless Session Bean[ Go to top ]

    No it may not. Pls review section 6 of the EJB 1.1 spec. A stateless session bean may only contain a null create() operation. You can not have a create() method with parameters.

    Dave Wolf
    Internet Applications Division

  10. Stateless Session Bean[ Go to top ]

    Stateless session bean are not involved in conversation.So a stateless session bean can only have one create method without parameters.