title: Can i throw all the exceptions from an EJB as my custom unchecked exception?
body: <p>As mentioned in this link <a href="https://stackoverflow.com/questions/1581600/why-throwing-an-ejbexception-is-a-recommended-practice">Why throwing an EJBException is a &quot;recommended&quot; practice?</a></p>
  <p><em>Specifically, the EJB specification says that if a bean throws a runtime exception (and EJBException is a runtime exception) from the business method, then the bean is discarded without calling ejbRemove on it.</em></p>
  <p>question1 : what does 'bean will be discarded' means here ?? do we need to lookup again in that case ??</p>
  <p><em>The throwing of EJBException is recommended by the EJB spec (14.2.2 in the EJB 3) in the cases where the EJB cannot recover from an exception it encounters.
  The spec also says that the EJB can reasonably allow (unchecked) System Exceptions to propagate to the container</em></p>
  <p>Let's consider my ejb method will insert data into 4 tables .
  If an exception occurs in the code after inserting data in 2 tables, i will not prompt the exception to user for getting a valid data from the user and process it and insert the data in 3rd n 4th table.
  Instead, i will just ask the user to call the EJB method again with proper data .</p>
  <p>question 2 : which of the following 3 is better option</p>
  <ul>
  <li><p>Both checked and unchecked exceptions in code as EJBException</p>
  </li>
  <li><p>Checked exceptions as customException and unchecked exceptions as EJBException</p>
  </li>
  <li><p>Both checked and unchecked exceptions in code as customException</p>
  <p>Note : customException is inherited from runtimeException and it is annotated as  &quot; @ApplicationException(rollback=true)&quot;</p>
  </li>
  </ul>
  <p>Thanks in advance..</p>