Unable to use UserSession in entity listener

Hi,

I am unable to use UserSession in my entity listener. Is this expected? I didn’t see this limitation in the Entity Listener documentation. Thanks.

I get the following errors at runtime.

Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.haulmont.cuba.security.global.UserSession' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@javax.inject.Inject()}

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'sample_BaseUuidEntityWithReasonEntityListener': Unsatisfied dependency expressed through field 'userSession'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.haulmont.cuba.security.global.UserSession' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@javax.inject.Inject()}

Hi,

UserSession is not a Spring bean, use UserSessionSource instead.

Ah. Thank you very much.