Re: AW: Synchronizing ejb method

"Kalra, Ashwani" <[email protected]> Fri, 19 May 2006 16:40:49 +0530
Newsgroups gmane.comp.java.sun.ejb.general
Message-ID <1B0CECCD25CA24499E03717EF3D503F10273CC2C@BOMEX001.corp.capgemini.com>
You are right, Some containers follow specs strictly=2E When I was working=
 with Oracle9i AS, it used to throw exception=2E

Due to scenario I have , I have come to conclusion that I need to do=
 something at database side=2E=20
I don't want to synchronize any state=2E The ejb method generates some=
 report in pdf and sends it by email=2E=20
This action can be triggered by web-client or the  batch process which runs=
 frequently=2E I don't want to generate this report twice(when both=
 executing at the same time) and send a duplicate=2E=20

Regds
Ashwani


-----Original Message-----
From: A mailing list for Enterprise JavaBeans development=
 [mailto:EJB-INTEREST@JAVA=2ESUN=2ECOM] On Behalf Of Andreas Berg
Sent: Friday, May 19, 2006 4:31 PM
To: EJB-INTEREST@JAVA=2ESUN=2ECOM
Subject: AW: AW: Synchronizing ejb method

If you quote the spec you should read it very very carefully=2E "The=
 container may throw=2E=2E=2E" is  just a recommendation for the container=
 developer, not a must have=2E I had to experience this problem in a real=
 world project, where ATG Dynamo Application Server did not throw such an=
 exception on concurrent access to a stateful bean=2E

As I said in my first posting there should be no state in a stateless bean=
 so no need to synchronize=2E Unless you share the client id explicitly you=
 will also not get into the situation, that two different clients access a=
 stateful bean at the same time=2E

To make further discussion easier, Ashwani, you should tell us why you want=
 to synchronize (is there a state in the instance, some static state, DB DB=
 state?) and on what object this snychronization should happen (on EJB=
 instance, on method for all instances, or on some member or static=
 object?)=2E

Regards, Andreas=2E
http://www=2Eandiberg=2Ede/

________________________________

Von: A mailing list for Enterprise JavaBeans development=
 [mailto:EJB-INTEREST@JAVA=2ESUN=2ECOM] Im Auftrag von Kalra, Ashwani
Gesendet: Freitag, 19=2E Mai 2006 07:37
An: EJB-INTEREST@JAVA=2ESUN=2ECOM
Betreff: Re: AW: Synchronizing ejb method


You are right John, It just got out of my mind that batch process is not a=
 web client=2E
=20
Thanks
Ashwani

________________________________

From: Johan Eltes [mailto:johan=2Eeltes@callista=2Ese]
Sent: Friday, May 19, 2006 11:03 AM
To: Kalra, Ashwani
Cc: EJB-INTEREST@JAVA=2ESUN=2ECOM
Subject: Re: AW: Synchronizing ejb method


I don't think the batch and the clients will get th same session id=2E=
 That's the whole idea of stateful session beans - that each client gets=
 its own instance and that the instance has affinity for requests from its=
 owning "user" during the lifetime of the users session=2E I would=
 recommend application-controlled database state management for locking out=
 one type of client from the other (with stateless session bean)=2E=20

/Johan

19 maj 2006 kl=2E 06=2E15 skrev Kalra, Ashwani:


        No its not correct=2E=20
        Section 7=2E5=2E8 , Ejb 2=2E1
        =20
        "Clients are not allowed to make concurrent calls to a stateful=
 session object=2E If a client-invoked business

        method is in progress on an instance when another client-invoked=
 call, from the same or different client,

        arrives at the same instance of a stateful session bean class, the=
 container may throw the

        java=2Ermi=2ERemoteException to the second client[7] if the client=
 is a remote client, or the

        javax=2Eejb=2EEJBException if the client is a local client=2E This=
 restriction does not apply to a stateless

        session bean because the container routes each request to a=
 different instance of the session bean

        class=2E"

        I think there is no standard approach as Andreas said=2E My problem=
 is that there is some batch process running and there is jsp page that can=
 access the same method of ejb which I wanted to avoid=2E I think I can use=
 statefull session bean so that at least second client gets the exception=
=2E

=09
        =20

        Thanks

        Ashwani

=09
        =20
=09
        =20

________________________________

        From: A mailing list for Enterprise JavaBeans development=
 [mailto:EJB-INTEREST@JAVA=2ESUN=2ECOM] On Behalf Of Tareq Ayub
        Sent: Friday, May 19, 2006 7:55 AM
        To: EJB-INTEREST@JAVA=2ESUN=2ECOM
        Subject: Re: AW: Synchronizing ejb method
=09
=09
        Refer to the EJB spec=2E The container will not allow multiple=
 threads to use the same instance of an SLSB=2E From the spec - "The=
 container must ensure that only one thread can be executing an instance at=
 any time"=2E Given that, why would you want to synchronize on an EJB=
 method anyways ? Also, SLSB have no state (no instance variables)=2E  The=
 same principle applies to SFSB in addition to the fact an instance is tied=
 to a single client=2E=20

        Tareq=20
