Mihai8
Mihai8

Reputation: 3147

Injection Context

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.

Upvotes: 0

Views: 217

Answers (1)

cassiomolin
cassiomolin

Reputation: 130957

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.

Upvotes: 1

Related Questions