Ya, I'm tring Spring AOP as well, and facing some problem.

If I AOP action class, some action when I run, I got this error, but some is 
running fine:

Struts has detected an unhandled exception:
# Messages: $Proxy18.input1()
File: java/lang/Class.java
Line number: 1,605
Stacktraces
java.lang.NoSuchMethodException: $Proxy18.input1()

    java.lang.Class.getMethod(Class.java:1605)
    
org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.getActionMethod(AnnotationValidationInterceptor.java:75)
    
org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:47)
    
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
    
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
    
com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:122)
    
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
    
com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195)
    
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
    
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
    
com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195)
    
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    java.lang.reflect.Method.invoke(Method.java:597)
    
org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
    
org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
    
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
    
com.iss.sandbox.louis.common.utils.LogInterceptor.invoke(LogInterceptor.java:67)
    
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
    $Proxy17.intercept(Unknown Source)



Not sure what happen, but if I AOP service & dao classes, thats fine, but it 
print the interface name instead of the actual implement class name.
Here is part of  my spring conf:



<bean 
class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator"> 
<property name="beanNames"> 
<list> 
<value>*Action*</value>
<value>*Service*</value> 
<value>*DAO*</value> 
</list>
</property> 
<property name="interceptorNames"> 
<list> 
<value>logInterceptor</value> 
</list> 
</property> 
</bean>  

And the LogInterceptor.java:
public class LogInterceptor implements MethodInterceptor {

private static Log logger = LogFactory.getLog(LogInterceptor.class);

/*
* (non-Javadoc)
* 
* @see
* org.aopalliance.intercept.MethodInterceptor#invoke(org.aopalliance.intercept
* .MethodInvocation)
*/
@Override
public Object invoke(MethodInvocation methodInvocation) throws Throwable {
if (logger.isDebugEnabled()) {
logger.debug("Beginning method: "
+ methodInvocation.getMethod().getClass() + "::"
+ methodInvocation.getMethod().getName());
}
try {
Object returnValue = methodInvocation.proceed();
return returnValue;
} finally {
if (logger.isDebugEnabled()) {
logger.debug("Finish execute "
+ methodInvocation.getMethod().getDeclaringClass()
+ "::" + methodInvocation.getMethod().getName());
}
}
}

}


Print out:

2009-08-18 11:11:00,296 DEBUG louis.common.utils.LogInterceptor.invoke:62 - 
Beginning method: class java.lang.reflect.Method::execute
2009-08-18 11:11:00,312 DEBUG louis.common.utils.LogInterceptor.invoke:71 - 
Finish execute interface com.opensymphony.xwork2.Action::execute




________________________________
From: Dave Newton <newton.d...@yahoo.com>
To: Struts Users Mailing List <user@struts.apache.org>
Sent: Monday, August 17, 2009 6:01:30 PM
Subject: Re: LoggingInterceptor

mailtolouis2020-str...@yahoo.com wrote:
> We use to have this log statement in most of the method begin and end
> in Struts1, now working with S2+Spring, both are provide logging
> interceptor, so I wonder this can help me to reduce coding in new
> project.

No; the logging interceptor does exactly what it says it does.

General declarative entry/exit logging should be handled via AOP, for example 
using Spring.

Dave


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org

Reply via email to