java - WELD-001408 Unsatisfied dependencies - can't find the root cause -
i cannot inject logger cdi bean. tried solutions answers other similar questions none have helped. appreciate if can me find what's going on here.
i using glassfish 4.0.
error message eclipse when trying deploy application:
deploy failing=error occurred during deployment: exception while loading app : cdi deployment failure:weld-001408 unsatisfied dependencies type [logger] qualifiers [@default] @ injection point [[backedannotatedfield] @inject protected learning.javaee.guestbook.unregistereduserpost.log]. please see server.log more details.
cdi bean containing injection point:
package learning.javaee.guestbook; import java.time.offsetdatetime; import java.util.logging.logger; import javax.enterprise.context.requestscoped; import javax.inject.inject; import javax.inject.named; @named @requestscoped public class unregistereduserpost extends abstractpost { private string name; private offsetdatetime datetime; @inject protected logger log; public unregistereduserpost() {} public string getname() { return name; } public void setname(string name) { this.name = name; } public offsetdatetime getdatetime() { return datetime; } public void setdatetime(offsetdatetime datetime) { this.datetime = datetime; } public void save() { log.info("test"); } }
logger producer:
package learning.javaee.guestbook; import javax.enterprise.inject.produces; import javax.enterprise.inject.spi.injectionpoint; import org.jboss.logging.logger; public class loggerproducer { @produces public logger producelogger(injectionpoint ip) { return logger.getlogger(ip.getmember().getdeclaringclass().getname()); } }
guestbook.xhtml - calls cdi bean's method save()
using logger instance
<?xml version="1.0" encoding="utf-8"?> <!doctype html> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://xmlns.jcp.org/jsf/html"> <h:head> <title>#{msg.page_title}</title> <link rel="stylesheet" type="text/css" href="css.css"/> </h:head> <h:body> <h:form> <h:outputtext value="#{msg.your_name} "/> <h:inputtext value="#{unregistereduserpost.name}"/> <br/><br/> <h:outputtext value="#{msg.your_msg}"/> <br/> <h:inputtextarea rows="5" cols="100" value="#{unregistereduserpost.content}"/> <br/><br/> <h:commandbutton value="#{msg.submit}" action="#{unregistereduserpost.save()}"/> </h:form> </h:body> </html>
webcontent\web-inf\beans.xml
<?xml version="1.0" encoding="utf-8"?> <beans xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd" version="1.1" bean-discovery-mode="all"> </beans>
sometimes making producer class @dependent scoped make work. i'm not sure. , in case, have "bean-discovery-mode=all" doesn't make differents.
but in case, have mistake in imports.
your producer produces "import org.jboss.logging.logger;" , injected field java.util.logging
.logger . don't have appropiated producer de type class wanted inject.
Comments
Post a Comment