Uploaded image for project: 'Forge'
  1. Forge
  2. FORGE-45

Injected EntityManager not work in servlet

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Won't Fix
    • None
    • None
    • None
    • None
    • Hide

      public class UploadFileServlet extends HttpServlet {
      @Inject
      private EntityManager entityManager;

      ...
      78 create(artifact);
      ...

      protected <T>void create( final T entity)

      { 102 getEntityManager().joinTransaction(); getEntityManager().persist(entity); }

      protected EntityManager getEntityManager()

      { return entityManager; }

      }

      Because @ConversationScoped used in org.jboss.forge.persistence.DatasourceProducer,when invoke create(artifact) then produce the following:

      Caused by: org.jboss.weld.context.ContextNotActiveException: WELD-001303 No active contexts for scope type javax.enterprise.context.ConversationScoped
      at org.jboss.weld.manager.BeanManagerImpl.getContext(BeanManagerImpl.java:664) file:C:%5CUsers%5CAdministrator%5Copt%5Cjboss-as7%5Cmodules%5Corg%5Cjboss%5Cweld%5Ccore%5Cmain%5Cweld-core-1.1.1.Final.jar:2011-04-04 15:54
      at org.jboss.weld.bean.proxy.ContextBeanInstance.getInstance(ContextBeanInstance.java:77) file:C:%5CUsers%5CAdministrator%5Copt%5Cjboss-as7%5Cmodules%5Corg%5Cjboss%5Cweld%5Ccore%5Cmain%5Cweld-core-1.1.1.Final.jar:2011-04-04 15:54
      at org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:124) file:C:%5CUsers%5CAdministrator%5Copt%5Cjboss-as7%5Cmodules%5Corg%5Cjboss%5Cweld%5Ccore%5Cmain%5Cweld-core-1.1.1.Final.jar:2011-04-04 15:54
      at org.jboss.weld.proxies.org$jboss$weld$beanProducerMethod-org$jboss$forge$persistence$DatasourceProducermethod_create()$$_WeldClientProxy.joinTransaction(org$jboss$weld$beanProducerMethod-org$jboss$forge$persistence$DatasourceProducermethod_create()$$_WeldClientProxy.java) file:C:%5CUsers%5CAdministrator%5Copt%5Cjboss-as7%5Cmodules%5Corg%5Cjboss%5Cweld%5Ccore%5Cmain%5Cweld-core-1.1.1.Final.jar:
      at net.flowas.artifactsWarehouse.view.UploadFileServlet.create(UploadFileServlet.java:102) [classes:]
      at net.flowas.artifactsWarehouse.view.UploadFileServlet.doPost(UploadFileServlet.java:78) [classes:]
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:754) file:C:%5CUsers%5CAdministrator%5Copt%5Cjboss-as7%5Cmodules%5Cjavax%5Cservlet%5Capi%5Cmain%5Cjboss-servlet-api_3.0_spec-1.0.0.Final.jar:1.0.0.Final
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) file:C:%5CUsers%5CAdministrator%5Copt%5Cjboss-as7%5Cmodules%5Cjavax%5Cservlet%5Capi%5Cmain%5Cjboss-servlet-api_3.0_spec-1.0.0.Final.jar:1.0.0.Final
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.6.0_24]
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [:1.6.0_24]
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [:1.6.0_24]
      at java.lang.reflect.Method.invoke(Method.java:597) [:1.6.0_24]
      at org.jboss.invocation.MethodInvokingInterceptor.processInvocation(MethodInvokingInterceptor.java:54)
      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:239)
      at org.jboss.as.ejb3.component.stateful.StatefulSessionSynchronizationInterceptor.processInvocation(StatefulSessionSynchronizationInterceptor.java:80)
      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:239)
      at org.jboss.as.ejb3.component.session.SessionBeanComponentConfiguration$1$1.processInvocation(SessionBeanComponentConfiguration.java:88)
      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:239)
      at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)
      at org.jboss.as.ee.component.DispatcherInterceptor.processInvocation(DispatcherInterceptor.java:47)
      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:239)
      at org.jboss.as.ejb3.component.stateful.ComponentInstanceInterceptor.processInvocation(ComponentInstanceInterceptor.java:48)
      at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:239)
      at org.jboss.invocation.InterceptorContext$Invocation.proceed(InterceptorContext.java:296)
      at org.jboss.ejb3.tx2.impl.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:286)
      ... 28 more

      Show
      public class UploadFileServlet extends HttpServlet { @Inject private EntityManager entityManager; ... 78 create(artifact); ... protected <T>void create( final T entity) { 102 getEntityManager().joinTransaction(); getEntityManager().persist(entity); } protected EntityManager getEntityManager() { return entityManager; } } Because @ConversationScoped used in org.jboss.forge.persistence.DatasourceProducer,when invoke create(artifact) then produce the following: Caused by: org.jboss.weld.context.ContextNotActiveException: WELD-001303 No active contexts for scope type javax.enterprise.context.ConversationScoped at org.jboss.weld.manager.BeanManagerImpl.getContext(BeanManagerImpl.java:664) file:C:%5CUsers%5CAdministrator%5Copt%5Cjboss-as7%5Cmodules%5Corg%5Cjboss%5Cweld%5Ccore%5Cmain%5Cweld-core-1.1.1.Final.jar:2011-04-04 15:54 at org.jboss.weld.bean.proxy.ContextBeanInstance.getInstance(ContextBeanInstance.java:77) file:C:%5CUsers%5CAdministrator%5Copt%5Cjboss-as7%5Cmodules%5Corg%5Cjboss%5Cweld%5Ccore%5Cmain%5Cweld-core-1.1.1.Final.jar:2011-04-04 15:54 at org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:124) file:C:%5CUsers%5CAdministrator%5Copt%5Cjboss-as7%5Cmodules%5Corg%5Cjboss%5Cweld%5Ccore%5Cmain%5Cweld-core-1.1.1.Final.jar:2011-04-04 15:54 at org.jboss.weld.proxies.org$jboss$weld$beanProducerMethod-org$jboss$forge$persistence$DatasourceProducermethod_create() $$_WeldClientProxy.joinTransaction(org$jboss$weld$beanProducerMethod-org$jboss$forge$persistence$DatasourceProducermethod_create() $$_WeldClientProxy.java) file:C:%5CUsers%5CAdministrator%5Copt%5Cjboss-as7%5Cmodules%5Corg%5Cjboss%5Cweld%5Ccore%5Cmain%5Cweld-core-1.1.1.Final.jar: at net.flowas.artifactsWarehouse.view.UploadFileServlet.create(UploadFileServlet.java:102) [classes:] at net.flowas.artifactsWarehouse.view.UploadFileServlet.doPost(UploadFileServlet.java:78) [classes:] at javax.servlet.http.HttpServlet.service(HttpServlet.java:754) file:C:%5CUsers%5CAdministrator%5Copt%5Cjboss-as7%5Cmodules%5Cjavax%5Cservlet%5Capi%5Cmain%5Cjboss-servlet-api_3.0_spec-1.0.0.Final.jar:1.0.0.Final at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) file:C:%5CUsers%5CAdministrator%5Copt%5Cjboss-as7%5Cmodules%5Cjavax%5Cservlet%5Capi%5Cmain%5Cjboss-servlet-api_3.0_spec-1.0.0.Final.jar:1.0.0.Final at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.6.0_24] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [:1.6.0_24] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [:1.6.0_24] at java.lang.reflect.Method.invoke(Method.java:597) [:1.6.0_24] at org.jboss.invocation.MethodInvokingInterceptor.processInvocation(MethodInvokingInterceptor.java:54) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:239) at org.jboss.as.ejb3.component.stateful.StatefulSessionSynchronizationInterceptor.processInvocation(StatefulSessionSynchronizationInterceptor.java:80) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:239) at org.jboss.as.ejb3.component.session.SessionBeanComponentConfiguration$1$1.processInvocation(SessionBeanComponentConfiguration.java:88) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:239) at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61) at org.jboss.as.ee.component.DispatcherInterceptor.processInvocation(DispatcherInterceptor.java:47) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:239) at org.jboss.as.ejb3.component.stateful.ComponentInstanceInterceptor.processInvocation(ComponentInstanceInterceptor.java:48) at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:239) at org.jboss.invocation.InterceptorContext$Invocation.proceed(InterceptorContext.java:296) at org.jboss.ejb3.tx2.impl.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:286) ... 28 more

    Description

      Injected EntityManager not work in servlet.
      Because @ConversationScoped used in org.jboss.forge.persistence.DatasourceProducer,when invoke create(artifact) then produce the this error "WELD-001303 No active contexts for scope type javax.enterprise.context.ConversationScoped".

      Attachments

        Activity

          People

            Unassigned Unassigned
            includeeasy_jira Liu Jianhong (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: