1 Reply Latest reply: Mar 1, 2012 7:49 AM by Sueleyman Vurucu RSS

Interceptors in As 7.1 doen't work.

Sueleyman Vurucu Expert

Hi @ 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;

  }

}

  • 1. Re: Interceptors in As 7.1 doen't work.
    Sueleyman Vurucu Expert

    Hi guys,

     

    so I can answer my question self  . The probleam was like the error says. I don't listed the interceptor in <interceptors section>

     

      <interceptors>

            <interceptor>

                <interceptor-class>com.siemag.components.logging.jboss.aop.TracingInterceptor</interceptor-class>

            </interceptor>

        </interceptors>

        <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>

     

    So that works also. I assume that jboss 6.1.0.Final do that wrong. But it's not realy certificated JavaEE6 server . So the problem solved.