Home Caching using singletons


EJB design: Home Caching using singletons

  1. Home Caching using singletons (6 messages)

      i am facing this rather strange problem.I am using a singleton to store my EJB Homes so that i dont have to do lookup of homes everytime I invoke a bean.Now all my EJBs are getting deployed and the singleton also gets compiled properly.But when i try to get the homes thru a singleton method in my session bean ;I am getting "Classdef not found javax/naming/Context".I dont think that there is any restriction on using singletons in Session beans..and if not...is this a problem of class loader in weblogic.
     I wanted to provide the code as well thats generating the error.

       // get reference of singleton class
       singletonHomes =SingletonHomes.getReference() ;

       // get DDAHome from static reference
      DDAHome ddaHome = (DDAHome )
                             singletonHomes.getDDAHome() ;

    if i replace this code with a normal lookup ; it works fine.The problem is with singleton; class loader i suppose.

      Any help would be appreciated.


    Threaded Messages (6)

  2. Home Caching using singletons[ Go to top ]

    I guess you can use the singleton but try not to store the ref itself (the Home ref you got from the lookup at the beginning). Instead use the HomeHandle...The first time you get the Home ref call getHomeHandle and store it
    and when you need it again ,you can access this HomeHandle and call getEJBHome to get the Home ref...I hope this helps
  3. Home Caching using singletons[ Go to top ]

      I got the solution.I included weblogicaux.jar in the classpath apart from weblogic.classpath and it found the particular class file.I dont know how weblogic class paths work.
      Anyways ; whats the reason u say that I should use home handle instead of a reference.Can u elaborate on that.
  4. Home Caching using singletons[ Go to top ]


    The need to store home handles arises only if u wanna serialize handles and store in some permanent storage like a database, since home handles are serializable. In your case home references should work fine.

  5. Home Caching using singletons[ Go to top ]

    Yep Rajit
        Thats what I thought.
  6. Home Caching using singletons[ Go to top ]

    Yes agree...use of Handle is just to be on the safe side (Handle is similar to IOR anyways ...it incorporates info to get the ref back)
  7. Home Caching using singletons[ Go to top ]

    Does the get* method need to be synchronized???? To be more descriptive, do the accesses to the cached home handles need to be synchronized????? It seems like it's not since one has to get the remote reference from the home handle.

    Se Hee