2 Replies Latest reply on Sep 8, 2014 1:42 AM by jaikiran pai

    @WebListener not detected in ear with skinny wars

    Chris Slater Newbie

      I'm trying to switch a project from Glassfish to Wildfy and am having a problem with a @WebListener annotated HttpSessionListener not being detected. The HttpSessionListener lives in a dependency jar.  Originally, this jar lived in the lib directory of of the ear, which was detected fine by Glassfish, but is only detected by Wildfly if I move it to the jar to WEB-INF/lib dir in the war.  I am using the maven ear plug in with the <skinnyWars>true</skinnyWars> option.  I would like to keep skinny wars to avoid dependency duplication across my project

       

      Is there some setting I can change to make this work?  Is this a bug?

       

       

      Again:

       

      This works with Glassfish <skinnyWars>true</skinnyWars>

      MyApp.ear

      -- MyWar.war

      ----- WEB-INF

      -------- lib

      -- MyEJB.jar

      -- lib

      ----- DependencyJar.jar

      -------- HttpSessionListener.class (WebListener Annotated)

       

       

      This is what I have to do for Wildfly <skinnyWars>false</skinnyWars>

      MyApp.ear

      -- MyWar.war

      ----- WEB-INF

      -------- lib

      ----------- DependencyJar.jar

      -------------- HttpSessionListener.class (WebListener Annotated)

      -- MyEJB.jar

      -- lib

      ----- DependencyJar.jar

      -------- HttpSessionListener.class (WebListener Annotated)

        • 1. Re: @WebListener not detected in ear with skinny wars
          jaikiran pai Master

          What WildFly does is the correct way as mandated by the Servlet 3 spec which states:

           

          11.3.1 Provision of Listener Classes

           

          The Developer of the Web application provides listener classes implementing one or

          more of the listener interfaces in the javax.servlet API. Each listener class must

          have a public constructor taking no arguments. The listener classes are packaged

          into the WAR, either under the WEB-INF/classes archive entry, or inside a JAR in

          the WEB-INF/lib directory.

          • 2. Re: @WebListener not detected in ear with skinny wars
            jaikiran pai Master

            I would like to keep skinny wars to avoid dependency duplication across my project

            You can still avoid the duplication. Just move the webapp specific components like the listener class to a jar within the .war/lib folder (or even .war/WEB-INF/classes) and you have the really shared classes across the application modules within the .ear/lib jars.

            1 of 1 people found this helpful