1

I use JSF with Spring security. I implement it.
My code:

@Named("userDetailsManagerImpl")
@Scope("application")
public class UserDetailBusinessImpl implements UserDetailsService {
    @Inject
    private MenuBackingBean menu;
}

Everything seem to be good. However I must define MenuBackingBean is application scope. I only want session scope for it. So I change scope to session, but I got an error below:
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userDetailsManagerImpl': Scope 'session' is not active for the current thread; consider defining a scoped proxy for this bean if you intend to refer to it from a singleton
I think this error cause by spring security set application for default scope.
I searched on Google but have no answer for this problem (maybe I have no right keyword searching). Please help me to solve, thank you
More info I used:

  • JSF 2.0
  • Spring security 3.1.2
  • Named and Inject from JSR 330
  • Scope annotation from springframework package
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
banhbaochay
  • 299
  • 1
  • 5
  • 14

1 Answers1

1

I suppose that you have this code somewhere:

@Inject
private YourSessionBean yourSessionBean;

// later in some method
this.yourSessionBean.doSomething();

Try to use javax.inject.Provider for all these cases:

@Inject
private Provider<YourSessionBean> yourSessionBeanProvider;

// later in some method
this.yourSessionBeanProvider.get().doSomething();
Maksym Demidas
  • 7,707
  • 1
  • 29
  • 36