[jboss-user] [JBoss AOP] - Aspect based logger for EJB3 project
sandello
do-not-reply at jboss.com
Thu May 15 04:42:29 EDT 2008
I have a project, which use EJB3 Session Beans, EJB3 Persistense, JMX and Eclipse RAP.
Now, I have written simple aspect. It should create TRACE log of all method invocation.
But, I have got exception after start JBoss with my project and aspect logger.
JBoss 4.2.1
JbossAOP 1.5.5
OS Fedora
java version "1.5.0_14"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_14-b03)
Java HotSpot(TM) 64-Bit Server VM (build 1.5.0_14-b03, mixed mode)
Aspect class:
| public class AspectLogger implements Interceptor {
| private Logger logger = Logger.getLogger(AspectLogger.class.getName());
|
|
| public String getName() {
| return this.getClass().getName();
| }
|
| public Object invoke(Invocation invocation) throws Throwable {
| if (invocation instanceof MethodInvocation) {
| MethodInvocation mi = (MethodInvocation) invocation;
|
| String iClassName = mi.getMethod().getDeclaringClass().getName();
| String iMethodName = mi.getMethod().getName();
|
| StringBuffer buff = new StringBuffer();
| buff.append(iClassName).append("#").append(iMethodName).append(" ");
|
| Object[] objects = mi.getArguments();
| buff.append(" agrs: |");
| if (objects != null) {
| for (Object o : objects) {
| buff.append(o.toString()).append("|");
| }
| }else{
| buff.append("|");
| }
| logger.trace(buff);
|
| Object ret = invocation.invokeNext();
|
| buff = new StringBuffer();
| buff.append(iClassName).append(" ").append(iMethodName).append(" ");
|
| buff.append(" result: |").append(ret).append("|");
| logger.trace(buff);
|
| return ret;
|
| }
| else {
| return invocation.invokeNext();
| }
| }
| }
|
jboss-aop.xml
| <aop>
| <bind pointcut="execution(* com.telecom_m.billingtm.*->*(..)) AND !execution(* *javassist*->*(..)) AND !execution(* *$*->*(..))">
| <interceptor class="com.telecom_m.util.log.AspectLogger" scope="PER_INSTANCE"/>
| </bind>
| </aop>
|
exception
| 13:57:32,762 WARN [ServiceController] Problem starting service billing:service=NumberCapacityManager
| java.lang.RuntimeException: javax.ejb.EJBException: java.lang.NullPointerException
| at com.telecom_m.billingtm.numeredcapacity.jmx.NumberCapacityInit.com$telecom_m$billingtm$numeredcapacity$jmx$NumberCapacityInit$start$aop(NumberCapacityInit.java:53)
| at com.telecom_m.billingtm.numeredcapacity.jmx.NumberCapacityInit$start_N8025343665958530775.invokeNext(NumberCapacityInit$start_N8025343665958530775.java)
| at com.telecom_m.util.log.AspectLogger.invoke(AspectLogger.java:43)
| at org.jboss.aop.advice.PerInstanceInterceptor.invoke(PerInstanceInterceptor.java:105)
| at com.telecom_m.billingtm.numeredcapacity.jmx.NumberCapacityInit$start_N8025343665958530775.invokeNext(NumberCapacityInit$start_N8025343665958530775.java)
| at com.telecom_m.billingtm.numeredcapacity.jmx.NumberCapacityInit.start(NumberCapacityInit.java)
| at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
| at java.lang.reflect.Method.invoke(Method.java:585)
| 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.system.ServiceController$ServiceProxy.invoke(ServiceController.java:995)
| at $Proxy0.start(Unknown Source)
| at org.jboss.system.ServiceController.start(ServiceController.java:417)
| at org.jboss.system.ServiceController.start(ServiceController.java:435)
| at sun.reflect.GeneratedMethodAccessor10.invoke(Unknown Source)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
| at java.lang.reflect.Method.invoke(Method.java:585)
| 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 $Proxy132.start(Unknown Source)
| ...
| Caused by: javax.ejb.EJBException: java.lang.NullPointerException
| at org.jboss.ejb3.tx.Ejb3TxPolicy.handleExceptionInOurTx(Ejb3TxPolicy.java:63)
| at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:83)
| at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:191)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
| at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:106)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:46)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:278)
| at org.jboss.ejb3.remoting.IsLocalInterceptor.invokeLocal(IsLocalInterceptor.java:79)
| at org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:70)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.ejb3.stateless.StatelessRemoteProxy.invoke(StatelessRemoteProxy.java:103)
| at $Proxy137.getServerInfo(Unknown Source)
| at com.telecom_m.billingtm.numeredcapacity.jmx.NumberCapacityInit.com$telecom_m$billingtm$numeredcapacity$jmx$NumberCapacityInit$setServerInfo$aop(NumberCapacityInit.java:92)
| at com.telecom_m.billingtm.numeredcapacity.jmx.NumberCapacityInit.access$2(NumberCapacityInit.java)
| at com.telecom_m.billingtm.numeredcapacity.jmx.NumberCapacityInit$setServerInfo_N5058612175990396503.invokeNext(NumberCapacityInit$setServerInfo_N5058612175990396503.java)
| at com.telecom_m.util.log.AspectLogger.invoke(AspectLogger.java:43)
| at org.jboss.aop.advice.PerInstanceInterceptor.invoke(PerInstanceInterceptor.java:105)
| at com.telecom_m.billingtm.numeredcapacity.jmx.NumberCapacityInit$setServerInfo_N5058612175990396503.invokeNext(NumberCapacityInit$setServerInfo_N5058612175990396503.java)
| at com.telecom_m.billingtm.numeredcapacity.jmx.NumberCapacityInit.setServerInfo(NumberCapacityInit.java)
| at com.telecom_m.billingtm.numeredcapacity.jmx.NumberCapacityInit.com$telecom_m$billingtm$numeredcapacity$jmx$NumberCapacityInit$start$aop(NumberCapacityInit.java:48)
| ... 142 more
| Caused by: java.lang.NullPointerException
| at com.telecom_m.util.log.AspectLogger.invoke(AspectLogger.java:36)
| at org.jboss.aop.advice.PerInstanceInterceptor.invoke(PerInstanceInterceptor.java:105)
| at com.telecom_m.billingtm.numeredcapacity.storage.NumberCapacityStorage$find_N172794843629558471.invokeNext(NumberCapacityStorage$find_N172794843629558471.java)
| at com.telecom_m.billingtm.numeredcapacity.storage.NumberCapacityStorage.find(NumberCapacityStorage.java)
| at com.telecom_m.billingtm.numeredcapacity.storage.NumberCapacityStorage.com$telecom_m$billingtm$numeredcapacity$storage$NumberCapacityStorage$getNumberCapacityAll$aop(NumberCapacityStorage.java:106)
| at com.telecom_m.billingtm.numeredcapacity.storage.NumberCapacityStorage$getNumberCapacityAll_N1171544817664568855.invokeNext(NumberCapacityStorage$getNumberCapacityAll_N1171544817664568855.java)
| at com.telecom_m.util.log.AspectLogger.invoke(AspectLogger.java:43)
| at org.jboss.aop.advice.PerInstanceInterceptor.invoke(PerInstanceInterceptor.java:105)
| at com.telecom_m.billingtm.numeredcapacity.storage.NumberCapacityStorage$getNumberCapacityAll_N1171544817664568855.invokeNext(NumberCapacityStorage$getNumberCapacityAll_N1171544817664568855.java)
| at com.telecom_m.billingtm.numeredcapacity.storage.NumberCapacityStorage.getNumberCapacityAll(NumberCapacityStorage.java)
| at com.telecom_m.billingtm.numeredcapacity.server.NumberCapacityServerSEJB3.com$telecom_m$billingtm$numeredcapacity$server$NumberCapacityServerSEJB3$getServerInfo$aop(NumberCapacityServerSEJB3.java:155)
| at com.telecom_m.billingtm.numeredcapacity.server.NumberCapacityServerSEJB3$getServerInfo_8270737250672936487.invokeNext(NumberCapacityServerSEJB3$getServerInfo_8270737250672936487.java)
| at com.telecom_m.util.log.AspectLogger.invoke(AspectLogger.java:43)
| at org.jboss.aop.advice.PerInstanceInterceptor.invoke(PerInstanceInterceptor.java:105)
| at com.telecom_m.billingtm.numeredcapacity.server.NumberCapacityServerSEJB3$getServerInfo_8270737250672936487.invokeNext(NumberCapacityServerSEJB3$getServerInfo_8270737250672936487.java)
| ...
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4150962#4150962
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4150962
More information about the jboss-user
mailing list