Interceptors in As 7.1 doen't work.
suikast42 Mar 1, 2012 7:35 AMHi @ all,
I migrate my app from Jboss 6.1.0.Final to 7.1.0.Final. I have some interceptors. The interceptors work fine in Jboss 6.1.0.Final. AS 7.1.0.Final says:
13:22:10,789 WARN [org.jboss.as.ejb3] (MSC service thread 1-14) JBAS014110: Default interceptor class com.siemag.components.logging.jboss.aop.TracingInterceptor is not listed in the <interceptors> section of ejb-jar.xml and will not be applied
My ejb-jar.xml
<?xml version="1.0" encoding="UTF-8"?>
<ejb-jar xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:ejb="http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_1.xsd"
version="3.1">
<display-name>WMS_BASE_SERVICES</display-name>
<assembly-descriptor>
<interceptor-binding>
<ejb-name>*</ejb-name>
<interceptor-class>com.siemag.components.logging.jboss.aop.TracingInterceptor</interceptor-class>
</interceptor-binding>
<interceptor-binding>
<ejb-name>DomainMessengerService</ejb-name>
<exclude-default-interceptors>true</exclude-default-interceptors>
</interceptor-binding>
</assembly-descriptor>
</ejb-jar>
My Interceptor class
public class TracingInterceptor {
private Logger log = Logger.getLogger(TracingInterceptor.class);
@AroundInvoke
public Object logCall(InvocationContext context) throws Exception{
Method method = context.getMethod();
String methodName = context.getTarget().getClass().getName() + "." + method.getName();
// String methodName = method.getDeclaringClass().getName() + "." + method.getName();
log.debug("Start invoking method: " + methodName);
Object result = null;
long startTime = -1;
try {
startTime = System.currentTimeMillis();
result = context.proceed();
} catch (Exception e) {
log.error("Error invoking method: " + methodName + " " + e.getMessage());
throw e;
}
long finshtime = System.currentTimeMillis() - startTime;
log.debug("Finish invoking method: " + methodName + " in " + finshtime + " [ms]");
return result;
}
}