集成jsf和spring org.springframework.beans.factory.CannotLoadBeanClassException:找不到类[org.primefaces.spring.scope.ViewScope]

时间:2014-12-03 20:03:18

标签: spring hibernate maven jsf classnotfoundexception

我正在尝试用jsf,spring,hibernate和maven编写一个项目,但我有一个问题,我得到一个空的数据表。并且这个异常类没有发现ViewScope,即使我的包中有这个类。

19:44:04,448 ERROR [org.springframework.web.context.ContextLoader] (MSC service thread 1-8) Context initialization failed: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.beans.factory.config.CustomScopeConfigurer#0' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Cannot create inner bean 'org.primefaces.spring.scope.ViewScope#1299ebc' of type [org.primefaces.spring.scope.ViewScope] while setting bean property 'scopes' with key [TypedStringValue: value [view], target type [null]]; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.primefaces.spring.scope.ViewScope] for bean with name 'org.primefaces.spring.scope.ViewScope#1299ebc' defined in ServletContext resource [/WEB-INF/applicationContext.xml]; nested exception is java.lang.ClassNotFoundException: org.primefaces.spring.scope.ViewScope from [Module "deployment.Projet_sqli.war:main" from Service Module Loader]
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:230) [spring-2.5.6.jar:2.5.6]
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:117) [spring-2.5.6.jar:2.5.6]
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveManagedMap(BeanDefinitionValueResolver.java:320) [spring-2.5.6.jar:2.5.6]
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:134) [spring-2.5.6.jar:2.5.6]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1245) [spring-2.5.6.jar:2.5.6]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1010) [spring-2.5.6.jar:2.5.6]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472) [spring-2.5.6.jar:2.5.6]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409) [spring-2.5.6.jar:2.5.6]
    at java.security.AccessController.doPrivileged(Native Method) [rt.jar:1.7.0_71]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380) [spring-2.5.6.jar:2.5.6]
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264) [spring-2.5.6.jar:2.5.6]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) [spring-2.5.6.jar:2.5.6]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261) [spring-2.5.6.jar:2.5.6]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185) [spring-2.5.6.jar:2.5.6]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164) [spring-2.5.6.jar:2.5.6]
    at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:880) [spring-2.5.6.jar:2.5.6]
    at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:533) [spring-2.5.6.jar:2.5.6]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:362) [spring-2.5.6.jar:2.5.6]
    at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255) [spring-2.5.6.jar:2.5.6]
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199) [spring-2.5.6.jar:2.5.6]
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45) [spring-2.5.6.jar:2.5.6]
    at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:3392) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:3850) [jbossweb-7.0.13.Final.jar:]
    at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:90) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_71]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_71]
    at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_71]
Caused by: org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.primefaces.spring.scope.ViewScope] for bean with name 'org.primefaces.spring.scope.ViewScope#1299ebc' defined in ServletContext resource [/WEB-INF/applicationContext.xml]; nested exception is java.lang.ClassNotFoundException: org.primefaces.spring.scope.ViewScope from [Module "deployment.Projet_sqli.war:main" from Service Module Loader]
    at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1141) [spring-2.5.6.jar:2.5.6]
    at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1105) [spring-2.5.6.jar:2.5.6]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:386) [spring-2.5.6.jar:2.5.6]
    at java.security.AccessController.doPrivileged(Native Method) [rt.jar:1.7.0_71]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380) [spring-2.5.6.jar:2.5.6]
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:219) [spring-2.5.6.jar:2.5.6]
    ... 28 more
Caused by: java.lang.ClassNotFoundException: org.primefaces.spring.scope.ViewScope from [Module "deployment.Projet_sqli.war:main" from Service Module Loader]
    at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)
    at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468)
    at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456)
    at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)
    at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120)
    at org.springframework.util.ClassUtils.forName(ClassUtils.java:211) [spring-2.5.6.jar:2.5.6]
    at org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:385) [spring-2.5.6.jar:2.5.6]
    at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1138) [spring-2.5.6.jar:2.5.6]
    ... 33 more

19:44:04,478 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/Projet_sqli]] (MSC service thread 1-8) Exception lors de l'envoi de l'évènement contexte initialisé (context initialized) à l'instance de classe d'écoute (listener) org.springframework.web.context.ContextLoaderListener: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.beans.factory.config.CustomScopeConfigurer#0' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Cannot create inner bean 'org.primefaces.spring.scope.ViewScope#1299ebc' of type [org.primefaces.spring.scope.ViewScope] while setting bean property 'scopes' with key [TypedStringValue: value [view], target type [null]]; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.primefaces.spring.scope.ViewScope] for bean with name 'org.primefaces.spring.scope.ViewScope#1299ebc' defined in ServletContext resource [/WEB-INF/applicationContext.xml]; nested exception is java.lang.ClassNotFoundException: org.primefaces.spring.scope.ViewScope from [Module "deployment.Projet_sqli.war:main" from Service Module Loader]
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:230) [spring-2.5.6.jar:2.5.6]
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:117) [spring-2.5.6.jar:2.5.6]
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveManagedMap(BeanDefinitionValueResolver.java:320) [spring-2.5.6.jar:2.5.6]
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:134) [spring-2.5.6.jar:2.5.6]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1245) [spring-2.5.6.jar:2.5.6]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1010) [spring-2.5.6.jar:2.5.6]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472) [spring-2.5.6.jar:2.5.6]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409) [spring-2.5.6.jar:2.5.6]
    at java.security.AccessController.doPrivileged(Native Method) [rt.jar:1.7.0_71]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380) [spring-2.5.6.jar:2.5.6]
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264) [spring-2.5.6.jar:2.5.6]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) [spring-2.5.6.jar:2.5.6]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261) [spring-2.5.6.jar:2.5.6]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185) [spring-2.5.6.jar:2.5.6]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164) [spring-2.5.6.jar:2.5.6]
    at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:880) [spring-2.5.6.jar:2.5.6]
    at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:533) [spring-2.5.6.jar:2.5.6]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:362) [spring-2.5.6.jar:2.5.6]
    at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255) [spring-2.5.6.jar:2.5.6]
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199) [spring-2.5.6.jar:2.5.6]
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45) [spring-2.5.6.jar:2.5.6]
    at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:3392) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:3850) [jbossweb-7.0.13.Final.jar:]
    at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:90) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_71]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_71]
    at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_71]
Caused by: org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.primefaces.spring.scope.ViewScope] for bean with name 'org.primefaces.spring.scope.ViewScope#1299ebc' defined in ServletContext resource [/WEB-INF/applicationContext.xml]; nested exception is java.lang.ClassNotFoundException: org.primefaces.spring.scope.ViewScope from [Module "deployment.Projet_sqli.war:main" from Service Module Loader]
    at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1141) [spring-2.5.6.jar:2.5.6]
    at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1105) [spring-2.5.6.jar:2.5.6]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:386) [spring-2.5.6.jar:2.5.6]
    at java.security.AccessController.doPrivileged(Native Method) [rt.jar:1.7.0_71]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380) [spring-2.5.6.jar:2.5.6]
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:219) [spring-2.5.6.jar:2.5.6]
    ... 28 more
Caused by: java.lang.ClassNotFoundException: org.primefaces.spring.scope.ViewScope from [Module "deployment.Projet_sqli.war:main" from Service Module Loader]
    at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)
    at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468)
    at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456)
    at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)
    at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120)
    at org.springframework.util.ClassUtils.forName(ClassUtils.java:211) [spring-2.5.6.jar:2.5.6]
    at org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:385) [spring-2.5.6.jar:2.5.6]
    at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1138) [spring-2.5.6.jar:2.5.6]
    ... 33 more

19:44:04,638 INFOS [javax.enterprise.resource.webcontainer.jsf.config] (MSC service thread 1-8) Initialisation de Mojarra 2.1.7-jbossorg-1 (20120227-1401) pour le contexte «/Projet_sqli»
19:44:06,392 INFO  [org.hibernate.validator.util.Version] (MSC service thread 1-8) Hibernate Validator 4.2.0.Final
19:44:08,097 INFOS [org.primefaces.webapp.PostConstructApplicationEventListener] (MSC service thread 1-8) Running on PrimeFaces 5.1
19:44:08,138 INFOS [javax.enterprise.resource.webcontainer.jsf.config] (MSC service thread 1-8) Monitoring jndi:/default-host/Projet_sqli/WEB-INF/faces-config.xml for modifications
19:44:08,318 ERROR [org.apache.catalina.core.StandardContext] (MSC service thread 1-8) Error listenerStart
19:44:08,318 ERROR [org.apache.catalina.core.StandardContext] (MSC service thread 1-8) Erreur de démarrage du contexte [/Projet_sqli] suite aux erreurs précédentes
19:44:08,318 INFO  [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/Projet_sqli]] (MSC service thread 1-8) Closing Spring root WebApplicationContext
19:44:08,348 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-8) MSC00001: Failed to start service jboss.web.deployment.default-host./Projet_sqli: org.jboss.msc.service.StartException in service jboss.web.deployment.default-host./Projet_sqli: JBAS018040: Failed to start context
    at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:95)
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_71]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_71]
    at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_71]

19:44:08,348 INFO  [org.jboss.as] (MSC service thread 1-7) JBAS015951: Admin console listening on http://127.0.0.1:9990
19:44:08,348 ERROR [org.jboss.as] (MSC service thread 1-7) JBAS015875: JBoss AS 7.1.1.Final "Brontes" started (with errors) in 13629ms - Started 278 of 357 services (2 services failed or missing dependencies, 76 services are passive or on-demand)
19:44:08,548 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS015870: Deploy of deployment "Projet_sqli.war" was rolled back with failure message {"JBAS014671: Failed services" => {"jboss.web.deployment.default-host./Projet_sqli" => "org.jboss.msc.service.StartException in service jboss.web.deployment.default-host./Projet_sqli: JBAS018040: Failed to start context"}}
19:44:08,548 INFO  [org.jboss.as.controller] (DeploymentScanner-threads - 2) JBAS014774: Service status report
JBAS014777:   Services which failed to start:      service jboss.web.deployment.default-host./Projet_sqli: org.jboss.msc.service.StartException in service jboss.web.deployment.default-host./Projet_sqli: JBAS018040: Failed to start context

这些是我的课程: CollaborateurBean.java

package controller;

import java.util.Date;
import java.util.List;

import javax.annotation.PostConstruct;

import model.CollaborateurMetier;
import net.vo.Collaborateur;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;


@Component
@Scope("view")
public class CollaborateurBean implements java.io.Serializable{

    /**
     * 
     */
    private static final long serialVersionUID = 1L;

    @Autowired
    private CollaborateurMetier collaborateurMetier;
    private List<Collaborateur> listeCollaborateurs;
    private int idCollaborateur;
    private String cin;
    private String nom;
    private String prenom;
    private Date dateNaissance;
    private String telephone;
    private String email;

    @PostConstruct
    public void init() {

        listeCollaborateurs = collaborateurMetier.getAllCollaborateurs();
    }

    public CollaborateurMetier getCollaborateurMetier() {
        return collaborateurMetier;
    }

    public void setCollaborateurMetier(CollaborateurMetier collaborateurMetier) {
        this.collaborateurMetier = collaborateurMetier;
    }

    public List<Collaborateur> getListeCollaborateurs() {
        return listeCollaborateurs;
    }

    public void setListeCollaborateurs(List<Collaborateur> listeCollaborateurs) {
        this.listeCollaborateurs = listeCollaborateurs;
    }

    public int getIdCollaborateur() {
        return idCollaborateur;
    }

    public void setIdCollaborateur(int idCollaborateur) {
        this.idCollaborateur = idCollaborateur;
    }

    public String getCin() {
        return cin;
    }

    public void setCin(String cin) {
        this.cin = cin;
    }

    public String getNom() {
        return nom;
    }

    public void setNom(String nom) {
        this.nom = nom;
    }

    public String getPrenom() {
        return prenom;
    }

    public void setPrenom(String prenom) {
        this.prenom = prenom;
    }

    public Date getDateNaissance() {
        return dateNaissance;
    }

    public void setDateNaissance(Date dateNaissance) {
        this.dateNaissance = dateNaissance;
    }

    public String getTelephone() {
        return telephone;
    }

    public void setTelephone(String telephone) {
        this.telephone = telephone;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

}

collaborateur.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:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"> 

 <h:head>
        <title>Facelet Title</title>
    </h:head>
    <h:body style="background-color: #ECF3FD;">
<h:form id="form">


   <p:dataTable id="display" var="listeCollaborateurs" value="#{collaborateurBean.listeCollaborateurs}" editable="true" style="margin-bottom:10px">
       <f:facet name="header">
           Liste des collaborateurs
       </f:facet>

       <p:column headerText="Id Collaborateur">
           <p:cellEditor>
               <f:facet name="output"><h:outputText value="#{listeCollaborateurs.idCollaborateur}" /></f:facet>
               <f:facet name="input"><p:inputText id="modelInput" value="#{listeCollaborateurs.idCollaborateur}" style="width:100%"/></f:facet>
           </p:cellEditor>
       </p:column>

       <p:column headerText="Raison sociale">
           <p:cellEditor>
               <f:facet name="output"><h:outputText value="#{listeCollaborateurs.cin}" /></f:facet>
               <f:facet name="input"><p:inputText value="#{listeCollaborateurs.cin}" style="width:100%" label="Year"/></f:facet>
           </p:cellEditor>
       </p:column>

       <p:column headerText="RIB">
           <p:cellEditor>
               <f:facet name="output"><h:outputText value="#{listeCollaborateurs.nom}" /></f:facet>
               <f:facet name="input"><p:inputText value="#{listeCollaborateurs.nom}" style="width:100%" label="Year"/></f:facet>
           </p:cellEditor>
       </p:column>

       <p:column headerText="Adresse">
           <p:cellEditor>
               <f:facet name="output"><h:outputText value="#{listeCollaborateurs.prenom}" /></f:facet>
               <f:facet name="input"><p:inputText value="#{listeCollaborateurs.prenom}" style="width:100%" label="Year"/></f:facet>
           </p:cellEditor>
       </p:column>
  <p:column headerText="Date de naissance">
           <p:cellEditor>
               <f:facet name="output"><h:outputText value="#{listeCollaborateurs.dateNaissance}" /></f:facet>
               <f:facet name="input"><p:inputText value="#{listeCollaborateurs.dateNaissance}" style="width:100%" label="Year"/></f:facet>
           </p:cellEditor>
       </p:column>
       <p:column headerText="Téléphone">
           <p:cellEditor>
               <f:facet name="output"><h:outputText value="#{listeCollaborateurs.telephone}" /></f:facet>
               <f:facet name="input"><p:inputText value="#{listeCollaborateurs.telephone}" style="width:100%" label="Year"/></f:facet>
           </p:cellEditor>
       </p:column>
       <p:column headerText="Email">
           <p:cellEditor>
               <f:facet name="output"><h:outputText value="#{listeCollaborateurs.email}" /></f:facet>
               <f:facet name="input"><p:inputText value="#{listeCollaborateurs.email}" style="width:100%" label="Year"/></f:facet>
           </p:cellEditor>
       </p:column>

   </p:dataTable>

</h:form>
</h:body>
</html>

ViewScope.java

package org.primefaces.spring.scope;

import java.util.Map;

import javax.faces.context.FacesContext;

import org.springframework.beans.factory.ObjectFactory;
import org.springframework.beans.factory.config.Scope;

public class ViewScope implements Scope {

    public Object get(String name, ObjectFactory objectFactory) {
        Map<String,Object> viewMap = FacesContext.getCurrentInstance().getViewRoot().getViewMap();

        if(viewMap.containsKey(name)) {
            return viewMap.get(name);
        } else {
            Object object = objectFactory.getObject();
            viewMap.put(name, object);

            return object;
        }
    }

    public Object remove(String name) {
        return FacesContext.getCurrentInstance().getViewRoot().getViewMap().remove(name);
    }

    public String getConversationId() {
        return null;
    }

    public void registerDestructionCallback(String name, Runnable callback) {
        //Not supported
    }

    public Object resolveContextualObject(String key) {
        return null;
    }
}

faces-config.xml中

<?xml version="1.0"?>
<faces-config version="2.2" 
              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/web-facesconfig_2_2.xsd">
<application>
    <el-resolver>
        org.springframework.web.jsf.el.SpringBeanFacesELResolver
    </el-resolver>
</application>

</faces-config>

1 个答案:

答案 0 :(得分:0)

我修复了这个addind在pom.xml中的一些spring依赖项

 <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring</artifactId>
    <version>2.5.6</version>
</dependency>
    <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-core</artifactId>
    <version>4.1.2.RELEASE</version>
</dependency>
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-context</artifactId>
    <version>4.1.2.RELEASE</version>
</dependency>
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-web</artifactId>
    <version>4.1.2.RELEASE</version>
</dependency>
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-tx</artifactId>
    <version>4.1.2.RELEASE</version>
</dependency>
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-orm</artifactId>
    <version>4.1.2.RELEASE</version>
</dependency>
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-test</artifactId>
    <version>4.1.2.RELEASE</version>
</dependency>