Issue while configuring Log4j2 in JBoss EAP 6.4 domain mode

Posted on

I am trying to integrate log4j2, with our web module but unfortunately, I am getting a lot of issues. I am trying to configure this in a domain mode and the log is from one of a host cost controller.

I have tried various ways to fix this issue but nothing works. Looked at the below forum answer, seems it's not working for me. I will appreciate if someone helps me to fix this issue or point out a solution.
https://developer.jboss.org/thread/239572?db=5

WAR/WEB-INF/jboss-deployment-structure.xml

<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">
    <deployment>
        <dependencies>
            <module name="att.opus" />
            <module name="org.apache.log4j2.core" />
            <module name="org.apache.log4j2" />
           <!--
                     <module name="org.apache.log4j2.jcl" />
                     <module name="org.apache.log4j2.fromlog4j" />
            -->
        </dependencies>
        <exclusions>
            <module name="org.jboss.logging"/>
            <module name="org.apache.log4j" />
            <module name="org.slf4j" />
        </exclusions>
     </deployment>
</jboss-deployment-structure>

modules\system\layers\base\org\apache\log4j2\core\main\module.xml
~~~


modules\system\layers\base\org\apache\log4j2\main\module.xml ~~~ <module xmlns="urn:jboss:module:1.1" name="org.apache.log4j2"> <resources> <resource-root path="log4j-api-2.7.jar"/> </resources> <dependencies> <module name="org.apache.log4j2.core"> <imports> <include path="META-INF"/> </imports> </module> </dependencies> </module>

modules\system\layers\base\org\apache\log4j2\jcl\main\module.xml

<module xmlns="urn:jboss:module:1.1" name="org.apache.log4j2.jcl">
    <resources>
        <resource-root path="log4j-jcl-2.7.jar"/>
    </resources>
    <dependencies>
        <module name="org.apache.log4j2"/>
        <module name="org.apache.log4j2.core">  
            <imports>
                <include path="META-INF"/>  
            </imports>  
        </module>
        <module name="org.apache.log4j2.fromlog4j"/>
        <module name="org.apache.commons.logging.opus" />
    </dependencies>
</module>

modules\system\layers\base\org\apache\log4j2\fromlog4j\main\module.xml

<module xmlns="urn:jboss:module:1.1" name="org.apache.log4j2.fromlog4j">
    <resources>
        <resource-root path="log4j-1.2-api-2.7.jar"/>
    </resources>
    <dependencies>
        <module name="org.apache.log4j2"/>
        <module name="org.apache.log4j2.jcl"/>
    </dependencies>
</module>

Exceptions in log

