kuba44 kuba44 - 5 months ago 21
Java Question

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)

Answer

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 {
  ...
}
Comments