Log4j 2
  1. Log4j 2
  2. LOG4J2-359

Log4jServletContextListener does not work on Weblogic 12.1.1 (12c) with web-app version "2.5"

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0-beta8
    • Fix Version/s: 2.0-rc1
    • Component/s: None
    • Labels:
      None

      Description

      I have Weblogic 12c running. My web-app is version "2.5".

      Following is a snippet from my web.xml

      <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      	xmlns="http://java.sun.com/xml/ns/javaee"
      	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
      	id="WebApp_ID" version="2.5">
      	<display-name>pec-service</display-name>
      	<context-param>
      		<param-name>log4jConfiguration</param-name>
      		<param-value>file:/C:/log4j/dev.log4j.xml</param-value>
      	</context-param>
      
      	<listener> 
      		<listener-class>org.apache.logging.log4j.core.web.Log4jServletContextListener</listener-class> 
      	</listener>	
      
      	<filter>
      		<filter-name>log4jServletFilter</filter-name>
      		<filter-class>org.apache.logging.log4j.core.web.Log4jServletFilter</filter-class> 
      	</filter>
      	<filter-mapping>
      		<filter-name>log4jServletFilter</filter-name> 
      		<url-pattern>/*</url-pattern>
      		<dispatcher>REQUEST</dispatcher>
      		<dispatcher>FORWARD</dispatcher> 
      		<dispatcher>INCLUDE</dispatcher>
      		<dispatcher>ERROR</dispatcher>
      	</filter-mapping>
      	
      </web-app>
      

      However, on my server startup I am getting the following error -

      <Aug 16, 2013 3:12:32 PM PDT> <Warning> <HTTP> <BEA-101162> <User defined listener org.apache.logging.log4j.core.web.Log4jServletContextListener failed: java.lang.IllegalStateException: Context destroyed before it was initialized..
      java.lang.IllegalStateException: Context destroyed before it was initialized.
      	at org.apache.logging.log4j.core.web.Log4jServletContextListener.contextDestroyed(Log4jServletContextListener.java:51)
      	at weblogic.servlet.internal.EventsManager$FireContextListenerAction.run(EventsManager.java:583)
      	at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
      	at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
      	at weblogic.servlet.provider.WlsSubjectHandle.run(WlsSubjectHandle.java:57)
      	Truncated. see log file for complete stacktrace
      > 
      <Aug 16, 2013 3:12:32 PM PDT> <Error> <Deployer> <BEA-149265> <Failure occurred in the execution of deployment request with ID "1376691143681" for task "2". Error is: "weblogic.application.ModuleException"
      weblogic.application.ModuleException
      	at weblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.java:1708)
      	at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:781)
      	at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:213)
      	at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:208)
      	at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:35)
      	Truncated. see log file for complete stacktrace
      Caused By: java.lang.NullPointerException
      	at org.apache.logging.log4j.core.web.Log4jServletContainerInitializer.onStartup(Log4jServletContainerInitializer.java:44)
      	at weblogic.servlet.internal.WebAppServletContext.initContainerInitializer(WebAppServletContext.java:1271)
      	at weblogic.servlet.internal.WebAppServletContext.initContainerInitializers(WebAppServletContext.java:1229)
      	at weblogic.servlet.internal.WebAppServletContext.preloadResources(WebAppServletContext.java:1726)
      	at weblogic.servlet.internal.WebAppServletContext.start(WebAppServletContext.java:2740)
      	Truncated. see log file for complete stacktrace
      > 
      <Aug 16, 2013 3:12:32 PM PDT> <Error> <Deployer> <BEA-149202> <Encountered an exception while attempting to commit the 7 task for the application "_auto_generated_ear_".> 
      <Aug 16, 2013 3:12:32 PM PDT> <Warning> <Deployer> <BEA-149004> <Failures were detected while initiating start task for application "_auto_generated_ear_".> 
      <Aug 16, 2013 3:12:32 PM PDT> <Warning> <Deployer> <BEA-149078> <Stack trace for message 149004
      weblogic.application.ModuleException
      	at weblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.java:1708)
      	at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:781)
      	at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:213)
      	at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:208)
      	at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:35)
      	Truncated. see log file for complete stacktrace
      Caused By: java.lang.NullPointerException
      	at org.apache.logging.log4j.core.web.Log4jServletContainerInitializer.onStartup(Log4jServletContainerInitializer.java:44)
      	at weblogic.servlet.internal.WebAppServletContext.initContainerInitializer(WebAppServletContext.java:1271)
      	at weblogic.servlet.internal.WebAppServletContext.initContainerInitializers(WebAppServletContext.java:1229)
      	at weblogic.servlet.internal.WebAppServletContext.preloadResources(WebAppServletContext.java:1726)
      	at weblogic.servlet.internal.WebAppServletContext.start(WebAppServletContext.java:2740)
      	Truncated. see log file for complete stacktrace
      

      If I remove the listener & the filter, it works fine.


      I did some research and found that even though the web-app is version "2.5", the

      Log4jServletContainerInitializer
      is getting invoked.

      1. LOG4J2-359.patch
        3 kB
        Abhinav Shah
      2. Log4jServletContainerInitializerTest.java
        4 kB
        Abhinav Shah
      3. Log4jServletContainerInitializer.java
        2 kB
        Abhinav Shah

        Issue Links

          Activity

          Nick Williams made changes -
          Status In Progress [ 3 ] Resolved [ 5 ]
          Resolution Fixed [ 1 ]
          Nick Williams made changes -
          Status Reopened [ 4 ] In Progress [ 3 ]
          Matt Sicker made changes -
          Link This issue is related to LOG4J2-344 [ LOG4J2-344 ]
          Gary Gregory made changes -
          Fix Version/s 2.0-rc1 [ 12325011 ]
          Fix Version/s 2.0-beta9 [ 12324756 ]
          Francesco Chicchiriccò made changes -
          Link This issue relates to SYNCOPE-414 [ SYNCOPE-414 ]
          Abhinav Shah made changes -
          Resolution Fixed [ 1 ]
          Status Resolved [ 5 ] Reopened [ 4 ]
          Abhinav Shah made changes -
          Attachment LOG4J2-359.patch [ 12601406 ]
          Abhinav Shah made changes -
          Attachment LOG4J2-359.patch [ 12600905 ]
          Nick Williams made changes -
          Status In Progress [ 3 ] Resolved [ 5 ]
          Fix Version/s 2.0-beta9 [ 12324756 ]
          Resolution Fixed [ 1 ]
          Abhinav Shah made changes -
          Attachment LOG4J2-359.patch [ 12600905 ]
          Abhinav Shah made changes -
          Attachment LOG4J2-359.patch [ 12600892 ]
          Abhinav Shah made changes -
          Attachment LOG4J2-359.patch [ 12600892 ]
          Nick Williams made changes -
          Link This issue relates to LOG4J2-293 [ LOG4J2-293 ]
          Nick Williams made changes -
          Link This issue duplicates LOG4J2-293 [ LOG4J2-293 ]
          Nick Williams made changes -
          Status Reopened [ 4 ] In Progress [ 3 ]
          Nick Williams made changes -
          Resolution Duplicate [ 3 ]
          Status Resolved [ 5 ] Reopened [ 4 ]
          Nick Williams made changes -
          Comment [ Duplicate of LOG4J2-293. ]
          Nick Williams made changes -
          Status Open [ 1 ] Resolved [ 5 ]
          Resolution Duplicate [ 3 ]
          Nick Williams made changes -
          Link This issue duplicates LOG4J2-293 [ LOG4J2-293 ]
          Abhinav Shah made changes -
          Nick Williams made changes -
          Field Original Value New Value
          Assignee Nick Williams [ beamerblvd ]
          Abhinav Shah created issue -

            People

            • Assignee:
              Nick Williams
              Reporter:
              Abhinav Shah
            • Votes:
              3 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development