0

How can I inject javax.ws.rs.core.Configuration in a filter, annotated with @WebFilter. I try something like

 @Context
 private Configuration configuration;

or

@Inject
private Configuration configuration;

but that not works.

Mihai8
  • 3,113
  • 1
  • 21
  • 31

1 Answers1

1

This injection doesn't look correct: Configuration is a JAX-RS type that can only be injected with @Context in resource classes (the ones annotated with @Path) or in provider classes (the ones annotated with @Provider). See this answer for details.

You could try to expose Configuration (or the information you need from it) as a CDI bean (using a producer method) and then inject it in the @WebFilter using @Inject.

cassiomolin
  • 124,154
  • 35
  • 280
  • 359