Roberto de Santis
Roberto de Santis

Reputation: 858

CDI session scoped bean is created only one time also if the user access from two different browser

i have a strange behaviour i'm seeing that if the user access to session bean from two different browser, the istance of session bean is the same. In my opinion this is an unespected behaviour. Someone have solved the same problem? I'm using Jsf 2.0, Spring 3.0.5, Hibernate and like WebServer Glassfish. Thank you in advance.

Update

import model.entity.Utente;
import java.io.Serializable;
import javax.enterprise.context.SessionScoped;
import javax.inject.Named;

/**
 *
 * @author 
 */
@Named
@SessionScoped
public class SessionBean implements Serializable {

this is how i declare CDI session bean

Upvotes: 0

Views: 886

Answers (1)

Ralph
Ralph

Reputation: 120791

I guess the bean is managed by Spring not by CDI. (If you want to use CDI with Spring you need to do a lot of work, only using javax.inject.Named is not enougth.)

Spring knows javax.inject.Named but not javax.enterprise.context.SessionScoped. To make a Spring Bean Session scoped, you need @org.springframework.context.annotation.Scope("session").

@see also: Spring Reference Chapter 3.5.4 Request, session, and global session scopes

Upvotes: 4

Related Questions