Hi,
I read in the "Mastering EJBs" book that the EJB spec does not allow multithreading inside the EJBs. But I tried to make an EJB by implementing Runnable and starting a thread inside the Bean class. But neither javac nor ejbc gave any errors. Shouldn't atleast ejbc give me a warning. I'm using Weblogic 8.1.3 and my compiler is jrockit-jdk.
Also what is the behaviour if there is any non-final static variable in EJBs.
Thanks
-
Threading in EJBs (7 messages)
- Posted by: Varun Airi
- Posted on: September 24 2004 09:29 EDT
Threaded Messages (7)
- Threading in EJBs by Sanjaya Ganesh on September 26 2004 23:16 EDT
- Threading in EJBs by Varun Airi on September 27 2004 02:47 EDT
-
Threading in EJBs by Nicolas Dobler on September 27 2004 08:00 EDT
- sorry by Nicolas Dobler on September 27 2004 08:11 EDT
- Threading in EJBs by Sanjaya Ganesh on September 27 2004 08:04 EDT
-
Threading in EJBs by Nicolas Dobler on September 27 2004 08:00 EDT
- Threading in EJBs by Varun Airi on September 27 2004 02:47 EDT
- Thanks by Varun Airi on September 27 2004 10:48 EDT
- Threading in EJBs by Igor Shindin on October 08 2004 13:17 EDT
-
Threading in EJBs[ Go to top ]
- Posted by: Sanjaya Ganesh
- Posted on: September 26 2004 23:16 EDT
- in response to Varun Airi
(1) I dont think "does not allow" is right - All those things like "Do not do IO inside EJBs", "Do not multi-thread" etc., are best practices in using EJBs. Of course, it does not tie your hands to prevent you from doing that - but it is never a good practice. You might have the reason why in the book, I believe.
(2) Not clear what your question on variable is - you can of course use non final statics.
-Sanjay -
Threading in EJBs[ Go to top ]
- Posted by: Varun Airi
- Posted on: September 27 2004 02:47 EDT
- in response to Sanjaya Ganesh
Thanks for the reply. In (2) I was asking that if we do have a non-final static variable in stateless/statefull session beans and its value is changed within the bean, then when the same EJB object is used to service some other request, doesn't it provide a wrong value ( the one that was set in last request).
Thanks -
Threading in EJBs[ Go to top ]
- Posted by: Nicolas Dobler
- Posted on: September 27 2004 08:00 EDT
- in response to Varun Airi
If you have a stateless SB, then you shouldn't have any non static variable because the same bean instance can be used to serve other clients.
If you have a statefull SB, you shouldn't have any problem. That bean instance will only serve one client (unless of course you share that bean instance with other clients, but I don't think you'd do that) -
sorry[ Go to top ]
- Posted by: Nicolas Dobler
- Posted on: September 27 2004 08:11 EDT
- in response to Nicolas Dobler
I missunderstand you. My answer was for non-static variables.
Sorry -
Threading in EJBs[ Go to top ]
- Posted by: Sanjaya Ganesh
- Posted on: September 27 2004 08:04 EDT
- in response to Varun Airi
Varun:
I got it now - Yes. Statics are a NO NO too. They dont mean anything actually in a cluster of EJBs :-).
-Sanjay -
Thanks[ Go to top ]
- Posted by: Varun Airi
- Posted on: September 27 2004 10:48 EDT
- in response to Varun Airi
Thanks for the help -
Threading in EJBs[ Go to top ]
- Posted by: Igor Shindin
- Posted on: October 08 2004 13:17 EDT
- in response to Varun Airi
You can do whatever you want. But in J2EE it is safer and better to follow best practices