简体   繁体   中英

WebBeans context with scope type annotation @RequestScoped does not exist within current thread

I'm using OpenJPA at TomEE server.

I build my .war, deploy it on server but i get this execption when i open page with my application:

javax.servlet.ServletException: WebBeans context with scope type annotation @RequestScoped does not exist within current thread
  javax.faces.webapp.FacesServlet.service(FacesServlet.java:229)
  filters.NoCacheFilter.doFilter(NoCacheFilter.java:42)
  org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:98)
  com.ocpsoft.pretty.PrettyFilter.doFilter(PrettyFilter.java:145)


javax.enterprise.context.ContextNotActiveException: WebBeans context with scope type annotation @RequestScoped does not exist within current thread
  org.apache.webbeans.container.BeanManagerImpl.getContext(BeanManagerImpl.java:351)
  org.apache.webbeans.intercept.NormalScopedBeanInterceptorHandler.getContextualCreationalContext(NormalScopedBeanInterceptorHandler.java:169)
  org.apache.webbeans.web.intercept.RequestScopedBeanInterceptorHandler.getContextualInstance(RequestScopedBeanInterceptorHandler.java:79)
  org.apache.webbeans.intercept.NormalScopedBeanInterceptorHandler.invoke(NormalScopedBeanInterceptorHandler.java:114)
  org.apache.webbeans.intercept.NormalScopedBeanInterceptorHandler.invoke(NormalScopedBeanInterceptorHandler.java:108)
  org.apache.webbeans.conversation.ConversationImpl_$$_javassist_0.isTransient(ConversationImpl_$$_javassist_0.java)
  org.apache.webbeans.jsf.WebBeansPhaseListener.beforePhase(WebBeansPhaseListener.java:106)
  org.apache.myfaces.lifecycle.PhaseListenerManager.informPhaseListenersBefore(PhaseListenerManager.java:77)
  org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:158)
  org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
  javax.faces.webapp.FacesServlet.service(FacesServlet.java:197)
  filters.NoCacheFilter.doFilter(NoCacheFilter.java:42)
  org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:98)
  com.ocpsoft.pretty.PrettyFilter.doFilter(PrettyFilter.java:145)

Ok, I find where is problem.

First of all, I had to read log of starting my TomEE server. I found there, that I have problem with one of my EJB class. I inject there resource with transaction manager:

   @Resource
   private UserTransaction userTransaction;

but I forgot to anotate my service EJB by:

@Stateless
@TransactionManagement(TransactionManagementType.BEAN)
public class TaskService {
  ...
}

如果“某人”不加批判地删除应用程序的登录页面,也可能会发生这种情况。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM