Can I call static methods in a cluster ?


General J2EE: Can I call static methods in a cluster ?

  1. Can I call static methods in a cluster ? (3 messages)

    Hi all,
    I have many JavaBeans utilities classes with static methods which I use for a stand-alone web-application application.
    Now I'd like to deploy the application in a cluster. What will be the impact ?
    Can I reuse my utility classes with static methods ?
    Thanks a lot
  2. No problem at all if you keep an eye for wich classloader is loading these classes. If you have static instances (like singletons) you can have nasty surprises.

    If your "util.jar" is in the server classpath, there will be only one class loading (i.e. a singleton would be shared by ALL applications in this server) in this JVM.

    If your "util.jar" is replicated in each WEB-INF/lib, these classes will be loaded by each application classloader (i.e. there would be one singleton instance for each application - this is the way Struts MUST be loaded, for example).
  3. Hi,
    thanks for your answer.
    Actually I'm not accustomed with the practice of adding libs in the classpath (in the development phase at least) yet, I'm interested to give it a try.
    I have a further question about utils instantiated with listeners (like Servlet context) but I I'd like to open a new thread for it.
    Tks again
  4. We are developing an application for the client .The environment is on weblogic and with hardware cluster Our application follows simple MVC-2 framework with struts implementation .We have simple service layer and DAO layer associated with it .The service layer and DAO layer consist of the all static method .The implementation works for single server do u foresee any issues in the cluster especially at service and DAO layer. Should we think on redesigning the services and DAO layer? Please suggest us best practices Narayana Sr Technical Consultant