users@jersey.java.net

[Jersey] Injecting _at_Context into ExceptionMapper constructor gives error

From: Martynas Jusevičius <martynas_at_graphity.org>
Date: Fri, 12 Jun 2015 13:33:02 +0200

Hey,

I'm using Jersey 1.19. I've implemented a per-request provider:

@Provider
public class MediaTypesProvider extends
PerRequestTypeInjectableProvider<Context, MediaTypes>

added its class to the Application:

        singletons.add(new MediaTypesProvider());

Also added an ExceptionMapper class:

        classes.add(NotFoundExceptionMapper.class);

Then when I try to inject MediaTypes into the mapper:

    public NotFoundExceptionMapper(@Context MediaTypes mediaTypes)

I get the following error:

Jun 12, 2015 1:31:11 PM com.sun.jersey.spi.inject.Errors processErrorMessages
SEVERE: The following errors and warnings have been detected with
resource and/or provider classes:
  SEVERE: Missing dependency for constructor public
org.graphity.processor.mapper.NotFoundExceptionMapper(org.graphity.core.MediaTypes)
at parameter index 0


Help appreciated.

Martynas