Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!

LakshmiNarayana Kodali

Greenhorn
+ Follow
since Oct 30, 2008
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by LakshmiNarayana Kodali

EntityExistsException occurs when trying to persist a new entity instance into database but that entity already exists in database.

The persistence provider will write an Insert statement for the persist operation.

And if the DB Manager executes that statement, the insert operation fails beacuse of PrimaryKey Constraint.

So that's why the EntityExistsException will occur.


-------------------------------------
LakshmiNarayana Kodali
SCJP 5(98%), SCWCD(100%), SCBCD in progress
You can have mutiple callbacks for a given bean.It is correct.

But the condition is you cannot define mutiple callback methods for a single lifecycle event in a Single bean class


Ex. In the above example, you mentioned 2 callback methods initBean() and initializeBean() for a PostConstuct event in 1 bean class PlcaeBidBean. This is wrong


However you can remove the one of the postConstruct methods and can put it in bean superclass or also in Bean Interceptor classes so that both methods will be called.

Simply to say, atmost 1 lifecycle callback method should be declared for each lifecycle event in each class ( it can be bean class or its super class or its interceptor class)


2. Lifecycle callback methods are also called as lifecycle callback interceptor methods.
I think because of that the exception has "Interceptors" words. Not sure

3. EJB3 in Action is really good book for EJB3 beginners. The authors did an excellent work.
The points mentioned by the authors are from the Specs only.
But there are few concepts which they need to explain clearly.

I looked at the questions raised by you. Really good. I'm also looking for answers for some questions. Let's see

-------------------------------------
LakshmiNarayana Kodali
SCJP 5(98%), SCWCD(100%), SCBCD in progress
The 1st,2nd and 3ed statements are correct.

4th statement is wrong.

If the bean instance method ( Business or lifecycle callback method ) throws runtime exception, @PreDestroy callback method will not be called. It will be missed

-------------------------------------
LakshmiNarayana Kodali
SCJP 5(98%), SCWCD(100%), SCBCD in progress
Session Bean provider means the programmer who develops the Session Beans.

Simply to say, the programmers who writes the SessionBean classes and its interfaces and its interceptor classes

-------------------------------------
LakshmiNarayana Kodali
SCJP 5(98%), SCWCD(100%), SCBCD in progress
For the Question 1 which you posted regarding lookup() method,

the answer is a,b,c.

In the lookup() method, 2 components are retrieved.
1. JMS resource using JNDI lookup (i,e Resource access)
2. Enterprise Bean access.

Both of these 2 things can be done using business method and also lifecycle callback methods.

So lookup() can be
a) It can be a business method
b) It can be a @PostConstruct method (It is lifecycle callback method)
c) It can be a @Remove method (It is also a business method in Stateful Bean)


These are the following things which can be done using both business methods and lifecycle callback methods.

1. SessionContext methods: getBusinessObject, getEJBHome, getEJBLocalHome, getCallerPrincipal, isCallerInRole, getEJBObject, getEJBLocalObject,
lookup
2. JNDI access to java:comp/env
3. Resource manager access
4. Enterprise bean access
5. EntityManagerFactory access
6. EntityManager access

-------------------------------------
LakshmiNarayana Kodali
SCJP 5(98%), SCWCD(100%), SCBCD in progress
setRollBackOnly() is available on SessionContext and MessageDrivenContext.


So this method works successfully if the following conditions are met

1. Session Beans or Message Driven Beans should use CMT (Transaction should be managed by container) and also
2. The method should be called in transactional context


It will throw IllegalStateException if
1. called in non transactional context or
2. called by the BMT bean

-------------------------------------
LakshmiNarayana Kodali
SCJP 5(98%), SCWCD(100%), SCBCD in progress
[ December 26, 2008: Message edited by: LakshmiNarayana Kodali ]
Congrats !!! for passing the exam




---------------------------------
LakshmiNarayana
SCJP5(98%), SCWCD(100%)
11 years ago
Yes you are correct

If an EntityManager is injected into Session bean using DI, it is Container managed JTA Entity Manager. And Container Managed EntityManager cannot be resouce local EntityManager.


Application Managed EntityManagers can be created using EntitymanagerFactory but cannot be injected using DI.
You need to read the Specs so that you can understand EJB3.0 thoroughly and also you will get a good score.

-----------------------------------------

LakshmiNarayana Kodali
SCJP 5, SCWCD 5 and SCBCD 5( in progress )
Client cannot remove Stateless Session Bean.

Only the Container can remove the Stateless Session Bean.

The following are the cases where the Stateless Session Bean will be destroyed.

1. If the Container finds that thee are already more beans in the pool, then there is possibility that few beans will be removed.
If there is any @PreDestroy method, it will be called first and then destroyed

2. If Container crashes, then beans will be removed without calling @PreDestroy method
[ December 12, 2008: Message edited by: LakshmiNarayana Kodali ]
Yes It is possible to understand EJB3 and finish Certification within 2 months.

If you have any idea on ORM tools like hibernate or Oracle TopLink then it is much easier
I would suggest you to go for EJB 3 in action as you are a beginner.

Head First EJB is about EJB 2.0 and you cannot use that book for SCBCD 5.0 as there is a lot of difference between EJB 2.0 and EJB 3.0


You can also use Mastering EJB and Oreilly EJB 3.0 for reference.
The default access specifier for abstract class is default.

---------------------------------------------

LakshmiNarayana Kodali
11 years ago
Congrats!!!



-----------------------------

LakshmiNarayana Kodali
SCJP 5, SCWCD 5
11 years ago
EJB3 in action is the best for beginner.

For reference, You can use Oreilly EJB3.0 5th edition and Mastering EJB 4th Edition.


LakshmiNarayana Kodali
SCJP 5, SCWCD 5