[Server:fe-mgd-server-2] [33m [0m [0m18:02:29,322 INFO [org.jboss.web] (ServerService Thread Pool -- 76) JBAS018210: Register web context: /opus [0m
[Server:fe-mgd-server-2] [0m [31m18:02:29,472 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/opus]] (ServerService Thread Pool -- 76) JBWEB000285: Error configuring application listener of class poslite.framework.OPUSHttpSessionEventHandler: java.lang.IllegalAccessError: tried to access method org.apache.logging.log4j.ThreadContext.getThreadContextMap()Lorg/apache/logging/log4j/spi/ThreadContextMap; from class org.apache.logging.log4j.ThreadContextAccess [0m
[Server:fe-mgd-server-2] [31m at org.apache.logging.log4j.ThreadContextAccess.getThreadContextMap(ThreadContextAccess.java:45) [log4j-core-2.7.jar:2.7] [0m
[Server:fe-mgd-server-2] [31m at org.apache.logging.log4j.core.impl.ContextDataInjectorFactory.createDefaultInjector(ContextDataInjectorFactory.java:83) [log4j-core-2.7.jar:2.7] [0m
[Server:fe-mgd-server-2] [31m at org.apache.logging.log4j.core.impl.ContextDataInjectorFactory.createInjector(ContextDataInjectorFactory.java:67) [log4j-core-2.7.jar:2.7] [0m
[Server:fe-mgd-server-2] [31m at org.apache.logging.log4j.core.lookup.ContextMapLookup.(ContextMapLookup.java:34) [log4j-core-2.7.jar:2.7] [0m
[Server:fe-mgd-server-2] [31m at org.apache.logging.log4j.core.lookup.Interpolator.(Interpolator.java:116) [log4j-core-2.7.jar:2.7] [0m
[Server:fe-mgd-server-2] [31m at org.apache.logging.log4j.core.config.AbstractConfiguration.(AbstractConfiguration.java:120) [log4j-core-2.7.jar:2.7] [0m
[Server:fe-mgd-server-2] [31m at org.apache.logging.log4j.core.config.NullConfiguration.(NullConfiguration.java:32) [log4j-core-2.7.jar:2.7] [0m
[Server:fe-mgd-server-2] [31m at org.apache.logging.log4j.core.LoggerContext.(LoggerContext.java:72) [log4j-core-2.7.jar:2.7] [0m
[Server:fe-mgd-server-2] [31m at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.createContext(ClassLoaderContextSelector.java:171) [log4j-core-2.7.jar:2.7] [0m
[Server:fe-mgd-server-2] [31m at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.locateContext(ClassLoaderContextSelector.java:145) [log4j-core-2.7.jar:2.7] [0m
[Server:fe-mgd-server-2] [31m at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:70) [log4j-core-2.7.jar:2.7] [0m
[Server:fe-mgd-server-2] [31m at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:57) [log4j-core-2.7.jar:2.7] [0m
[Server:fe-mgd-server-2] [31m at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:147) [log4j-core-2.7.jar:2.7] [0m
[Server:fe-mgd-server-2] [31m at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:45) [log4j-core-2.7.jar:2.7] [0m
[Server:fe-mgd-server-2] [31m at org.apache.logging.log4j.LogManager.getContext(LogManager.java:194) [log4j-api-2.7.jar:2.7] [0m
[Server:fe-mgd-server-2] [31m at org.apache.logging.log4j.spi.AbstractLoggerAdapter.getContext(AbstractLoggerAdapter.java:103) [log4j-api-2.7.jar:2.7] [0m
[Server:fe-mgd-server-2] [31m at org.apache.logging.log4j.jcl.LogAdapter.getContext(LogAdapter.java:39) [log4j-jcl-2.7.jar:2.7] [0m
[Server:fe-mgd-server-2] [31m at org.apache.logging.log4j.spi.AbstractLoggerAdapter.getLogger(AbstractLoggerAdapter.java:42) [log4j-api-2.7.jar:2.7] [0m
[Server:fe-mgd-server-2] [31m at org.apache.logging.log4j.jcl.LogFactoryImpl.getInstance(LogFactoryImpl.java:40) [log4j-jcl-2.7.jar:2.7] [0m
[Server:fe-mgd-server-2] [31m at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:669) [commons-logging-1.2.jar:1.2] [0m
[Server:fe-mgd-server-2] [31m at poslite.framework.OPUSHttpSessionEventHandler.(OPUSHttpSessionEventHandler.java:53) [classes:] [0m
[Server:fe-mgd-server-2] [31m at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) [rt.jar:1.7.0_99] [0m
[Server:fe-mgd-server-2] [31m at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) [rt.jar:1.7.0_99] [0m
[Server:fe-mgd-server-2] [31m at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) [rt.jar:1.7.0_99] [0m
[Server:fe-mgd-server-2] [31m at java.lang.reflect.Constructor.newInstance(Constructor.java:526) [rt.jar:1.7.0_99] [0m
[Server:fe-mgd-server-2] [31m at org.jboss.msc.value.ConstructedValue.getValue(ConstructedValue.java:61) [0m

[Server:fe-mgd-server-2] [31mCaused by: java.lang.NoClassDefFoundError: Could not initialize class org.apache.logging.log4j.core.LoggerContext [0m
[Server:fe-mgd-server-2] [31m at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.createContext(ClassLoaderContextSelector.java:171) [log4j-core-2.7.jar:2.7] [0m
[Server:fe-mgd-server-2] [31m at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.locateContext(ClassLoaderContextSelector.java:145) [log4j-core-2.7.jar:2.7] [0m
[Server:fe-mgd-server-2] [31m at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:74) [log4j-core-2.7.jar:2.7] [0m
[Server:fe-mgd-server-2] [31m at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:57) [log4j-core-2.7.jar:2.7] [0m
[Server:fe-mgd-server-2] [31m at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:147) [log4j-core-2.7.jar:2.7] [0m
[Server:fe-mgd-server-2] [31m at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:45) [log4j-core-2.7.jar:2.7] [0m
[Server:fe-mgd-server-2] [31m at org.apache.logging.log4j.LogManager.getContext(LogManager.java:307) [log4j-api-2.7.jar:2.7] [0m
[Server:fe-mgd-server-2] [31m at org.apache.log4j.Logger$PrivateManager.getContext(Logger.java:59) [log4j-1.2-api-2.7.jar:2.7] [0m
[Server:fe-mgd-server-2] [31m at org.apache.log4j.Logger.getLogger(Logger.java:41) [log4j-1.2-api-2.7.jar:2.7] [0m
[Server:fe-mgd-server-2] [31m at poslite.servlet.POSServletContextAttributeListener.(POSServletContextAttributeListener.java:12) [classes:] [0m
[Server:fe-mgd-server-2] [31m ... 32 more [0m

Responses