=09
=09
        On May 15, 2006, at 2:40 AM, Andreas Berg wrote:


                You shouldn't=2E The only reason to synchronize a stateless=
 session bean is if your bean is not stateless=2E Then ask yourself why you=
 chose a stateless bean for some stateful purpose=2E
                =20
                If you really want to synchronize your SLSB you need to=
 think about the runtime environment=2E If all the instances of the SLSB=
 run in a single JVM, you can use the standard Java synchronization=
 features inside the bean to synchronize=2E But this doesn't work with a=
 clustered environment=2E AFAIK there is no standard approach to solve this=
=2E
                =20
                Kind regards,
                =20
                Andreas=2E
                =20
                =20
                Andreas Berg
                Zelfi AG
                Hechtsheimer Stra=DFe 33
                55131 Mainz
                Telefon: 06131-9064850
                Telefax: 06131-9064853
                andreas=2Eberg@zelfi=2Ecom
                http://www=2Ezelfi=2Ecom/
                =20

________________________________

                Von: A mailing list for Enterprise JavaBeans development=
 [mailto:EJB-INTEREST@JAVA=2ESUN=2ECOM] Im Auftrag von Kalra, Ashwani
                Gesendet: Montag, 15=2E Mai 2006 06:42
                An: EJB-INTEREST@JAVA=2ESUN=2ECOM
                Betreff: Synchronizing ejb method
        =09
        =09
                Hi,
                The client of my ejb can be an jsp or standalone java class=
=2E  How can I synchronize access to the SLSB ejb method? I am using ejb2=
=2E0 version
                =20
                =20

                __________________=20
                Regards=20
                Ashwani Kalra=20
        =09

                =20
                This message contains information that may be privileged or=
 confidential and is the property of the Capgemini Group=2E It is intended=
 only for the person to whom it is addressed=2E If you are not the intended=
 recipient, you are not authorized to read, print, retain, copy,=
 disseminate, distribute, or use this message or any part thereof=2E If you=
 receive this message in error, please notify the sender immediately and=
 delete all copies of this message=2E
        =09
                =09
                =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D To unsubscribe, send email to listserv@java=2Esun=2Ecom=
 and include in the body of the message "signoff EJB-INTEREST"=2E For=
 general help, send email to listserv@java=2Esun=2Ecom and include in the=
 body of the message "help"=2E=20

                =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D To unsubscribe, send email to listserv@java=2Esun=2Ecom=
 and include in the body of the message "signoff EJB-INTEREST"=2E For=
 general help, send email to listserv@java=2Esun=2Ecom and include in the=
 body of the message "help"=2E=20



        =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D To unsubscribe, send email to listserv@java=2Esun=2Ecom and=
 include in the body of the message "signoff EJB-INTEREST"=2E For general=
 help, send email to listserv@java=2Esun=2Ecom and include in the body of=
 the message "help"=2E=20

        This message contains information that may be privileged or=
 confidential and is the property of the Capgemini Group=2E It is intended=
 only for the person to whom it is addressed=2E If you are not the intended=
 recipient, you are not authorized to read, print, retain, copy,=
 disseminate, distribute, or use this message or any part thereof=2E If you=
 receive this message in error, please notify the sender immediately and=
 delete all copies of this message=2E
=09
        =09
        =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D To unsubscribe, send email to listserv@java=2Esun=2Ecom and=
 include in the body of the message "signoff EJB-INTEREST"=2E For general=
 help, send email to listserv@java=2Esun=2Ecom and include in the body of=
 the message "help"=2E=20



This message contains information that may be privileged or confidential=
 and is the property of the Capgemini Group=2E It is intended only for the=
 person to whom it is addressed=2E If you are not the intended recipient,=
 you are not authorized to read, print, retain, copy, disseminate,=
 distribute, or use this message or any part thereof=2E If you receive this=
 message in error, please notify the sender immediately and delete all=
 copies of this message=2E

=09
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
 To unsubscribe, send email to listserv@java=2Esun=2Ecom and include in the=
 body of the message "signoff EJB-INTEREST"=2E For general help, send email=
 to listserv@java=2Esun=2Ecom and include in the body of the message "help"=
=2E=20

=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
To unsubscribe, send email to listserv@java=2Esun=2Ecom and include in the=
 body
of the message "signoff EJB-INTEREST"=2E  For general help, send email to
listserv@java=2Esun=2Ecom and include in the body of the message "help"=2E

This message contains information that may be privileged or confidential=
 and is the property of the Capgemini Group=2E It is intended only for the=
 person to whom it is addressed=2E If you are not the intended recipient, =
 you are not authorized to read, print, retain, copy, disseminate, =
 distribute, or use this message or any part thereof=2E If you receive this=
  message in error, please notify the sender immediately and delete all =
 copies of this message=2E

=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
To unsubscribe, send email to [email protected] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[email protected] and include in the body of the message "help".