No replies so far.. Forwarding again ..
Hi all
I have the following scenario in my deployment :-
+-----+ +-----+ +-----+
| A |----------------->| B |------------------->| C |
+-----+ +-----+ +-----+
Stateless Stateless Entity
Session Session (CMP)
foo() ----- calls -----> bar() ----- calls -----> finder()
throw throw throw
BarException BarException ObjectNotFoundException
This is what I expect from the beans :
The finder in bean C should throw FinderException. Bean B should
catch this exception and throw BarException. Bean A should throw
BarException back to the caller. The caller is the actual client
program. The client expects BarException to be thrown in the given
scenario.
The only bean which updates the database is Bean C. That too, it does not
update more than one table. Therefore, it is not necessary that updates
should happen within a transaction. Since database update is not
happening within a transaction, bean B and A also need not execute their
methods within a transaction.
The transactional attribute in all the three bean's ejb-jar.xml is :
<container-transaction>
<method>
<ejb-name>BeanX</ejb-name> // where X = A, B, C
<method-intf>Remote</method-intf>
<method-name>*</method-name>
</method>
<trans-attribute>Required</trans-attribute>
When I deploy the beans and run the client, this is what happens :
1. Client class A.foo()
2. A.foo() calls B.bar()
3. B.bar() calls C.finder()
4. C.finder() throws ObjectNotFoundException (shouldnt it throw
FinderException? Anyway that's ok).
5. B.bar() catches Exception and throws BarException
6. A.foo() gets javax.transaction.TransactionRolledBackException
instead of BarException. The method foo() is written this way to
re-throw BarException.
...
}
catch (BarException e) {
throw e; // re-throw
}
catch (Exception e) {
throw new EJBException(e);
}
Since foo() does not get BarException (it is lost), it goes the
catch(Exception) clause and so EJBException is thrown.
7. The client gets EJBException whereas it is expecting
BarException. It doesnt know what to do with this Exception and
so it fails :-(
This is my question. What changes should I make to the bean or to the
transactional attributes so that BarException is thrown all the way back
till the client?
Im using Weblogic 5.1 on NT.
Thanks.
--
shiv
[EMAIL PROTECTED]
__________________________________________________
Do You Yahoo!?
Talk to your friends online with Yahoo! Messenger.
http://im.yahoo.com
===========================================================================
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".