0 Replies Latest reply on Nov 29, 2006 7:01 AM by Russ

    EJB Running on JBoss Server

    Russ Newbie

      I have deployed my application on a JBoss server (4.0.5). I have two EJBs that has a reference to a static class called ServiceLocator, The EJBs use this class throughout the lifecycle of the object. The ServiceLocator is a Singleton. Within the ejbCreate method, I check for the ServiceLocator class. If it is null, I call ServiceLocator.getInstance().

      My problem is understanding why JBoss does not like this static reference behavior. When I login to my application we go through EJB1. One of the things we do inside EJB1 is call other ejbs for addtional information. This is where the Service Locator becomes involved. Inside individual methods I use the ServiceLocator reference (sl) and fetch the appropriate EJB for use. The problem is the variable sl, is null when I attempt to use it within a business method. When I change the code to call the class like ServiceLocator.getInstance() everything is fine. Additionally, using a static initializer prevents the error, too. What I can see from the log files is the ejbcontainer is calling ejbRemove() just prior to calling the business method.

      Can someone share their knowledge in this area? I was under the understanding that ejbCreate was the approach one should take for creating a instance/class-level variable. Having a class level variable seem to make sense and reduced the number of keystrokes in each EJB.

      Thank you for taking the time to read and explain.