Je l'ExceptionMapper suivante:injection CDI avec ExceptionMapper- @Inject null
@Provider
public class GenericExceptionMapper
implements ExceptionMapper<Exception> {
@Inject
private ExceptionDAO exceptionDAO;
@Override
public Response toResponse(Exception e) {
LOGGER.error(e.getMessage(), e);
return Response.status(INTERNAL_SERVER_ERROR)
.type(MediaType.TEXT_PLAIN)
.entity(e.getMessage())
.build();
}
Le exceptionDAO est toujours nulle. J'ai un beans.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee /beans_1_0.xsd"
></beans>
J'ai essayé injecter beaucoup de classes, mais ils montrent toujours aussi nul.
Avez-vous CDI travailler n'importe où dans votre projet? Quel genre de projet (EAR, WAR, etc.) est-ce? Où est le beans.xml spécifiquement? Comment 'ExceptionDAO' est-il annoté? – dcsohl
Oh, d'autres questions: Est-ce que 'GenericExceptionMapper' a des annotations? Comment en obtenez-vous un? – dcsohl
C'est un projet JAR. Oui CDI travaille dans d'autres domaines – abbas