exam questions

Exam 1z0-898 All Questions

View all questions & answers for the 1z0-898 exam

Exam 1z0-898 topic 1 question 32 discussion

Actual exam question from Oracle's 1z0-898
Question #: 32
Topic #: 1
[All 1z0-898 Questions]

FooBean and BarBean are both EJB 3.0 stateless beans with container-managed transaction demarcation. All business methods in FooBean have transaction attribute REQUIRED, and all business methods in BarBean have transaction attribute REQUIRED_NEW. The business method foo in FooBean invokes the
Business method bar in BarBean.
Given:
10. Public class BarBean {
11. public void bar () {
12. throw new RuntimeException ("unexpected error . . . ");
13. }}
Which is true about the method of invocation assuming execution reaches line 12?

  • A. FooBean.foo method receives javax.ejb.EJBException.
  • B. The BarBean bean instance is in ready state for the next invocation.
  • C. FooBean.foo method receives javax -ejb. EJBTtansactionRolledbackException.
  • D. FooBean.foo method receives the original RuntimeException thrown from BarBean.bar method.
Show Suggested Answer Hide Answer
Suggested Answer: A 🗳️
The exception will be thrown within the FooBean container.
A standard EJBException will be thrown.
The EJBException is thrown to report that the invoked business method or callback method could not be completed because of an unexpected error (e.g. the instance failed to open a database connection).
Note:

Transaction Attributes -
A transaction attribute controls the scope of a transaction. Figure below illustrates why controlling the scope is important. In the diagram, method-A begins a transaction and then invokes method-B of Bean-2. When method-B executes, does it run within the scope of the transaction started by method-A, or does it execute with a new transaction? The answer depends on the transaction attribute of method-B.
* RequiresNew Attribute
If the client is running within a transaction and invokes the enterprise beans method, the container takes the following steps:
1. Suspends the clients transaction
2. Starts a new transaction
3. Delegates the call to the method
4. Resumes the clients transaction after the method completes
If the client is not associated with a transaction, the container starts a new transaction before running the method.
You should use the RequiresNew attribute when you want to ensure that the method always runs within a new transaction.
Reference: The Java EE 6 Tutorial, Container-Managed Transactions

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
Currently there are no comments in this discussion, be the first to comment!
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...