jsf - com.sun.faces.mgbean.ManagedBeanCreationException: -
i created java ee web application jsf 2 (primefaces), hibernate , spring. added necessary jars , declared beans in faces-config
.
when run application following exception:
enter code here error occurred: erreur lors de l’injection de ressources dans le bean géré «loginbean» +- stack trace com.sun.faces.mgbean.managedbeancreationexception: erreur lors de l’injection de ressources dans le bean géré «loginbean» @ com.sun.faces.mgbean.beanbuilder.invokepostconstruct(beanbuilder.java:229) @ com.sun.faces.mgbean.beanbuilder.build(beanbuilder.java:105) @ com.sun.faces.mgbean.beanmanager.createandpush(beanmanager.java:409) @ com.sun.faces.mgbean.beanmanager.create(beanmanager.java:269) @ com.sun.faces.el.managedbeanelresolver.resolvebean(managedbeanelresolver.java:244) @ com.sun.faces.el.managedbeanelresolver.getvalue(managedbeanelresolver.java:116) @ com.sun.faces.el.demuxcompositeelresolver._getvalue(demuxcompositeelresolver.java:176) @ com.sun.faces.el.demuxcompositeelresolver.getvalue(demuxcompositeelresolver.java:203) @ org.apache.el.parser.astidentifier.getvalue(astidentifier.java:71) @ org.apache.el.parser.astvalue.getvalue(astvalue.java:147) @ org.apache.el.valueexpressionimpl.getvalue(valueexpressionimpl.java:189) @ com.sun.faces.facelets.el.tagvalueexpression.getvalue(tagvalueexpression.java:109) @ javax.faces.component.componentstatehelper.eval(componentstatehelper.java:194) @ javax.faces.component.componentstatehelper.eval(componentstatehelper.java:182) @ javax.faces.component.uioutput.getvalue(uioutput.java:169) @ org.primefaces.util.componentutils.getvaluetorender(componentutils.java:64) @ org.primefaces.component.inputtext.inputtextrenderer.encodemarkup (inputtextrenderer.java:77) @ org.primefaces.component.inputtext.inputtextrenderer.encodeend (inputtextrenderer.java:51) @ javax.faces.component.uicomponentbase.encodeend(uicomponentbase.java:875) @ com.sun.faces.renderkit.html_basic.htmlbasicrenderer.encoderecursive (htmlbasicrenderer.java:312) @ com.sun.faces.renderkit.html_basic.gridrenderer.renderrow(gridrenderer.java:185) @ com.sun.faces.renderkit.html_basic.gridrenderer.encodechildren (gridrenderer.java:129) @ javax.faces.component.uicomponentbase.encodechildren(uicomponentbase.java:845) @ org.primefaces.renderkit.corerenderer.renderchild(corerenderer.java:59) @ org.primefaces.renderkit.corerenderer.renderchildren(corerenderer.java:47) @ org.primefaces.component.panel.panelrenderer.encodecontent (panelrenderer.java:202) @ org.primefaces.component.panel.panelrenderer.encodemarkup (panelrenderer.java:119) @ org.primefaces.component.panel.panelrenderer.encodeend(panelrenderer.java:56) @ javax.faces.component.uicomponentbase.encodeend(uicomponentbase.java:875) @ javax.faces.component.uicomponent.encodeall(uicomponent.java:1786) @ javax.faces.render.renderer.encodechildren(renderer.java:168) @ javax.faces.component.uicomponentbase.encodechildren(uicomponentbase.java:845) @ javax.faces.component.uicomponent.encodeall(uicomponent.java:1779) @ javax.faces.component.uicomponent.encodeall(uicomponent.java:1782) @ javax.faces.component.uicomponent.encodeall(uicomponent.java:1782) @ com.sun.faces.application.view.faceletviewhandlingstrategy.renderview (faceletviewhandlingstrategy.java:402) @ com.sun.faces.application.view.multiviewhandler.renderview (multiviewhandler.java:125) @ com.sun.faces.lifecycle.renderresponsephase.execute (renderresponsephase.java:121) @ com.sun.faces.lifecycle.phase.dophase(phase.java:101) @ com.sun.faces.lifecycle.lifecycleimpl.render(lifecycleimpl.java:139) @ javax.faces.webapp.facesservlet.service(facesservlet.java:594) @ org.apache.catalina.core.applicationfilterchain.internaldofilter (applicationfilterchain.java:305) @ org.apache.catalina.core.applicationfilterchain.dofilter (applicationfilterchain.java:210) @ org.apache.catalina.core.standardwrappervalve.invoke (standardwrappervalve.java:224) @ org.apache.catalina.core.standardcontextvalve.invoke (standardcontextvalve.java:169) @ org.apache.catalina.authenticator.authenticatorbase.invoke (authenticatorbase.java:472) @ org.apache.catalina.core.standardhostvalve.invoke(standardhostvalve.java:168) @ org.apache.catalina.valves.errorreportvalve.invoke(errorreportvalve.java:98) @ org.apache.catalina.valves.accesslogvalve.invoke(accesslogvalve.java:928) @ org.apache.catalina.core.standardenginevalve.invoke (standardenginevalve.java:118) @ org.apache.catalina.connector.coyoteadapter.service(coyoteadapter.java:407) @ org.apache.coyote.http11.abstracthttp11processor.process (abstracthttp11processor.java:987) @ org.apache.coyote.abstractprotocol$abstractconnectionhandler.process (abstractprotocol.java:539) @ org.apache.tomcat.util.net.jioendpoint$socketprocessor.run(jioendpoint.java:300) @ java.util.concurrent.threadpoolexecutor.runworker(unknown source) @ java.util.concurrent.threadpoolexecutor$worker.run(unknown source) @ java.lang.thread.run(unknown source) caused by: com.sun.faces.spi.injectionproviderexception @ com.sun.faces.vendor.webcontainerinjectionprovider.invokeannotatedmethod (webcontainerinjectionprovider.java:119) @ com.sun.faces.vendor.webcontainerinjectionprovider.invokepostconstruct (webcontainerinjectionprovider.java:99) @ com.sun.faces.mgbean.beanbuilder.invokepostconstruct (beanbuilder.java:223) ... 56 more caused by: java.lang.reflect.invocationtargetexception @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(unknown source) @ sun.reflect.delegatingmethodaccessorimpl.invoke(unknown source) @ java.lang.reflect.method.invoke(unknown source) @ com.sun.faces.vendor.webcontainerinjectionprovider.invokeannotatedmethod (webcontainerinjectionprovider.java:117) ... 58 more caused by: java.lang.nullpointerexception @ com.plasticum.beans.loginbean.init(loginbean.java:29) ... 63 more + - component tree <uiviewroot id="j_id1" inview="true" locale="fr_fr" renderkitid="html_basic" rendered="true" transient="false" viewid="/pages/loginx.xhtml"> javax_faces_location_head <componentresourcecontainer id="javax_faces_location_head" inview="true" rendered="true" transient="false"> <uioutput inview="true" rendered="true" transient="false"/> <uioutput inview="true" rendered="true" transient="false"/> <uioutput inview="true" rendered="true" transient="false"/> <uioutput inview="true" rendered="true" transient="false"/> <uioutput inview="true" rendered="true" transient="false"/> <uioutput inview="true" rendered="true" transient="false"/> </componentresourcecontainer> <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:a4j="http://richfaces.org/a4j" xmlns:rich="http://richfaces.org/rich" xmlns:s="http://jboss.com/products/seam/taglib"> <uioutput id="j_idt3" inview="true" rendered="true" transient="false"> <title>authentification</title> <link rel="stylesheet" type="text/css" href="../css/styles.css"/> </uioutput> <uioutput id="j_idt5" inview="true" rendered="true" transient="false"> <center> <htmlform enctype="application/x-www-form-urlencoded" id="form" inview="true" prependid="true" rendered="true" submitted="false" transient="false"> <panel closable="false" closespeed="500" collapsed="false" header="authentification" id="panel" inview="true" rendered="true" toggleorientation="vertical" togglespeed="500" toggleable="false" transient="false" visible="true"> <messages autoupdate="false" closable="false" escape="true" globalonly="false" id="msgs" inview="true" redisplay="true" rendered="true" showdetail="false" showsummary="true" transient="false"/> <clock autosync="false" id="j_idt7" inview="true" mode="server" pattern="hh:mm:ss dd.mm.yyyy" rendered="true" syncinterval="60000" transient="false"/> <htmlpanelgrid border="-2147483648" columns="3" id="j_idt8" inview="true" rendered="true" transient="false"> <htmloutputlabel escape="true" for="identifiant" id="j_idt9" inview="true" rendered="true" transient="false" value="identifiant "/> <inputtext disabled="false" id="identifiant" immediate="false" inview="true" label="identifiant" localvalueset="false" maxlength="-2147483648" readonly="false" rendered="true" required="true" size="-2147483648" transient="false" type="text" valid="true"/> <message display="icon" escape="true" for="identifiant" id="j_idt10" inview="true" redisplay="true" rendered="true" showdetail="true" showsummary="false" transient="false"/> <htmloutputlabel escape="true" id="j_idt11" inview="true" rendered="true" transient="false" value="mot de passe"/> <password disabled="false" feedback="false" goodlabel="good" id="mp" immediate="false" inview="true" inline="false" label="mot de passe" localvalueset="false" maxlength="-2147483648" promptlabel="please enter password" readonly="false" redisplay="false" rendered="true" required="true" size="-2147483648" stronglabel="strong" transient="false" valid="true" weaklabel="weak"/> <message display="icon" escape="true" for="mp" id="msgsurname" inview="true" redisplay="true" rendered="true" showdetail="true" showsummary="false" transient="false"/> </htmlpanelgrid> <commandbutton action="#{loginbean.connect()}" actionexpression="# {loginbean.connect()}" ajax="true" async="false" disabled="false" escape="true" global="true" iconpos="left" id="btn" immediate="false" inview="true" inline="false" partialsubmit="false" readonly="false" rendered="true" transient="false" type="submit" update="panel" value="valider"/> </panel> </htmlform> </center> </uioutput> </html> </uiviewroot> +- scoped variables request parameters name value none view attributes name value none request attributes name value none flash attributes name value none session attributes name value none application attributes name value csfcff com.sun.faces.context.flash.elflash@1c8a2ab
i think resolved probleme adding nessesary annotation managed bean @managedbaen , @managedproperty, have other exception can't inderstand logonbean :
package com.plasticum.beans; import javax.annotation.postconstruct; import javax.faces.application.facesmessage; import javax.faces.bean.managedbean; import javax.faces.bean.managedproperty; import javax.faces.bean.sessionscoped; import javax.faces.bean.viewscoped; import javax.faces.context.facescontext; import java.io.serializable; import java.util.list; import org.springframework.beans.factory.annotation.autowired; import org.springframework.context.annotation.scope; import org.springframework.stereotype.component; import com.plasticum.service.utilisateurservice; import com.plasticum.web.utilisateurbean; import com.plasticum.model.*; @sessionscoped @managedbean(name = "utlisateurservice") //@viewscoped public class loginbean implements serializable { @managedproperty(value="#{utilisateurservice}") utilisateurservice utilisateurservice; private string login; private string password; list<utilisateur> list= utilisateurservice.findall(); /*@postconstruct public void init() { utilisateurbean utilisateurbean = new utilisateurbean(); list = utilisateurbean.getlist(); }*/ public string getlogin() { return login; } public void setlogin(string login) { this.login = login; } public string getpassword() { return password; } public void setpassword(string password) { this.password = password; } public string connect() { facescontext fc = facescontext.getcurrentinstance(); /*for (int = 0; < list.size(); i++) { if (list.get(i).getnom().equals(login) && list.get(i).getmp().equals(password)) { return "menu"; } }*/ string hh=list.get(1).getnom(); fc.addmessage(null, new facesmessage(hh)); return "login"; /* * facescontext fc = facescontext.getcurrentinstance(); * if(login.equals("admin") && password.equals("admin")){return"menu";} * else{ * * fc.addmessage(null, new * facesmessage("login ou mot de passe incorrect !!!!")); * return"login";} */ /* * string log=""; string pass=""; facescontext * fc=facescontext.getcurrentinstance(); for(int i=0;i<list.size();i++) * { log=list.get(i).getnom(); //+" "+list.get(i).getprenom(); * pass=list.get(i).getmp(); if(this.login.equals(log) && * this.password.equals(pass)){return "menu";} * * } fc.addmessage(null, new * facesmessage("login ou mot de passe incorrect !!!!")); * return"login"; */ } public java.util.list getlist() { return list; } public void setlist(java.util.list list) { this.list = list; } public utilisateurservice getutilisateurservice() { return utilisateurservice; } public void setutilisateurservice(utilisateurservice utilisateurservice) { this.utilisateurservice = utilisateurservice; } }
and web.xml
<?xml version="1.0" encoding="utf-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xmlns:fmt="http://java.sun.com/jstl/fmt" xsi:schemalocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="webapp_id" version="3.0"> <display-name>plasticum</display-name> <welcome-file-list> <welcome-file>index.jsp</welcome-file> <welcome-file>default.html</welcome-file> <welcome-file>default.htm</welcome-file> <welcome-file>default.jsp</welcome-file> </welcome-file-list> <servlet> <servlet-name>faces servlet</servlet-name> <servlet-class>javax.faces.webapp.facesservlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <context-param> <param-name>javax.faces.default_suffix</param-name> <param-value>.xhtml</param-value> </context-param> <servlet-mapping> <servlet-name>faces servlet</servlet-name> <url-pattern>*.xhtml</url-pattern> </servlet-mapping> <context-param> <param-name>primefaces.theme</param-name> <param-value>bluesky</param-value> </context-param> <listener> <listener-class>org.springframework.web.context.contextloaderlistener</listener-class> </listener> <listener> <listener- class>org.springframework.web.context.request.requestcontextlistener</listener- class> </listener> <context-param> <param-name>contextconfiglocation</param-name> <param-value>classpath:application_context.xml</param-value> </context-param> <context-param> <param-name>javax.servlet.jsp.jstl.fmt.localizationcontext</param-name> <param-value>resources.application</param-value> </context-param> <context-param> <description>state saving method: 'client' or 'server' (=default). see jsf specification 2.5.2</description> <param-name>javax.faces.state_saving_method</param-name> <param-value>client</param-value> </context-param> <context-param> <param-name>javax.faces.project_stage</param-name> <param-value>development</param-value> </context-param> <listener> <listener-class>com.sun.faces.config.configurelistener</listener-class> </listener> </web-app>
and application context.xml
<?xml version="1.0" encoding="utf-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:p="http://www.springframework.org/schema/p" xsi:schemalocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd"> <bean id="utilisateurservice" class="com.plasticum.service.utilisateurserviceimpl"> <property name="sessionfactory" ref="sessionfactory" /> </bean> <bean id="rebutservice" class="com.plasticum.service.rebutserviceimpl"> <property name="sessionfactory" ref="sessionfactory" /> </bean> <bean id="mcservice" class="com.plasticum.service.mcserviceimpl"> <property name="sessionfactory" ref="sessionfactory" /> </bean> <bean id="mccservice" class="com.plasticum.service.mccserviceimpl"> <property name="sessionfactory" ref="sessionfactory" /> </bean> <bean id="historiqueservice" class="com.plasticum.service.historiqueserviceimpl"> <property name="sessionfactory" ref="sessionfactory" /> </bean> <bean id="descdefservice" class="com.plasticum.service.descdefserviceimpl"> <property name="sessionfactory" ref="sessionfactory" /> </bean> <bean id="defautservice" class="com.plasticum.service.defautserviceimpl"> <property name="sessionfactory" ref="sessionfactory" /> </bean> <bean id="critereservice" class="com.plasticum.service.critereserviceimpl"> <property name="sessionfactory" ref="sessionfactory" /> </bean> <bean id="articleservice" class="com.plasticum.service.articleserviceimpl"> <property name="sessionfactory" ref="sessionfactory" /> </bean> <context:component-scan base-package="com.plasticum.service" /> <bean id='datasource' class="org.apache.commons.dbcp.basicdatasource"> <property name="driverclassname" value="org.gjt.mm.mysql.driver" /> <property name="url" value="jdbc:mysql://localhost:3306/plasticum" /> <property name="username" value="root" /> <property name="password" value="" /> </bean> <bean id="sessionfactory" class="org.springframework.orm.hibernate4.localsessionfactorybean"> <property name="datasource" ref="datasource" /> <property name="packagestoscan" value="com.plasticum.model" /> <property name="hibernateproperties"> <props> <prop key="hibernate.dialect">org.hibernate.dialect.mysql5dialect</prop> <prop key="hibernate.show_sql">true</prop> </props> </property> </bean> <tx:annotation-driven transaction-manager="transactionmanager" /> <bean id="transactionmanager" class="org.springframework.orm.hibernate4.hibernatetransactionmanager" p:sessionfactory-ref="sessionfactory"> </bean> </beans>
this login.xhtml:
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:a4j="http://richfaces.org/a4j" xmlns:rich="http://richfaces.org/rich" xmlns:p="http://primefaces.org/ui" xmlns:s="http://jboss.com/products/seam/taglib"> <h:head> <title>authentification </title> </h:head> <h:body> <center> <h:form id="form"> <p:panel id="panel" header="authentification"> <p:messages id="msgs"/> <h:panelgrid columns="3"> <h:outputlabel for="identifiant" value="identifiant " /> <p:inputtext id="identifiant" value="#{loginbean.login}" required="true" label="identifiant"> <f:validatelength minimum="2" /> </p:inputtext> <p:message for="identifiant" display="icon"/> <h:outputlabel value="mot de passe" /> <p:password id="mp" value="#{loginbean.password}" label="mot de passe" required="true"> <f:validatelength minimum="2" /> <p:ajax update="mp" event="keyup" /> </p:password> <p:message for="mp" id="msgsurname" display="icon"/> </h:panelgrid> <p:commandbutton id="btn" value="valider" update="panel" action="# {loginbean.connect()}"/> </p:panel> </h:form> </center> </h:body> </html>
Comments
Post a Comment