How do I write a J2EE/EJB Singleton?



A day ago my application was one EAR, containing one WAR, one EJB JAR, and a couple of utility JAR files. I had a POJO singleton class in one of those utility files, it worked, and all was well with the world:


EAR
|--- WAR
|--- EJB JAR
|--- Util 1 JAR
|--- Util 2 JAR
|--- etc.

Then I created a second WAR and found out (the hard way) that each WAR has its own ClassLoader, so each WAR sees a different singleton, and things break down from there. This is not so good.


EAR
|--- WAR 1
|--- WAR 2
|--- EJB JAR
|--- Util 1 JAR
|--- Util 2 JAR
|---

Related to : How do I write a J2EE/EJB Singleton?
J2EE/EJB + service locator: is it safe to cache EJB Home lookup result?
Programming Languages

In a J2EE application, we are using EJB2 in weblogic.


To avoid losing time building the initial context and looking up EJB Home interface, I'm considering the Service Locator Pattern.


But after a few search on the web I found that even if this pattern is often recommended for the InitialContext caching, there are some negative opinion about the EJB Home caching.


Questions:


Is it safe to cache EJB Home lookup result ?
What will happen if one my cluster node is no more working ?
What will happen if I install a new version of the EJB without refreshing the service locator's cache ?

How do I write a J2EE/EJB Singleton?
Programming Languages

A day ago my application was one EAR, containing one WAR, one EJB JAR, and a couple of utility JAR files. I had a POJO singleton class in one of those utility files, it worked, and all was well with the world:


EAR
|--- WAR
|--- EJB JAR
|--- Util 1 JAR
|--- Util 2 JAR
|--- etc.

Then I created a second WAR and found out (the hard way) that each WAR has its own ClassLoader, so each WAR sees a different singleton, and things break down from there. This is not so good.


EAR
|--- WAR 1
|--- WAR 2
|--- EJB JAR
|--- Util 1 JAR
|--- Util 2 JAR
|---
Singleton across classloaders/EJB:How to avoid multiple instance of JCS Cache due to multiple class loader/EJB's?
Programming Languages

I want to use JCS (Java Cache System) to cache ldap queries which should be shared by multiple EJB's (class loaders) to avoid the duplicate searches. I have created a singleton wrapper to create only one instance of JCS cache but due to each EJB's having their own class loader, it creates multiple instance of JCS cache so ldap search results are not reused.


Is there any way to create a true singleton which can be shared by multiple EJBs/Class loaders?
One of my friend suggested to create a EJB wrapper on my singleton. Is it right approach? Can't I implement without EJB? I saw and article about how to implement "Absolute Singleton" but when I tried the solution

EJB help, very confused with gui's and JFrames with J2EE
Programming Languages

Hi im in need of some help with a J2EE application im working on. I need to develop a JFrame front-end GUI client that will talk to the server, however i am not sure how to use JFrame to invoke methods on the server. This is mainly because im struggling to understand how I can call a method on the client side that will call a method on the server side when it appears to me that the client doesn't have a handle on the server-side (If that makes sense?)
I have crawled the web for some examples(including sun) but I still cannot find a tutorial.
So I created a simple 'Tester' package that had a stateless session bean
Familar with Java but not J2EE, JSP, EJB
Programming Languages

I'm looking for a good book to get started with J2EE, JSP, EJB, and Struts.
To be honest, I'm not really familar with those. I'm fairly a newbie programmer when it comes to Java - by that, I mean, I can implement data structures (binary trees, priority queues, stacks, graphs, sorting routines, etc). I can do a bit of Java applets.
Thus far, I had been doing all my projects in Java using JCreator, which many say is for beginners. So, I just downloaded Oracle JDeveloper 10g as a new IDE for my Java projects.
Now, at the moment I'm relearning advanced methods of PHP like OOP and networking
Which j2ee/j2se for EJB?
Programming Languages

hi all,
I currently studying 2 books both by the 'head first' series, jsp+servlets and EJB. i'm two thirds through the servlets+jsp book and if anyone needs to learn this subject this is the book, it's amazing!!
I've just started reading the book on EJB and i'm not sure which version of j2ee to get. the book says 1.3 not 1.4 but i can't find a link to it at sun?? Secondly the j2se i've got is 1.5. The book states that there could be problems with this later version?? Does this mean i'll have to downoad 1.3 or 1.4 or is there a patch now for the server as the book was written a couple of years ago?

Privacy Policy - Copyrights Notice - Feedback - Report Violation - RSS 2017 © bighow.org All Rights Reserved .