Forums Register Login

Question on Singleton Session Bean Instantiation

+Pie Number of slices to send: Send

Source:OCP JavaEE 6 EJB Developer Study Notes by Ivan A Krizsan,Version: April 8, 2012



Hi All,

Below is the Code for Singleton Session Bean and Client Servlet that accesses the Bean.

Singleton Session Bean


Client Servlet


Below is the messages logged server.log:




Request Issued:

http://localhost:8080/BusinessMethodInterceptors/
http://localhost:8080/BusinessMethodInterceptors/test.do

Here,BusinessMethodInterceptors is the name of Web Project.

As per my understanding,Singletion Session Bean is instantiated once per application per class.
However, in the server.log I see that it is Instantiated(Created) twice in application (See message "INFO: *** SingletonSessionBeanA - Created" is displayed twice)
Please advise if my understanding is incorrect.
+Pie Number of slices to send: Send
Hi Mohit,

This is what I also noticed when I was preparing for the exam: the constructor of a Singleton is called twice (!). This is an implementation specific thing not mandated (or explained) by the specifications. The PostConstruct method is only called once luckily...

Regards,
Frits
+Pie Number of slices to send: Send
Thanks again Frits
Do not set lab on fire. Or this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1806 times.
Similar Threads
GlassFish v3 and localhost in Windows7
a blank glassFish admin console @ netbeans 6.8
Call EJB from Application Client
Help With Rest EJB
cant load the admin console in glassfish v3
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 17:23:41.