Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

EJBTransactionRollbackException thrown to remote or local client?

 
Ranch Foreman
Posts: 1924
13
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
According to this API :http://docs.oracle.com/javaee/6/api/javax/ejb/EJBTransactionRolledbackException.html
It says, EJBTransactionRollbackException is thrown to a remote client telling the client that the client's transaction is marked for rollback or has been rolled back.

But when I tried, this exception can be thrown to a local callee bean which in the same .war file as the bean that throws a system exception and causes the transaction to be marked for rollback.


I have two more days before my exam. I am keeping my fingers cross now.

 
Bartender
Posts: 1558
5
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Somehow, I'm not able to find any reference which mentions that this exception cannot be thrown to local client

Further, according to section 14.3.1 of EJB Sepcification:

If the business interface is a remote business interface that extends java.rmi.Remote, the javax.transaction.TransactionRolledbackException is thrown to the client, which will receive this exception.


(here, 'this' exception means EJBTransactionRollbackException) - so it seems that this exception can be thrown to local client as well.

Can you recheck the scenario with no-interface view?
 
Himai Minh
Ranch Foreman
Posts: 1924
13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried with two @LocalBean , BeanA and BeanB. The servlet client and the beans are in the same .war file. The EJBTransactionRollbackException is thrown to BeanA, even though BeanA and BeanB are local to each other.





Output:
Warning: A system exception occurred during an invocation on EJB BeanA method public void com.ivan.scbcd6.BeanA.methodA()
javax.ejb.EJBTransactionRolledbackException
.....
Caused by: javax.ejb.TransactionRolledbackLocalException: Exception thrown from bean
...
Caused by: java.lang.RuntimeException: run time exception from b
at com.ivan.scbcd6.BeanB.methodB(BeanB.java:26)

Warning: StandardWrapperValve[OtherServlet]: PWC1406: Servlet.service() for servlet OtherServlet threw exception
javax.ejb.EJBTransactionRolledbackException
 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys.
Some time ago I was investigating this question also.

The conclusion is (14.3.1 of EJB Sepcification):
If you're using EJB 3.x approach the EJBTransactionRolledBackException for both Local and Remote beans.
If you're using EJB 2.1 then exception depends on if it's Local (EJBTransactionRolledBackException) or Remote (javax.transaction.TransactionRolledbackException) bean.
 
Not so fast naughty spawn! I want you to know about
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic