Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

243
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!