WELD-001303 No active contexts for scope type javax.enterprise.context.SessionScoped
Asked Answered
M

3

10

I have searched every where, but seem I cannot find out the best answer for me to resolved this error, there is my stack trace, can somebody tell me what happening with me, I have spent twos date to finding this error....:(

16:55:02,405 SEVERE [org.activiti.engine.impl.jobexecutor.TimerCatchIntermediateEventJobHandler] (Thread-16 (HornetQ-client-global-threads-982087879)) exception during timer execution: org.activiti.engine.ActivitiException: Exception while invoking TaskListener: WELD-001303 No active contexts for scope type javax.enterprise.context.SessionScoped
    at org.activiti.engine.impl.persistence.entity.TaskEntity.fireEvent(TaskEntity.java:529) [activiti-engine-5.11.jar:5.11]
    at ....
Caused by: org.jboss.weld.context.ContextNotActiveException: WELD-001303 No active contexts for scope type javax.enterprise.context.SessionScoped
    at org.jboss.weld.manager.BeanManagerImpl.getContext(BeanManagerImpl.java:598) [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
    at org.jboss.weld.bean.proxy.ContextBeanInstance.getInstance(ContextBeanInstance.java:71) [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
    at org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:79) [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
    at com.metro.wfm.shared.cdi.OverrideUserBean$Proxy$_$$_WeldClientProxy.hasBean(OverrideUserBean$Proxy$_$$_WeldClientProxy.java) [wfm-shared-0.0.2.jar:]
    ... 168 more
Mussel answered 19/3, 2013 at 10:2 Comment(2)
Impossible to answer without more detail. What is your application (ear? war?)Thoroughpaced
My application is war.Mussel
S
7

Session scoped contexts are only active during servlet calls with the service() method, or when executing a servlet filter. Not sure how you have your Activiti job setup, but it would appear not to be within the active period of a session context. As such, if you inject any beans that require @SessionScoped then the injection will fail.

The solution would be to remove the bean injections that require @SessionScoped, or to modify the beans.

Sesquicentennial answered 19/3, 2013 at 10:31 Comment(1)
Hi There, I using weld, and producing entitymanager which has to be valid for the user loggedin session and Injecting the entitymanager, and I have a use filter to intercept requests, I am getting the exception : org.jboss.weld.context.ContextNotActiveException: WELD-001303: No active contexts for scope type javax.enterprise.context.SessionScoped Please tell me how to do the same.SentilWitenagemot
S
6

I was facing the same problem, and based on the answer that @Perception posted, it seems that if you are using @Singleton (javax.ejb.Singleton) along with @Startup (javax.ejb.Startup) annotations on some initialization class, and also injecting other bean which is @SessionScoped or depends on other bean that is @SessionScoped, it will cause this WELD-001303 error.

Soccer answered 22/7, 2015 at 16:7 Comment(0)
R
0

You should separate frontend session logic. Imagine you have @SessionScoped bean for every logged user, it contains Account object.

After login, the same time save Account object into session bean and save Account object in the @ApplicationScoped bean, but in the HashMap(id, account), in the backend logic, every Singleton bean can access and get data from @Application Scoped bean. Even @Schedule method.

Reproduce answered 19/11, 2019 at 20:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.