Search code examples
javaclassloaderweblogic11g

is the class loader for different application can be different?


I am confused at a point while running my application. My application consists of EJB and servlets. i need to know, whether the class loader for these application types is same or different. I am using weblogic as application container. Please help me.


Solution

  • There is one class in my application which is singleton and class loader dependent.And the problem is that the instance of my class changes when class loader changes, and i need to use the same instance of the class through out the life time.

    Yes there is a system classloader that all of the webapp classloaders will delegate to.

    To get your class into that classloader, you need to make sure it is in the relevant classpath. For instance with Tomcat, you would put the JAR file into $CATALINA_HOME/lib (... if I'm remembering that correctly).

    That having been said, I'm not convinced that sharing application singletons between multiple webapps is good design.