dipakmak / jmx-logger

Automatically exported from code.google.com/p/jmx-logger
0 stars 0 forks source link

Using jmxlogger in JBoss 4.2.3 results in error #7

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?

1. Changed <jboss.home>/server/default/conf/jboss-log4j.xml to use the new
JMXLogger appender.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"
    debug="false">
    <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
        <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler" />
        <param name="Target" value="System.out" />
        <param name="Threshold" value="DEBUG" />
        <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="%d{ISO8601} %-5p [%c{4}] - %m%n" />
        </layout>
    </appender>
    <appender name="FILE"
        class="org.jboss.logging.appender.DailyRollingFileAppender">
        <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler" />
        <param name="File" value="${jboss.server.log.dir}/server.log" />
        <param name="Append" value="true" />
        <param name="Threshold" value="DEBUG" />
        <param name="DatePattern" value="'.'yyyy-MM-dd" />
        <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="%d{ISO8601} %-5p [%c{4}] - %m%n" />
        </layout>
    </appender>
    <appender name="JMX" class="jmxlogger.integration.log4j.JmxLogAppender">
        <param name="ObjectName" value="jmxlogger.log4j:type=Log4jAppender" />
        <param name="ServerSelection" value="platform" />
        <param name="LogPattern" value="Exception" />
        <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="%d{ISO8601} %-5p [%c{2}:%L] -
%m%n" />
        </layout>
    </appender>
    <category name="com.arjuna">
        <priority value="INFO" />
    </category>
    <category name="jacorb">
        <priority value="WARN" />
    </category>
    <category name="javax.enterprise.resource.webcontainer.jsf">
        <priority value="INFO" />
    </category>
    <category name="org.apache">
        <priority value="INFO" />
    </category>
    <category name="org.apache.axis">
        <priority value="INFO" />
    </category>
    <category name="org.hibernate">
        <priority value="INFO" />
    </category>
    <category name="org.jboss">
        <priority value="INFO" />
    </category>
    <category name="org.jboss.mq">
        <priority value="INFO" />
    </category>
    <category name="org.jboss.management">
        <priority value="INFO" />
    </category>
    <category name="org.jboss.serial">
        <priority value="INFO" />
    </category>
    <category name="org.jgroups">
        <priority value="WARN" />
    </category>
    <category name="org.quartz">
        <priority value="INFO" />
    </category>
    <root>
        <priority value="DEBUG" />
        <appender-ref ref="CONSOLE" />
        <appender-ref ref="FILE" />
        <appender-ref ref="JMX" />
    </root>
</log4j:configuration>

2. Made sure the correct version of log4j is being used (See issue 3 that
was closed)

   i.e. Replaced <jboss.home>server/default/lib/log4j.jar with log4j-1.2.15.jar

What is the expected output?

JMX logging to the JConsole

What do you see instead?

An error on startup of jboss:

2009-10-23 16:30:56,785 WARN  [org.jboss.system.ServiceController] -
Problem starting service jboss:service=NamingBeanImpl
java.lang.NoSuchMethodError: org.apache.log4j.spi.LoggingEvent.getTimeStamp()J
    at jmxlogger.integration.log4j.JmxLogAppender.prepareLogEvent(Unknown Source)
    at jmxlogger.integration.log4j.JmxLogAppender.append(Unknown Source)
    at org.apache.log4j.AppenderSkeleton.doAppend(AppenderSkeleton.java:230)
    at
org.apache.log4j.helpers.AppenderAttachableImpl.appendLoopOnAppenders(AppenderAt
tachableImpl.java:65)
    at org.apache.log4j.Category.callAppenders(Category.java:203)
    at org.apache.log4j.Category.forcedLog(Category.java:388)
    at org.apache.log4j.Category.log(Category.java:853)
    at org.jboss.logging.Log4jLoggerPlugin.debug(Log4jLoggerPlugin.java:129)
    at org.jboss.logging.Logger.debug(Logger.java:160)
    at org.jnp.server.NamingBeanImpl.start(NamingBeanImpl.java:110)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.jav
a:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at
org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155
)
    at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
    at
org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133
)
    at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
    at
org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperati
onInterceptor.java:142)
    at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
    at
org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
    at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
    at
org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:99
5)
    at $Proxy0.start(Unknown Source)
    at org.jboss.system.ServiceController.start(ServiceController.java:417)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.jav
a:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at
org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155
)
    at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
    at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
    at
org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
    at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
    at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
    at $Proxy4.start(Unknown Source)
    at org.jboss.deployment.SARDeployer.start(SARDeployer.java:304)
    at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1025)
    at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:819)
    at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:782)
    at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:766)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.jav
a:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at
org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155
)
    at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
    at
org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133
)
    at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
    at
org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperati
onInterceptor.java:142)
    at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
    at
org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
    at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
    at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
    at $Proxy5.deploy(Unknown Source)
    at org.jboss.system.server.ServerImpl.doStart(ServerImpl.java:482)
    at org.jboss.system.server.ServerImpl.start(ServerImpl.java:362)
    at org.jboss.Main.boot(Main.java:200)
    at org.jboss.Main$1.run(Main.java:508)
    at java.lang.Thread.run(Thread.java:619)
2009-10-23 16:30:57,051 ERROR [org.jboss.deployment.MainDeployer] - Could
not start deployment:
file:/C:/opt/jboss-4.2.3/server/default/conf/jboss-service.xml
java.lang.NoSuchMethodError: org.apache.log4j.spi.LoggingEvent.getTimeStamp()J
    at jmxlogger.integration.log4j.JmxLogAppender.prepareLogEvent(Unknown Source)
    at jmxlogger.integration.log4j.JmxLogAppender.append(Unknown Source)
    at org.apache.log4j.AppenderSkeleton.doAppend(AppenderSkeleton.java:230)
    at
org.apache.log4j.helpers.AppenderAttachableImpl.appendLoopOnAppenders(AppenderAt
tachableImpl.java:65)
    at org.apache.log4j.Category.callAppenders(Category.java:203)
    at org.apache.log4j.Category.forcedLog(Category.java:388)
    at org.apache.log4j.Category.log(Category.java:853)
    at org.jboss.logging.Log4jLoggerPlugin.warn(Log4jLoggerPlugin.java:188)
    at org.jboss.logging.Logger.warn(Logger.java:216)
    at org.jboss.system.ServiceController.start(ServiceController.java:424)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.jav
a:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at
org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155
)
    at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
    at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
    at
org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
    at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
    at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
    at $Proxy4.start(Unknown Source)
    at org.jboss.deployment.SARDeployer.start(SARDeployer.java:304)
    at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1025)
    at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:819)
    at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:782)
    at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:766)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.jav
a:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at
org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155
)
    at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
    at
org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133
)
    at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
    at
org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperati
onInterceptor.java:142)
    at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
    at
org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
    at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
    at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
    at $Proxy5.deploy(Unknown Source)
    at org.jboss.system.server.ServerImpl.doStart(ServerImpl.java:482)
    at org.jboss.system.server.ServerImpl.start(ServerImpl.java:362)
    at org.jboss.Main.boot(Main.java:200)
    at org.jboss.Main$1.run(Main.java:508)
    at java.lang.Thread.run(Thread.java:619)
2009-10-23 16:30:57,442 ERROR [STDERR] - Failed to boot JBoss:
2009-10-23 16:30:57,442 INFO  [jboss.system.server.Server] [] - Runtime
shutdown hook called, forceHalt: true
2009-10-23 16:30:57,442 ERROR [STDERR] - Exception in thread "JBoss
Shutdown Hook" 

What version of the product are you using? On what operating system?

jmxlogger-0.1.0.jar
log4j-1.2.15.jar
JBoss-4.2.3-GA
Windows XP

Please provide any additional information below.

The log4j-boot.jar in <jboss.home>/lib folder contains a subset of log4j
classes from an older version of log4j. It's LoggingEvent.class does not
implement the getTimestamp() method.
Even though the log4j.jar in <jboss.home>/server/default/lib has been
replaced with the correct version of log4j the log4j-boot.jar is being
loaded first by the classloader that is configuring log4j using the
jboss-log4j.xml file
How would I remedy this? Rebuild JBoss from the source and have it use
log4j-1.2.15.jar? Is this even possible?

Original issue reported on code.google.com by bergman...@gmail.com on 23 Oct 2009 at 2:40

GoogleCodeExporter commented 8 years ago
Alas! Log4j is has always been an issue with 4.x version of JBoss.  As of today,
JmxLogger supports log4j ver 1.2.15.  I am not familiar with the detail of how 
JBoss
loads/uses log4j internally.  

One way to solve this (if you have access to the app server component's code), 
is to
force JBoss to load your component's lib in its own class space.  To do this, 
update
your jboss-service.xml file, in your WEB-INF/ dir for instance, and add the 
following
line 

<loader-repository>your.own.jmx.domain:a_key=value,to=distinguish,the=loader</lo
ader-repository>

inside the <server/> section of the file.  Redeploy component.

This should allow you to use the version of log4J that you want.

Original comment by vladimir...@gmail.com on 8 Dec 2009 at 6:14