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

256
Views
La vinculación del interceptor no funciona

Tengo una clase de interceptor CDI anotada con javax.interceptor.InterceptorBinding @LogBinding, definida de la siguiente manera:

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

Luego uso la anotación en el bean EJB:

 @Alternative @Stateless @LogBinding public class FooService { @Asynchronous public fooMethod() { } }

Invoco fooMethod desde otro bean. El problema es que el interceptor no se llama. Todo funciona cuando cambio la anotación @LogBinding a @Interceptors({LogInterceptor.class}) en FooService. No sé si puede tener impacto, pero FooService se comercializa como @Alternative, porque se inyecta en otros lugares como EJB bean, a continuación se muestra el campo productor:

 @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"); } }

¿Por qué no funciona?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

También debe anotar su clase de interceptor con ese enlace para que sepa qué clase usar como 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!