<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">
<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>
                                <td>
                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="http://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">JBoss Community</a></h1>
                                                                </td>
                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px; -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
JBoss logbridge NPE with java.util.logging.Logger.getAnonymousLogger()
</h3>
<span style="margin-bottom: 10px;">
created by <a href="http://community.jboss.org/people/michael.faber">Michael Faber</a> in <i>Beginner's Corner</i> - <a href="http://community.jboss.org/message/559724#559724">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">
<div class="jive-rendered-content"><p>Hi JBoss Community,</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>at the moment i am trying to migrate a project to the JBoss 5.1.0 server.</p><p>Doing this I ran into some problems with the jboss logbridge (org.jboss.logbridge.LogbridgeHandler), when an anonymous logger from the JUL framework is used.</p><p>Using an anonymous logger a NPE will occur in the initialization of the log4j logger when the publish() method of the LogBridgeHandler is used.</p><p>The stacktrace is:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p><code></p><p>Exception in thread "main" javax.ejb.EJBException: java.lang.NullPointerException<br/>    at org.jboss.ejb3.tx.Ejb3TxPolicy.handleExceptionInOurTx(Ejb3TxPolicy.java:77)<br/>    at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:83)<br/>    at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:190)<br/>    at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)<br/>    at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)<br/>    at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)<br/>    at org.jboss.ejb3.tx.NullInterceptor.invoke(NullInterceptor.java:42)<br/>    at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)<br/>    at org.jboss.ejb3.security.Ejb3AuthenticationInterceptorv2.invoke(Ejb3AuthenticationInterceptorv2.java:186)<br/>    at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)<br/>    at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:41)<br/>    at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)<br/>    at org.jboss.ejb3.BlockContainerShutdownInterceptor.invoke(BlockContainerShutdownInterceptor.java:67)<br/>    at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)<br/>    at org.jboss.aspects.currentinvocation.CurrentInvocationInterceptor.invoke(CurrentInvocationInterceptor.java:67)<br/>    at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)<br/>    at org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:421)<br/>    at org.jboss.ejb3.session.InvokableContextClassProxyHack._dynamicInvoke(InvokableContextClassProxyHack.java:53)<br/>    at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:91)<br/>    at org.jboss.aspects.remoting.AOPRemotingInvocationHandler.invoke(AOPRemotingInvocationHandler.java:82)<br/>    at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:891)<br/>    at org.jboss.remoting.transport.socket.ServerThread.completeInvocation(ServerThread.java:744)<br/>    at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:697)<br/>    at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:524)<br/>    at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:232)<br/>Caused by: java.lang.NullPointerException<br/>    at org.apache.log4j.CategoryKey.<init>(CategoryKey.java:31)<br/>    at org.apache.log4j.Hierarchy.getLogger(Hierarchy.java:261)<br/>    at org.apache.log4j.Hierarchy.getLogger(Hierarchy.java:242)<br/>    at org.apache.log4j.LogManager.getLogger(LogManager.java:188)<br/>    at org.apache.log4j.Logger.getLogger(Logger.java:104)<br/><strong>    at org.jboss.logbridge.LogBridgeHandler.publish(LogBridgeHandler.java:71)</strong><br/>    at java.util.logging.Logger.log(Logger.java:458)<br/>    at java.util.logging.Logger.doLog(Logger.java:480)<br/>    at java.util.logging.Logger.log(Logger.java:503)<br/>    at logbridge.test.LogbridgeTestCaseBean.logTest(LogbridgeTestCaseBean.java:24)<br/>    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)<br/>    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)<br/>    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)<br/>    at java.lang.reflect.Method.invoke(Method.java:597)<br/>    at org.jboss.aop.joinpoint.MethodInvocation.invokeTarget(MethodInvocation.java:122)<br/>    at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:111)<br/>    at org.jboss.ejb3.EJBContainerInvocationWrapper.invokeNext(EJBContainerInvocationWrapper.java:69)<br/>    at org.jboss.ejb3.interceptors.aop.InterceptorSequencer.invoke(InterceptorSequencer.java:73)<br/>    at org.jboss.ejb3.interceptors.aop.InterceptorSequencer.aroundInvoke(InterceptorSequencer.java:59)<br/>    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)<br/>    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)<br/>    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)<br/>    at java.lang.reflect.Method.invoke(Method.java:597)<br/>    at org.jboss.aop.advice.PerJoinpointAdvice.invoke(PerJoinpointAdvice.java:174)<br/>    at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)<br/>    at org.jboss.ejb3.interceptors.aop.InvocationContextInterceptor.fillMethod(InvocationContextInterceptor.java:72)<br/>    at org.jboss.aop.advice.org.jboss.ejb3.interceptors.aop.InvocationContextInterceptor_z_fillMethod_6971605.invoke(InvocationContextInterceptor_z_fillMethod_6971605.java)<br/>    at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)<br/>    at org.jboss.ejb3.interceptors.aop.InvocationContextInterceptor.setup(InvocationContextInterceptor.java:88)<br/>    at org.jboss.aop.advice.org.jboss.ejb3.interceptors.aop.InvocationContextInterceptor_z_setup_6971605.invoke(InvocationContextInterceptor_z_setup_6971605.java)<br/>    at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)<br/>    at org.jboss.ejb3.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:62)<br/>    at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)<br/>    at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:56)<br/>    at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)<br/>    at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)<br/>    at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)<br/>    at org.jboss.ejb3.tx.NullInterceptor.invoke(NullInterceptor.java:42)<br/>    at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)<br/>    at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:68)<br/>    at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)<br/>    at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79)<br/>    at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:190)<br/>    at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)<br/>    at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)<br/>    at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)<br/>    at org.jboss.ejb3.tx.NullInterceptor.invoke(NullInterceptor.java:42)<br/>    at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)<br/>    at org.jboss.ejb3.security.Ejb3AuthenticationInterceptorv2.invoke(Ejb3AuthenticationInterceptorv2.java:186)<br/>    at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)<br/>    at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:41)<br/>    at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)<br/>    at org.jboss.ejb3.BlockContainerShutdownInterceptor.invoke(BlockContainerShutdownInterceptor.java:67)<br/>    at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)<br/>    at org.jboss.aspects.currentinvocation.CurrentInvocationInterceptor.invoke(CurrentInvocationInterceptor.java:67)<br/>    at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)<br/>    at org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:421)<br/>    at org.jboss.ejb3.session.InvokableContextClassProxyHack._dynamicInvoke(InvokableContextClassProxyHack.java:53)<br/>    at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:91)<br/>    at org.jboss.aspects.remoting.AOPRemotingInvocationHandler.invoke(AOPRemotingInvocationHandler.java:82)<br/>    at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:891)<br/>    at org.jboss.remoting.transport.socket.ServerThread.completeInvocation(ServerThread.java:744)<br/>    at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:697)<br/>    at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:524)<br/>    at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:232)<br/>    at org.jboss.remoting.MicroRemoteClientInvoker.invoke(MicroRemoteClientInvoker.java:211)<br/>    at org.jboss.remoting.Client.invoke(Client.java:1724)<br/>    at org.jboss.remoting.Client.invoke(Client.java:629)<br/>    at org.jboss.aspects.remoting.InvokeRemoteInterceptor.invoke(InvokeRemoteInterceptor.java:60)<br/>    at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)<br/>    at org.jboss.aspects.tx.ClientTxPropagationInterceptor.invoke(ClientTxPropagationInterceptor.java:61)<br/>    at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)<br/>    at org.jboss.ejb3.security.client.SecurityClientInterceptor.invoke(SecurityClientInterceptor.java:65)<br/>    at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)<br/>    at org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:74)<br/>    at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)<br/>    at org.jboss.aspects.remoting.PojiProxy.invoke(PojiProxy.java:62)<br/>    at $Proxy3.invoke(Unknown Source)<br/>    at org.jboss.ejb3.proxy.impl.handler.session.SessionProxyInvocationHandlerBase.invoke(SessionProxyInvocationHandlerBase.java:207)<br/>    at org.jboss.ejb3.proxy.impl.handler.session.SessionProxyInvocationHandlerBase.invoke(SessionProxyInvocationHandlerBase.java:164)<br/>    at $Proxy2.logTest(Unknown Source)<br/>    at logbridge.test.LogbridgeTestClient.main(LogbridgeTestClient.java:24)<br/>    at org.jboss.aspects.remoting.InvokeRemoteInterceptor.invoke(InvokeRemoteInterceptor.java:72)<br/>    at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)<br/>    at org.jboss.aspects.tx.ClientTxPropagationInterceptor.invoke(ClientTxPropagationInterceptor.java:61)<br/>    at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)<br/>    at org.jboss.ejb3.security.client.SecurityClientInterceptor.invoke(SecurityClientInterceptor.java:65)<br/>    at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)<br/>    at org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:74)<br/>    at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)<br/>    at org.jboss.aspects.remoting.PojiProxy.invoke(PojiProxy.java:62)<br/>    at $Proxy3.invoke(Unknown Source)<br/>    at org.jboss.ejb3.proxy.impl.handler.session.SessionProxyInvocationHandlerBase.invoke(SessionProxyInvocationHandlerBase.java:207)<br/>    at org.jboss.ejb3.proxy.impl.handler.session.SessionProxyInvocationHandlerBase.invoke(SessionProxyInvocationHandlerBase.java:164)<br/>    at $Proxy2.logTest(Unknown Source)<br/>    at logbridge.test.LogbridgeTestClient.main(LogbridgeTestClient.java:24)</p><p></code></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>The LogBridgeHandler tries to resolve the name for the targetLogger from the LogRecord name which is null in case of an anonymous logger. Hence the log4j logger can not be initialized correctly.</p><p>As a workaround i implemented my own LogBridgeHandler which checks the name of the LogRecord, and in case that the name is null uses the log4j Root logger (since the anonymous logger always has the RootLogger as parent). However i would like to minimize the amount of customization that has to be done when installing the application and use the jboss default LogBridgeHandler.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>My questions regarding this issue are the following:</p><p>1) Is there another way of using the jboss logbridge with JUL anonymous loggers without customization ?</p><p>2) Is this problem already solved in later versions of the jboss logbridge project ? (i searched for it, but didn't find any clues that this is the case)</p><p>3) Will this issue be eventually adressed in later versions of the jboss logbridge project, i.e. will there be a fix or do i have to stick with my customized version ?</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>Thank you for your effort !</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>Michael</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>PS: I add a jar File containing a small testcase with a StatelessBean using a JUL anonymous logger and a simple client triggering the logging. This should trigger the error described above (tested with a JBoss 5.1.0 default server).</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>The StatelessBean will just do</p><p><code></p><p>public void logTest() {<br/>      Logger logger = Logger.getAnonymousLogger();<br/>      logger.log(Level.INFO, "This is a TestLog");<br/>   }</p><p></code></p></div>
<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
<p style="margin: 0;">Reply to this message by <a href="http://community.jboss.org/message/559724#559724">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in Beginner's Corner at <a href="http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2075">Community</a></p>
</div></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>