He creado un Java EE de aplicaciones web con JSF 2 (PrimeFaces), Hibernate y Spring. He añadido todo lo necesario frascos y declaré mi frijoles en faces-config.

Cuando ejecuto mi aplicación me sale el siguiente excepción:


enter code here
An Error Occurred:
Erreur lors de linjection de ressources dans le bean géré «loginBean»
+- Stack Trace
com.sun.faces.mgbean.ManagedBeanCreationException: Erreur lors de linjection de     
ressources dans le bean géré «loginBean»
at com.sun.faces.mgbean.BeanBuilder.invokePostConstruct(BeanBuilder.java:229)
at com.sun.faces.mgbean.BeanBuilder.build(BeanBuilder.java:105)
at com.sun.faces.mgbean.BeanManager.createAndPush(BeanManager.java:409)
at com.sun.faces.mgbean.BeanManager.create(BeanManager.java:269)
at 
com.sun.faces.el.ManagedBeanELResolver.resolveBean(ManagedBeanELResolver.java:244)
at com.sun.faces.el.ManagedBeanELResolver.getValue(ManagedBeanELResolver.java:116)
at 
com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176)
at 
com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203)
at org.apache.el.parser.AstIdentifier.getValue(AstIdentifier.java:71)
at org.apache.el.parser.AstValue.getValue(AstValue.java:147)
at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:189)
at 
com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:109)
at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:194)
at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:182)
at javax.faces.component.UIOutput.getValue(UIOutput.java:169)
at org.primefaces.util.ComponentUtils.getValueToRender(ComponentUtils.java:64)
at 
org.primefaces.component.inputtext.InputTextRenderer.encodeMarkup
(InputTextRenderer.java:77)
at org.primefaces.component.inputtext.InputTextRenderer.encodeEnd
(InputTextRenderer.java:51)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875)
at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive
(HtmlBasicRenderer.java:312)
at com.sun.faces.renderkit.html_basic.GridRenderer.renderRow(GridRenderer.java:185)
at com.sun.faces.renderkit.html_basic.GridRenderer.encodeChildren
(GridRenderer.java:129)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:845)
at org.primefaces.renderkit.CoreRenderer.renderChild(CoreRenderer.java:59)
at org.primefaces.renderkit.CoreRenderer.renderChildren(CoreRenderer.java:47)
at org.primefaces.component.panel.PanelRenderer.encodeContent
(PanelRenderer.java:202)
at org.primefaces.component.panel.PanelRenderer.encodeMarkup
(PanelRenderer.java:119)
at org.primefaces.component.panel.PanelRenderer.encodeEnd(PanelRenderer.java:56)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1786)
at javax.faces.render.Renderer.encodeChildren(Renderer.java:168)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:845)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1779)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1782)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1782)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView
(FaceletViewHandlingStrategy.java:402)
at com.sun.faces.application.view.MultiViewHandler.renderView
(MultiViewHandler.java:125)
at com.sun.faces.lifecycle.RenderResponsePhase.execute
(RenderResponsePhase.java:121)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:594)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter
(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter
(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke
(StandardWrapperValve.java:224)
at org.apache.catalina.core.StandardContextValve.invoke
(StandardContextValve.java:169)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke
(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:928)
at org.apache.catalina.core.StandardEngineValve.invoke
(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process
(AbstractHttp11Processor.java:987)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process
(AbstractProtocol.java:539)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:300)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: com.sun.faces.spi.InjectionProviderException
at   com.sun.faces.vendor.WebContainerInjectionProvider.invokeAnnotatedMethod
(WebContainerInjectionProvider.java:119)
at com.sun.faces.vendor.WebContainerInjectionProvider.invokePostConstruct
(WebContainerInjectionProvider.java:99)
at com.sun.faces.mgbean.BeanBuilder.invokePostConstruct
(BeanBuilder.java:223)
... 56 more
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.sun.faces.vendor.WebContainerInjectionProvider.invokeAnnotatedMethod
(WebContainerInjectionProvider.java:117)
... 58 more
Caused by: java.lang.NullPointerException
at 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  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 a 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 [email protected] 
  • Ningún código. Y hay una muy clara Caused by: java.lang.NullPointerException en el seguimiento de la pila. ¿Qué versión de JSF es esto cierto?
InformationsquelleAutor user2338085 | 2013-05-15

1 Comentario

  1. 1

    creo que he resuelto este probleme mediante la adición de todos así lo requiriesen de anotación para mi managed bean como @managedbaen y @managedproperty, pero ahora tengo otro excepción de que yo no puedo inderstand este es mi 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 i = 0; i < 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;
    }
    }

    y este es mi 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>

    y esta mi solicitud 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>

    este es mi inicio de sesión.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>

Dejar respuesta

Please enter your comment!
Please enter your name here