1 Reply Latest reply on Dec 7, 2014 12:58 AM by jaikiran pai

    how a webapp can have same classloader as an extension?

    mazz Master

      OK, this is going to sound a little weird, but work with me

       

      Suppose I have a Wildfly module extension - deployed in modules/system/layers/base/blahblah and my service all works well.

       

      But now suppose I want a web front end to it. Let's say it is a very simple war - a single servlet, maybe some supporting classes. The servlet and many of its supporting libs/classes (let's say all) are in jars that are in the module extension already. So really, my war just needs to specify a dependency on my module extension (via jboss-deployment-structure.xml).

       

      In fact, to deploy the WAR, my service can do it. I don't need to put the WAR independently in the deployment/ directory; my service extension can add a deploy step during its own initialiation to deploy the war. So even the WAR is inside the service (the web.xml and all is inside modules/system/layers/base/blahblah/main/resources/my.war).

       

      The problem is I believe the WAR will have its own classloader. However, I want the WAR to share the same classloader as the service extension (because, for example, perhaps the service creates some singleton in some third-party lib which I have no control over, but which the WAR needs access to that singleton instance).

       

      Is there anyway to have such a WAR dependency where the WAR can share the classloader of one of its dependencies?

       

      Is there *any* way to do such a thing?