logging - Fail to inject log4j using CDI - WELD-001408: Unsatisfied dependencies for type Logger with qualifiers @Default -
I have the same problem as explained here: This is probably the same setup (Wildfile 8.0).
Despite having a resource class with the manufacturer, I can not present a wooden example. Neiter in the controller, nor in EJB [Question 1] Should I be correct if I am wrong, I should be able to inject them into @nodel beans and @Stateless (EJB) in annotated beans, should not I?
package com.doe.webapp.service.auxilliary.cdiproducer; Import javax.enterprise.context.Dependent; Import javax.enterprise.context.RequestScoped; Import javax.enterprise.inject.Produces; Import javax.enterprise.inject.spi.InjectionPoint; Import javax.faces.context.FacesContext; Import org.apache.log4j.Logger; @Dependent Public Sector Resources {@Produces Public Logger productionLog (InjectionPoint injectionPoint) {Return Logger.getLogger (injectionPoint.getMember () getDeclaringClass () getName () ..); } @Produces @RequestScoped Public FacesContext yields FacesContext () {back FacesContext.getCurrentInstance (); }} Here is the start of my controller:
package com.doe.webapp.controller.security; Import java.io.IOException; Import java.util.Map; Import javax.annotation.PostConstruct; Import javax.enterprise.inject.model; Import javax.enterprise.inject.Produces; Import javax.faces.application.FacesMessage; Import javax.faces.bean.ManagedProperty; Import javax.faces.context.FacesContext; Import javax.inject.Inject; Import javax.inject.Named; Import javax.servlet.ServletException; Import javax.servlet.http.Cookie; Import javax.servlet.http.HttpServletRequest; Import javax.servlet.http.HttpServletResponse; Import javax.validation.constraints.Pattern; Import org.slf4j.Logger; Import com.doe.webapp.model.usermgmt.User; Import com.doe.webapp.service.security.LoginService; @Model Public Class Login Administrator {Private Static Last String Admin = "Admin"; Log in @ personal logger; @ Touch the face of the private face bracket; @ Login the private login service service; [...] Here is EJB, which is also an injection in the @ modeled annotated class. Similarly, while working prior to logger, the logger's injection throws the error mentioned earlier.
package com.doe.webapp.service.security; Import java.util.logging.Logger; Import javax.ejb.Stateless; Import javax.enterprise.event.Event; Import javax.inject.Inject; Import com.doe.webapp.data.UserRepository; Import com.doe.webapp.model.usermgmt.User; @Stateless Public Class LoginService {@ Inject personal transient logger log; @ Remove the personal user repository; @ Private Event & lt; Users & gt; UserEvent; Public user login (user user) {log.info ("login" + user.getuenname ()); User RUser = repository.findByCredentials (user.getUsername), user.getPassword ()); Returns RUser; }} Now, I get an error for LoginController.java controller
weld-2001,408. @Default injection point [BackedAnnotatedField] at com.doe.webapp.controller.security.LoginController.log (LoginController.javaxx) on unsatisfied dependency for type logger with qualifier @Inject private com.doe.webapp.controller.security .LoginController.log and LoginService.java Another one for enterprise bean
Weld-2001,408:. Unsatisfied dependency injection point for type logger with qualifier @Default [BackedAnnotatedField] @Inject at personal transient com.doe com.doe.webapp.service.security.LoginService.log .webapp.service.security.LoginService.log (LoginService [Question 2]: What I'm doing is not understandable that this injection fails with WELD-001408 error.
Now JBoss environment, but one possible mistake:
Login Ervice wants to import and injection the following: import java.util.logging.Logger; ... @ personal transient logger log in; login controller tries to use SLF4J: import org.slf4j.Logger; ... @ log in the private logger; While a third type of resource class logger : using import org.apache Does .log4j.Logger;
Comments
Post a Comment