10 Replies Latest reply on Apr 25, 2014 6:15 AM by androidgalaxyman

    jboss eap 6.1 does loads load log4j , my application not finds that anyway

    androidgalaxyman

      Hi ,

       

      we are having connectivity application bundled as EAR. Inside that we are having RAR package, which consists of plugins for the communication. This application designed were in the use of jboss 4.2.3. These plugins are loads the  LOG4J mechanism .The problems not been appeared in jboss 4.2.3 Or jboss 5.1.0. Now we are migrating the application to jboss eap 6.1 . There we are having NPE , when the application (plugins)  tries to load the log4j independently. From the jboss eap 6.1 documentation , i have studied we need to change the MANIFEST.MF , with an attribute

      Dependencies : org.apache.log4j
      
      

      But i have tried , i couldn't load the log4j ends up with NPE. Can please anyone suggest?

       

      My App Architecture :

       

      ->Ear

              -> META-INF-> MANIFEST.MF (not changed here)

              -> EJB1.jar

              -> lib

             -> plugin.rar ->

                                ->META-INF(not changed here)

                                 -> test.plugin.jar ->

                                                            ->META-INF -> MANIFEST.MF(changed here)

                                       

       

      https://docs.jboss.org/author/display/AS7/Developer+Guide#DeveloperGuide-%26nbsp%3Bjbossdeploymentstructure.xml

      http://www.mastertheboss.com/jboss-as-7/jboss-as-7-classloading/page-3

      https://docs.jboss.org/author/display/AS72/Class+Loading+in+AS7

      https://access.redhat.com/site/documentation/en-US/JBoss_Enterprise_Application_Platform/6.1/pdf/Migration_Guide/JBoss_Enterprise_Application_Platform-6.1-Migration_Guide-en-US.pdf

       

      Code Looks like,

      ##############

       

      private static boolean isLog4jConfigured() {
              Enumeration appenders = Logger.getRootLogger().getAllAppenders();
              if (appenders.hasMoreElements()) {
                  return true;
              } else {
                  Enumeration loggers = LogManager.getCurrentLoggers();
                  while (loggers.hasMoreElements()) {
                      Logger c = (Logger) loggers.nextElement();
                      if (c.getAllAppenders().hasMoreElements())
                          return true;
                  }
              }
              return false;
          }
      
      

       

       

      Error :

      #####

       

      13:37:01,939 INFO  [org.jboss.as.messaging] (ServerService Thread Pool -- 61) JBAS011601: Bound messaging object to jndi name java:jboss/exported/jms/RemoteConnectionFactory

      13:37:01,956 ERROR [stderr] (MSC service thread 1-9) java.lang.NullPointerException

      13:37:01,956 ERROR [stderr] (MSC service thread 1-9)    at com.xxxx.tocf.common.CommonTrace.loadConfigurationFile(CommonTrace.java:212)

      13:37:01,957 ERROR [stderr] (MSC service thread 1-9)    at com.xxxx.tocf.common.CommonTrace.<clinit>(CommonTrace.java:130)

      13:37:01,957 ERROR [stderr] (MSC service thread 1-9)    at com.xxxx.tocf.tcs.plugin.PluginList.Reset(PluginList.java:28)

      13:37:01,958 ERROR [stderr] (MSC service thread 1-9)    at com.xxxx.tocf.plugin.jca.PluginResourceAdapter.start(PluginResourceAdapter.java:85)

      13:37:01,959 ERROR [stderr] (MSC service thread 1-9)    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

      13:37:01,959 ERROR [stderr] (MSC service thread 1-9)    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

      13:37:01,960 ERROR [stderr] (MSC service thread 1-9)    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

      13:37:01,961 ERROR [stderr] (MSC service thread 1-9)    at java.lang.reflect.Method.invoke(Method.java:597)

      13:37:01,961 ERROR [stderr] (MSC service thread 1-9)    at org.jboss.jca.deployers.common.AbstractResourceAdapterDeployer.startContext(AbstractResourceAdapterDeployer.java:350)

      13:37:01,962 ERROR [stderr] (MSC service thread 1-9)    at org.jboss.jca.deployers.common.AbstractResourceAdapterDeployer.createObjectsAndInjectValue(AbstractResourceAdapterDeployer.java:2408)

      13:37:01,962 ERROR [stderr] (MSC service thread 1-9)    at org.jboss.jca.deployers.common.AbstractResourceAdapterDeployer.createObjectsAndInjectValue(AbstractResourceAdapterDeployer.java:1104)

      13:37:01,963 ERROR [stderr] (MSC service thread 1-9)    at org.jboss.as.connector.services.resourceadapters.deployment.ResourceAdapterDeploymentService$AS7RaDeployer.doDeploy(ResourceAdapterDeploymen

      13:37:01,963 ERROR [stderr] (MSC service thread 1-9)    at org.jboss.as.connector.services.resourceadapters.deployment.ResourceAdapterDeploymentService.start(ResourceAdapterDeploymentService.java:112

      13:37:01,964 ERROR [stderr] (MSC service thread 1-9)    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)

      13:37:01,965 ERROR [stderr] (MSC service thread 1-9)    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)

      13:37:01,966 ERROR [stderr] (MSC service thread 1-9)    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)

      13:37:01,966 INFO  [org.jboss.as.ejb3] (MSC service thread 1-3) JBAS014142: Started message driven bean 'DeliveryMDB' with 'tocfT24ra-ra' resource adapter

      13:37:01,966 INFO  [org.jboss.as.ejb3] (MSC service thread 1-12) JBAS014142: Started message driven bean 'OFSMessageMDB' with 'hornetq-ra' resource adapter

      13:37:01,966 ERROR [stderr] (MSC service thread 1-9)    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)

      13:37:01,968 ERROR [stderr] (MSC service thread 1-9)    at java.lang.Thread.run(Thread.java:662)

      13:37:01,973 WARN  [common] (MSC service thread 1-9) TC Trace initialization: : java.lang.Exception: Log4j configuration has not been found

              at com.xx.tocf.common.CommonTrace.loadConfigurationFile(CommonTrace.java:209) [tcommon.jar:common_R10.0.4_GA]

              at com.xx.tocf.tcs.trace.TCSTrace.<clinit>(TCSTrace.java:26) [tcserver.jar:]

              at com.xx.tocf.tcs.plugin.PluginList.Reset(PluginList.java:28) [tcserver.jar:]

              at com.xx.tocf.plugin.jca.PluginResourceAdapter.start(PluginResourceAdapter.java:85) [tocfplugin.jar:]

              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.6.0_22]

              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [rt.jar:1.6.0_22]

              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [rt.jar:1.6.0_22]

              at java.lang.reflect.Method.invoke(Method.java:597) [rt.jar:1.6.0_22]

              at org.jboss.jca.deployers.common.AbstractResourceAdapterDeployer.startContext(AbstractResourceAdapterDeployer.java:350) [ironjacamar-deployers-common-1.0.15.Final.jar:1.0.15.Final]

              at org.jboss.jca.deployers.common.AbstractResourceAdapterDeployer.createObjectsAndInjectValue(AbstractResourceAdapterDeployer.java:2408) [ironjacamar-deployers-common-1.0.15.Final.jar:1.0.15.Final]

              at org.jboss.jca.deployers.common.AbstractResourceAdapterDeployer.createObjectsAndInjectValue(AbstractResourceAdapterDeployer.java:1104) [ironjacamar-deployers-common-1.0.15.Final.jar:1.0.15.Final]

              at org.jboss.as.connector.services.resourceadapters.deployment.ResourceAdapterDeploymentService$AS7RaDeployer.doDeploy(ResourceAdapterDeploymentService.java:197)

              at org.jboss.as.connector.services.resourceadapters.deployment.ResourceAdapterDeploymentService.start(ResourceAdapterDeploymentService.java:112)

              at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)

              at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)

              at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [rt.jar:1.6.0_22]

              at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [rt.jar:1.6.0_22]

              at java.lang.Thread.run(Thread.java:662) [rt.jar:1.6.0_22]

       

       

       

       

       

       

       

       

      13:37:01,976 INFO  [com.jbase.jremote.jca.inflow.JRemoteActivationSpec] (ServerService Thread Pool -- 61) Validated JRemoteActivationSpec:

              handler = [DELIVERY]

      13:37:01,984 INFO  [com.xx.tocf.t24ra.T24ResourceAdapter] (ServerService Thread Pool -- 61) endPointActivation: org.jboss.as.ejb3.inflow.JBossMessageEndpointFactory@11ef9f6,com.jbase.jremote.jca.inflow.JRemoteActivationSpec@acc399

      13:37:01,993 INFO  [tcs] (MSC service thread 1-9) appender [formatter]

      13:37:01,994 INFO  [tcs] (MSC service thread 1-9) PluginLoaded [appenderformatter.jar]

      13:37:01,995 INFO  [tcs] (MSC service thread 1-9) atmlistener [listener]

      13:37:01,995 INFO  [tcs] (MSC service thread 1-9) PluginLoaded [atmlistener.jar]

        • 1. Re: jboss eap 6.1 does loads load log4j , my application not finds that anyway
          lafr

          There is no need to add dependency to org.apache.log4j.

          See chapter 3.1.4.2 in the EAP pdf mentioned above.

           

          And I not see the relationship to log4j. What's happening where the NPE occurs?

          13:37:01,956 ERROR [stderr] (MSC service thread 1-9) java.lang.NullPointerException

          13:37:01,956 ERROR [stderr] (MSC service thread 1-9)    at com.temenos.tocf.common.CommonTrace.loadConfigurationFile(CommonTrace.java:212)

          • 2. Re: Re: jboss eap 6.1 does loads load log4j , my application not finds that anyway
            androidgalaxyman

            Hi Frank,

             

            sorry for the delayed reply. We are having the application , which checks for log 4j initialization. I tried with your suggestion on changing manifest , the NPE occurs when my application checks for log 4j. The same application behaves correctly without NPE in jboss 4.x, 5.1,6.1 . only the 6.1 EAP says NPE . so that i digged it further, actually jboss 4.2 ,5.1,6.1 loads the root-logger as expected. on EAP 6.1 when app server trying to check for root logger , there is no appender getting added. The code Enumeration appenders = Logger.getRootLogger().getAllAppenders(); the code returns NullEnumeration. i suspect the jboss whether loads the configuration for root-logger. can you please let me know , if you know anything?

             

             

             

             

             <subsystem xmlns="urn:jboss:domain:logging:1.2">
                        <console-handler name="CONSOLE">
                            <level name="INFO"/>
                            <formatter>
                                <pattern-formatter pattern="%K{level}%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/>
                            </formatter>
                        </console-handler>
                        <size-rotating-file-handler name="SIZROTFILE" autoflush="true">
                            <formatter>
                                <pattern-formatter pattern="%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/>
                            </formatter>
                            <file relative-to="jboss.server.log.dir" path="size_handler_server.log"/>
                            <rotate-size value="1M"/>
                            <max-backup-index value="100"/>
                            <append value="false"/>
                        </size-rotating-file-handler>
                        <logger category="com.arjuna">
                            <level name="WARN"/>
                        </logger>
                        <logger category="org.apache.tomcat.util.modeler">
                            <level name="WARN"/>
                        </logger>
                        <logger category="org.jboss.as.config">
                            <level name="DEBUG"/>
                        </logger>
                        <logger category="sun.rmi">
                            <level name="WARN"/>
                        </logger>
                        <logger category="jacorb">
                            <level name="WARN"/>
                        </logger>
                        <logger category="jacorb.config">
                            <level name="ERROR"/>
                        </logger>
                        <logger category="org.jboss.msc.service">
                            <level name="INFO"/>
                        </logger>
                        <root-logger>
                            <level name="INFO"/>
                            <handlers>
                                <handler name="CONSOLE"/>
                                <handler name="SIZROTFILE"/>
                            </handlers>
                        </root-logger>
                    </subsystem>
            

             

             

            private static boolean isLog4jConfigured() {
                    Enumeration appenders = Logger.getRootLogger().getAllAppenders();
                    if (appenders.hasMoreElements()) {
                        return true;
                    } else {
                        Enumeration loggers = LogManager.getCurrentLoggers();
                        while (loggers.hasMoreElements()) {
                            Logger c = (Logger) loggers.nextElement();
                            if (c.getAllAppenders().hasMoreElements())
                                return true;
                        }
                    }
                    return false;
                }
            
            • 3. Re: jboss eap 6.1 does loads load log4j , my application not finds that anyway
              jamezp

              JBoss EAP 6.x does not use log4j as it's log manager which might explain what you're seeing. If you include a log4j configuration file in your deployment then the server will attempt to configure log4j for you.

               

              Since it seems like you're attempting to configure log4j in your application you might need to exclude log4j as a server dependency and include your own log4j library.

               

              Also see the logging documentation.

               

              --

              James R. Perkins

              • 4. Re: jboss eap 6.1 does loads load log4j , my application not finds that anyway
                androidgalaxyman

                Hi James,

                 

                Thanks for your kind reply. i tried with our suggestion, even that i got same exception

                 

                My package xxx.ear

                                    --> META-INF(application.xml ,jboss-app.xml,jboss-deployment-structure.xml,MANIFEST.MF)

                                    --> EJB_A.jar

                                    -->EJB _B.jar

                                    -->PLUGIN.rar (contains the application code ->Enumeration appenders = Logger.getRootLogger().getAllAppenders())

                                    --> lib (dependency jar , log4j-1.2.17.jar, log4j.xml)

                 

                jboss-deployment-structure.xml

                 

                <jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">

                    <!-- for top deployment, e.g. ear -->

                    <deployment>

                        <!-- Exclusions allow you to prevent the server from automatically adding some dependencies -->

                        <exclusions>

                            <module name="org.apache.log4j" />

                        </exclusions>

                    </deployment>

                 

                    <!-- for sub deployment, e.g. war. sub-deployment is required when ear contains one or more wars -->

                    <sub-deployment name="EJB_A.jar">

                        <exclusions>

                            <module name="org.apache.log4j" />

                        </exclusions>

                    </sub-deployment>

                    <sub-deployment name="EJB _B.jar">

                        <exclusions>

                            <module name="org.apache.log4j" />

                        </exclusions>

                    </sub-deployment>

                    <sub-deployment name="PLUGIN.rar">

                        <exclusions>

                            <module name="org.apache.log4j" />

                        </exclusions>

                    </sub-deployment>

                </jboss-deployment-structure>

                 

                log4j.xml

                ***********

                <?xml version="1.0" encoding="UTF-8" ?>

                <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">

                 

                 

                <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">

                 

                  <!--Appender -->

                  <appender name="Console" class="org.apache.log4j.ConsoleAppender">

                    <param name="Target" value="System.out"/>

                    <param name="Threshold" value="DEBUG"/>

                    <layout class="org.apache.log4j.PatternLayout">

                      <param name="ConversionPattern" value="%-5p %c{1} - %m%n"/>

                    </layout>

                  </appender>

                  <appender name="RollingFileApp" class="org.apache.log4j.RollingFileAppender">

                    <param name="File" value="${jboss.server.log.dir}\tocf_server.log"/>

                  <param name="Threshold" value="DEBUG"/>

                    <param name="Append" value="false"/>

                    <param name="MaxFileSize" value="100KB"/>

                    <!-- Keep one backup file -->

                    <param name="MaxBackupIndex" value="1"/>

                    <layout class="org.apache.log4j.PatternLayout">

                      <param name="ConversionPattern" value="%p %t %c - %m%n"/>

                    </layout>

                  </appender>

                  <!--Category-->

                  <category name="tcs">

                      <priority value="DEBUG"/>

                      <appender-ref ref="RollingFileApp"/>

                   </category>

                   <category name="ofs">

                      <priority value="DEBUG"/>

                      <appender-ref ref="RollingFileApp"/>

                   </category>

                   <category name="tcp">

                      <priority value="DEBUG"/>

                      <appender-ref ref="RollingFileApp"/>

                   </category>

                   <category name="common">

                      <priority value="DEBUG"/>

                      <appender-ref ref="RollingFileApp"/>

                   </category>

                   <category name="filelistener">

                      <priority value="DEBUG"/>

                      <appender-ref ref="RollingFileApp"/>

                   </category>

                  

                 

                 

                  <root>

                    <priority value ="INFO" />

                    <appender-ref ref="Console" />

                    <!--

                  <appender-ref ref="RollingFileApp" />

                  -->

                  </root>

                 

                </log4j:configuration>

                • 5. Re: Re: jboss eap 6.1 does loads load log4j , my application not finds that anyway
                  jamezp

                  It's possibly it's not finding your log4j.xml file. Maybe put the configuration file in your rar/META-INF/. Or you could add a line to include the lib as a root resource in your jboss-deployment-structure.xml.

                  
                    <resources>
                    <resource-root path="lib" />
                    </resources>
                  

                   

                  --

                  James R. Perkins

                  1 of 1 people found this helpful
                  • 6. Re: jboss eap 6.1 does loads load log4j , my application not finds that anyway
                    androidgalaxyman

                    Hi James,

                     

                    Thanks for your help.your suggestion -> Maybe put the configuration file in your rar/META-INF/ log4j.xml . worked. But newer problems is , i could n't able to see the logging trace of application level.

                     

                     

                    standalone-full.xml

                    *********************

                      <root-logger>
                                    <level name="INFO"/>
                                    <handlers>
                                        <handler name="CONSOLE"/>
                                        <handler name="PERROT"/>
                      <handler name="FILE"/>
                                    </handlers>
                                </root-logger>
                    

                     

                    jboss-logging.xml sample for jboss 6.1.0 Final

                    #######################################

                      <root-logger>

                                    <level name="DEBUG"/>

                                    <handlers>

                                        <handler name="CONSOLE"/>

                      <handler name="FILE"/>

                      </handlers>

                    </root-logger>

                     

                     

                    Sample output trace ,Like STANDARD OUT in jboss 6.1.0 Final

                     

                    013-03-14 11:44:03,527 INFO  [org.jboss.bootstrap.impl.base.server.AbstractServer] (Thread-2) JBossAS [6.1.0.Final "Neo"] Started in 17s:293ms

                    2013-03-14 11:44:03,902 INFO  [STDOUT] (pool-1-thread-4) 11:44:03,902 DEBUG [tcs] Out of the loop, status : 1

                    2013-03-14 11:44:03,902 INFO  [STDOUT] (pool-1-thread-4) 11:44:03,902 DEBUG [tcs] Out of the loop, status : 1

                    2013-03-14 11:44:03,902 INFO  [STDOUT] (pool-1-thread-4) 11:44:03,902 DEBUG [tcs]  New Listener : FileUploadDownloadChannel

                    2013-03-14 11:44:03,903 INFO  [STDOUT] (pool-1-thread-4) 11:44:03,902 DEBUG [tcs]  New Listener : FileUploadDownloadChannel

                    2013-03-14 11:44:03,903 INFO  [STDOUT] (pool-1-thread-4) 11:44:03,903 INFO  [tcs] FileUploadDownloadChannel/tcp/10003 /T24/

                    2013-03-14 11:44:03,903 INFO  [STDOUT] (pool-1-thread-4) 11:44:03,903 INFO  [tcs] FileUploadDownloadChannel/tcp/10003 /T24/

                    2013-03-14 11:44:03,903 INFO  [STDOUT] (pool-1-thread-4) 11:44:03,903 DEBUG [tcs] Register :

                    • 7. Re: jboss eap 6.1 does loads load log4j , my application not finds that anyway
                      jamezp

                      The log output you're showing looks like JBoss AS 6.x log output which is different than JBoss EAP 6.x.

                       

                      Either way if you want to see trace logging you have both a logger, whether it be specific or root, and the handler need to be set to allow trace messages through.

                       

                      --

                      James R. Perkins

                      • 8. Re: jboss eap 6.1 does loads load log4j , my application not finds that anyway
                        androidgalaxyman

                        Hi James,

                         

                        i am appreciating your extreme support. There is nothing specific changes in our application. as we deployed that ear component inside Jboss 4.2.3 , 5.1.0, 6.1.0 Final version, its smoothly emits logs out. Neither we did changes in jboss-log4j.xml or jboss-logging.xml . For my case all application server doesn't required any root or handler configuration related to  trace the STDOUT messages of application logging. i am puzzled out why my application needs root-logger / appender configuration in jboss EAP 6.1 Final. why it doesn't emits the STDOUT messages ? where they lost out?

                         

                        Thanks

                        • 9. Re: jboss eap 6.1 does loads load log4j , my application not finds that anyway
                          jamezp

                          JBoss EAP 6.x handles logging different than any previous versions of EAP or JBoss AS with the exception of JBoss AS 7.x. For EAP 6.x there is no jboss-log4j.xml or jboss-logging.xml. If however you have a jboss-log4j.xml file in your deployment EAP 6 will attempt to configure logging for your deployment. If you do not want that to happen you need to remove the file from your deployment or add the system property org.jboss.as.logging.per-deployment with a value of false.

                           

                          --

                          James R. Perkins

                          1 of 1 people found this helpful
                          • 10. Re: jboss eap 6.1 does loads load log4j , my application not finds that anyway
                            androidgalaxyman

                            Hi James,

                             

                            Thanks for your help. Finally i could able to log my application , with help of jboss-deployment-structure.xml. Apart from that , i didn't added anything. But one thing i found, i can't able to log anything when i use jBoss EAP 6.1 Alpha , even i configured jboss-deployment-structure.xml , but in jBoss EAP 6.1 Final is working fine ,once we add deployment structure xml file.

                             

                            <jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">

                                <!-- for top deployment, e.g. ear -->

                               

                              <deployment>

                                   <!-- Exclusions allow you to prevent the server from automatically adding some dependencies -->

                                  <exclusions>

                                        <module name="org.apache.log4j" />

                                    </exclusions>

                                </deployment>

                               

                                <!-- for sub deployment, e.g. war. sub-deployment is required when ear contains one or more wars -->

                                <sub-deployment name="xx-ejba.jar">

                                    <exclusions>

                                        <module name="org.apache.log4j" />

                                    </exclusions>

                                </sub-deployment>

                                <sub-deployment name="xx-ejb.jar">

                                    <exclusions>

                                        <module name="org.apache.log4j" />

                                    </exclusions>

                                </sub-deployment>

                                <sub-deployment name="xx.rar">

                                    <exclusions>

                                        <module name="org.apache.log4j" />

                                    </exclusions>

                                </sub-deployment>

                            </jboss-deployment-structure>