hi Amit,
You are right. This  scenario is usually for jsp->>EJB or jsp-->delegate-EJB. 
Where callers are not originators of the transaction. But the original question 
is,If I am correct is that why you have to call setRollback(sometimes) even if 
you are throwing EJBException which is nothing but child of RuntimeException.
This scenario is like
ejb1-->ejb2(this calls setRollbackonly  after getting some exception). So what 
are the options for ejb1. Ejb1 can also be originator of Transaction.


/Ashwani


> -----Original Message-----
> From: Amit Kharadkar [mailto:[EMAIL PROTECTED]
> Sent: Monday, March 21, 2005 2:44 PM
> To: Kalra, Ashwani; EJB-INTEREST@JAVA.SUN.COM
> Subject: RE: EJBException and setRollBackOnly
>
>
> Hi Ashwani,
> If a runtime exception like a null pointer exception or a
> array index out of
> bounds exception is raised then the transaction is automatically for
> rollback
> If a user-defined exception is raised then u will have to set the
> transaction for rollback as per the desired condition. You
> can the set the
> transaction for rollback and not raise a exception
>
> Warm Regards
> Amit Kharadkar
> CashTech Solutions Pvt. Ltd.,
> Pride Parmar Galaxy,
> Sadhu Vaswani Chowk,
> Pune 411009
> Tel. 91 20 56052000 (ext. 2165)
>
> -----Original Message-----
> From: A mailing list for Enterprise JavaBeans development
> [mailto:[EMAIL PROTECTED] Behalf Of Kalra, Ashwani
> Sent: Monday, March 21, 2005 2:16 PM
> To: EJB-INTEREST@JAVA.SUN.COM
> Subject: Re: EJBException and setRollBackOnly
>
> >I have a container managed session bean which calls DAO, and I was
> wondering why we have to setRollBackOnly once we catch
>
> >the exception and then throw EJBException.
>
> This is what I read from specs 2.1 relevant to your question.
> It explains
> why you need to call setRollBackOnly.
>
> " When a client executing in a transaction context receives a
> RemoteException or an EJBException
> from an enterprise bean invocation, the client may use either of the
> following strategies to deal
> with the exception:
> * Discontinue the transaction. If the client is the
> transaction originator,
> it may simply rollback its
> transaction. If the client is not the transaction originator,
> it can mark
> the transaction for rollback
> or perform an action that will cause a rollback. For example,
> if the client
> is an enterprise
> bean, the enterprise bean may throw a RuntimeException which
> will cause the
> container
> to rollback the transaction.
> * Continue the transaction. The client may perform additional
> operations on
> the same or other
> enterprise beans, and eventually attempt to commit the
> transaction. If the
> transaction was
> marked for rollback at the time the RemoteException or
> EJBException was
> thrown to
> the client, the commit will fail."
>
> >Can I just do setRollBackOnly and not throw EJBException?
> Will it still
> roll back the transaction? Or it won't happen until
>
> >the container catches EJBException.
> No, Client , or container will get the indication only if you throw
> appropriate exceptions.
>
> Thank you very much for any help.
>
> /Ashwani
>
>
>
> -----Original Message-----
> From: A mailing list for Enterprise JavaBeans development
> [mailto:[EMAIL PROTECTED] Behalf Of Lee, Howard
> Sent: Saturday, March 19, 2005 3:40 AM
> To: EJB-INTEREST@JAVA.SUN.COM
> Subject: EJBException and setRollBackOnly
>
>
> Hi,
>
> I have a container managed session bean which calls DAO, and
> I was wondering
> why we have to setRollBackOnly once we catch the exception
> and then throw
> EJBException. Can I just do setRollBackOnly and not throw
> EJBException? Will
> it still roll back the transaction? Or it won't happen until
> the container
> catches EJBException. Thank you very much for any help.
>
>
> **********************************************************************
> E-mail sent through the Internet is not secure. Western Asset
> therefore
> recommends that you do not send any confidential or sensitive
> information to
> us via electronic mail, including social security numbers,
> account numbers,
> or personal identification numbers. Delivery, and or timely
> delivery of
> Internet mail is not guaranteed. Western Asset therefore
> recommends that you
> do not send time sensitive or action-oriented messages to us
> via electronic
> mail.
>
> **********************************************************************
> ==============================================================
> =============
> 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".
>
>
> This message contains information that may be privileged or
> confidential and
> is the property of the Capgemini Group. It is intended only
> for the person
> to whom it is addressed. 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. If you receive this 
> message in error,
> please notify the sender immediately and delete all  copies
> of this message.
>
> ==============================================================
> =============
> 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".
>
>

This message contains information that may be privileged or confidential and is 
the property of the Capgemini Group. It is intended only for the person to whom 
it is addressed. 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. If you receive this  message in error, please notify the 
sender immediately and delete all  copies of this message.

===========================================================================
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".

Reply via email to