• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Application Exceptions...

 
Niranjan Deshpande
Ranch Hand
Posts: 1277
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Application exceptions can be checked or unchecked.

1.if they are checked, they need to be declared in the "throws" clause, the do not auto roll back the transaction so you need to manually roll back using setRollBackOnly( )

2.if they are unchecked, they need NOT be declared in the "throws" clause, they do not auto roll back the transaction so you need to manually roll back using rollback=true in the @ApplictionException on the exception class.

So, checked App Ex. MUST be defined as MyAppEx extends java.lang.Exception and unchecked app. ex. MUST be defined as
@ApplicationException(rollback="true/false")
public class MyAppEx

Should the above definition style mandotrily followed for defining the checked/unchecked exceptions?

 
Treimin Clark
Ranch Hand
Posts: 757
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Checked application exception cal also be defined with the @ApplicationException annotation. If it defined as the rollback=true, no need to explicitly use the setRollbackOnly() method.

@ApplicationException(rollback=true)
public class MyException extends Exception{}

If an exception extends java.lang.Exception, but did not defined as an application by using ApplicationException, it is still an application exception with rollback=false. That is why you need to explicitly call the setRollbackOnly() method their.
 
Ralph Jaus
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So, checked App Ex. MUST be defined as MyAppEx extends java.lang.Exception and unchecked app. ex. MUST be defined as
@ApplicationException(rollback="true/false")
public class MyAppEx

Using the deployment descriptor, pre-existing (checked as well as unchecked) exceptions can be defined as application exceptions, too:
 
Treimin Clark
Ranch Hand
Posts: 757
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Uh! These descriptorsssss


 
Niranjan Deshpande
Ranch Hand
Posts: 1277
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
...they seem to be friendly to me now. The trick is: if you get a question on DD, you can logically weed out the absurd/weird/crappy names based on your experience of 'logically how a DD element can be like'

Of course, to back this up you can use attempt lots of DD questions in the mock!

hth Clark...
 
Treimin Clark
Ranch Hand
Posts: 757
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But "Deshpande" you know there are some super elements and sub-elements, like something goes in to the <assembly-descriptor> and something in to the <enterprise-beans> and more and more.....

I wish I will'nt get and any DD on the exam.
 
Niranjan Deshpande
Ranch Hand
Posts: 1277
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
..good one clark! [;)]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic