0

I'm experiencing CDI interceptors binding issues and I couldn't figure out what is wrong.

While I'm developing using Eclipse, only with JRebel agent active, interceptors work well, but when I deploy the same application, at the same glassfish instalation, this time an EAR file using asadmin command, the interceptors are completely ignored. The same happens when I turn jrebel agent off.

I'm using Glassfish 3.1.2.2 with Weld 1.1.11 and JDK 1.6.

My application is a multi-module maven project like:

APP
 \--MODULE-EJB1 (annotation and interceptor resides here.)
    \--META-INF\beans.xml (with interceptor declaration)
 \--MODULE-EJB2
    \--META-INF\beans.xml (empty one)
 \--MODULE-JAR
    \--META-INF\beans.xml (empty one)
 \--MODULE-WAR
    \--WEB-INF\beans.xml (empty one)
 \--MODULE-EAR

My annotation:

@InterceptorBinding
@Target({ TYPE, METHOD })
@Retention(RUNTIME)
public @interface Audited {
}

My Interceptor class:

@Audited
@Interceptor
public class AuditInterceptor implements Serializable {
   [...]
}

My intercepted method:

@Override
@Audited
public E save(E model) throws SGIException, ConstraintViolationException {
   [...]
}

My beans.xml files:

<?xml version="1.0"?>
<beans
    xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://jboss.org/schema/cdi/beans_1_0.xsd" >
    <interceptors>
        <class>pkg.interceptor.AuditInterceptor</class>
    </interceptors>
</beans>

<!-- empty one -->
<?xml version="1.0"?>
<beans
    xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://jboss.org/schema/cdi/beans_1_0.xsd" />

I hope I provided everything that matters.

Thanks in advance for helping, it's a very crucial part of application.

dmota
  • 1

1 Answers1

0

Glassfish has had problems with interceptors being properly enabled since day one. I have no idea if they've fixed it yet. Currently the only way to get it to work is to continue to undeploy and redeploy until they finally work :(

LightGuard
  • 5,298
  • 19
  • 19