Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

246
Vistas
Interceptor binding doesn't work

I have CDI interceptor class annotated with javax.interceptor.InterceptorBinding @LogBinding, defined as follows:

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

Then I use annotation on EJB bean:

@Alternative
@Stateless
@LogBinding 
public class FooService {

    @Asynchronous
    public fooMethod() {

    }
}

I invoke fooMethod from another bean. The problem is that interceptor isn't called. Everything works when I change @LogBinding annotation to @Interceptors({LogInterceptor.class}) on the FooService. I don't know if it may have impact but FooService is market as @Alternative, because it's injected in other places as EJB bean, below is the producer field:

@Default
@Produces
@EJB
private FooService fooService;


@Interceptor
@LogBinding
@Priority(Interceptor.Priority.APPLICATION)
public class LogInterceptor {
  @AroundInvoke
    public Object invoke(final InvocationContext invocationContext) throws Exception {
    System.out.println("it works");
    }
}

Why it doesn't work?

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

You also have to annotate your interceptor class with that binding in order for it to know which class to use as the interceptor

@LogBinding
@Interceptor
public class LogInterceptor {...}
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda