solarie
solarie

Reputation: 273

Cannot inject a request scoped bean as managed property of a session scoped bean

I have problem with JSF 2 when trying to made several beans injection i receive this error:

GRAVE: JSF ne pourra pas créé le bean géré contact_ lorsqu'il sera demandé.  
Les problèmes suivants ont été détectés :
 - Erreur inattendue lors du traitement du bean géré organisme_
 29 nov. 2012 20:56:23 com.sun.faces.application.view.FaceletViewHandlingStrategy handleRenderException
GRAVE: Error Rendering View[/index.xhtml]
com.sun.faces.mgbean.ManagedBeanCreationException: Impossible de créer le bean géré contact_.  Les problèmes suivants ont été détectés :
 - Erreur inattendue lors du traitement du bean géré organisme_

here is the beans code :

@ManagedBean (name="organisme_")    
@SessionScoped    
public class Organisme_  implements java.io.Serializable  {    
private static final long serialVersionUID = 4579411552477526993L;    
    private int idOrganisme;    
    @ManagedProperty(value="#{adresse_}")    
    private Adresse_ adresses_organisme;    
private String nomOrganisme;    
     private String telephone;    
     private String fax;    
     private Integer effectif;    
     private String message;    
     private String web;    
//getter and setter    

And

@ManagedBean(name="contact_")    
@RequestScoped    
public class Contact_  implements java.io.Serializable {    
private static final long serialVersionUID = 493917875769565440L;    
    private int idContact;    
     @ManagedProperty(value="#{organisme_}")    
     private Organisme_ organisme;    
 @ManagedProperty(value="#{adresse_}")    
     private Adresse_ adresses;    
     private String nomContact;    
     private String prenomContact;    
     private String email;    
     private String password;    
//getter and setter    
public String Connexion() {return "success";
}

And

@ManagedBean(name="adresse_")    
@RequestScoped    
public class Adresse_  implements java.io.Serializable {    
private int idAdresse;    
    private String pays;    
//getter and setter    

the index page contain :

commandLink action="#{contact_.Connexion()}"  style=" cursor: pointer; text-decoration: none;" </blink>

Upvotes: 1

Views: 1930

Answers (1)

SJuan76
SJuan76

Reputation: 24780

addresse_ is a RequestScoped bean. You cannot inject a RequestScoped bean in a SessionScoped bean (you will have lots of requests and its related beans and only a session and its bean, it would make no sense to inject one particular instance of addresse_ ignoring all the others).

Upvotes: 5

Related Questions