Noob Question about Classloaders and JMV in EJB


EJB design: Noob Question about Classloaders and JMV in EJB

  1. Hello, I have an EAR with 1 EJB in it. Can anyone tell me how many classloaders will this EJB have? I want to create a Singleton Class and its my understanding so far that there will be one classloader per EJB inside the EAR, so I guess it will be okay to have that Singleton class in there? I wanted to confirm that. Thank you.
  2. It depends on what AppServer that you are deploying your EJB. Normally there are three boottrap, application, and module classloaders which are used by an EJB module. If you want to use singleton, just to be aware that (1) module classloader is used by module only, i.e. if you deploy your class at this level, there may be several singleton instance in the same EAR application (2) application classloader is used by all EAR application, a singleton at this level will ensure that all modules in the same EAR share the same instance. (3) boottrap level, well it's obvious. Good luck,