-
Bug
-
Resolution: Done
-
Major
-
2.0.GA
-
None
I have a Spring AOP interceptor whose job is to log information about all my public methods. I happen to have a class called ClientFactory that encapsulates the RESTEaxy client proxy capability as well. The key method of ClientFactory is as follows:
public <T> T create(Class<T> c) {
RegisterBuiltin.register(ResteasyProviderFactory.getInstance());
return ProxyFactory.create(c, location);
}
where "location" is the Spring configured URL of the destination.
When I try to fire up my TestNG tests, I get the following NPE:
java.lang.NullPointerExceptionat org.jboss.resteasy.client.core.ClientProxy.invoke(ClientProxy.java:59)at $Proxy41.toString(Unknown Source)at com.myapp.LoggingAspect.logInfo(LoggingAspect.java:21)at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)at java.lang.reflect.Method.invoke(Method.java:597)at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:627)at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:616)at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:64)at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:635)at
com.myapp.client.ClientFactory$$EnhancerByCGLIB$$864cba00.create(<generated>)at
com.myapp.services.remote.entities.query.QueryEngine.initializeService(QueryEngine.java:419)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:597)at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:297)at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:250)at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:144)
Here are lines 58-59 of ClientProxy.java:
58
ClientInvoker clientInvoker = methodMap.get(method);
59
return clientInvoker.invoke(args);
This can be worked around by altering your pointcut expression to avoid any method that uses ClientProxy.