<div dir="ltr">Hi guys.<div><br></div><div>I&#39;m having some problems trying to programmatically inject some classes in my project.</div><div><br></div><div>Here an example.</div><div><br></div><div>A converter that uses some shared code from an stateful bean:</div>

<div><div>class Converter {</div><div>    @Inject</div><div>    StatefulService statefulService;</div><div><br></div><div>    public MyEntity converte(String string) {</div><div>        return statefulService.findById(Integer.valueOf(string));</div>

<div>    }</div><div>}</div></div><div><br></div><div><br></div><div><div>@Stateful</div><div>class StatefulService {</div><div>    @PersistenceContext(type = PersistenceContextType.EXTENDED)</div><div>    EntityManager em;</div>

<div><br></div><div>    @TransactionAttribute</div><div>    public MyEntity findById(Integer id) {</div><div>        return em.find(MyEntity.class, id);</div><div>    }</div><div>}</div></div><div><br></div><div><br></div>

<div>When I try to create a Converter instance:</div><div><div>BeanManager beanManager </div><div>     = (BeanManager)InitialContext.doLookup(&quot;java:comp/BeanManager&quot;);</div><div>Bean&lt;Converter&gt; bean </div>

<div>     = (Bean&lt;Converter&gt;) beanManager.resolve(beanManager.getBeans(Converter.class));</div><div>CreationalContext&lt;Converter&gt; ctx = beanManager.createCreationalContext(bean);</div></div><div><br></div><div>

Such as from Dependent context:</div><div><div>        Context context = beanManager.getContext(Dependent.class);</div><div>        Converter c = context.get(bean, ctx);</div></div><div><br></div><div>Or from BeanManager:</div>

<div>        Converter c = beanManager.getReference(bean, Converter.class, ctx);<br></div><div><br></div><div>It creates a Converter ok, But if I call any method that results in the EntityManager(EXTENDED) and I call twice in two different bean the second one fails because of the extended context.</div>

<div><br></div><div>e.g</div><div><div>Converter c = getConverter();</div><div>MyEntity converter = c.converte(&quot;1&quot;);</div><div>        </div><div>Converter c2 = getConverter();</div><div>MyEntity converter2 = c2.converte(&quot;1&quot;);//fails in Converter</div>

</div><div><br></div><div><br></div><div>Is there a way to programmatically create my beans using the same context?</div><div><br></div><div><br></div><div><br></div><div><br></div><div>Below the stacktrace</div><div><div>

17:44:41,130 ERROR [org.jboss.as.ejb3.tx.CMTTxInterceptor] (http--0.0.0.0-8080-2) javax.ejb.EJBTransactionRolledbackException: JBAS011437: Found extended persistence context in SFSB invocation call stack but that cannot be used because the transaction already has a transactional context associated with it.  This can be avoided by changing application code, either eliminate the extended persistence context or the transactional context.  See JPA spec 2.0 section 7.6.3.1.  Scoped persistence unit name=TestWeb-0.0.1-SNAPSHOT.war#JanarioPU, persistence context already in transaction =ExtendedEntityManager [TestWeb-0.0.1-SNAPSHOT.war#JanarioPU], extended persistence context =ExtendedEntityManager [TestWeb-0.0.1-SNAPSHOT.war#JanarioPU].</div>

<div>17:44:41,134 ERROR [org.jboss.ejb3.invocation] (http--0.0.0.0-8080-2) JBAS014134: EJB Invocation failed on component StatefulService for method public br.com.janario.testweb.cdi.MyEntity br.com.janario.testweb.cdi.StatefulService.findById(java.lang.Integer): javax.ejb.EJBTransactionRolledbackException: JBAS011437: Found extended persistence context in SFSB invocation call stack but that cannot be used because the transaction already has a transactional context associated with it.  This can be avoided by changing application code, either eliminate the extended persistence context or the transactional context.  See JPA spec 2.0 section 7.6.3.1.  Scoped persistence unit name=TestWeb-0.0.1-SNAPSHOT.war#JanarioPU, persistence context already in transaction =ExtendedEntityManager [TestWeb-0.0.1-SNAPSHOT.war#JanarioPU], extended persistence context =ExtendedEntityManager [TestWeb-0.0.1-SNAPSHOT.war#JanarioPU].</div>

<div><span class="" style="white-space:pre">        </span>at org.jboss.as.ejb3.tx.CMTTxInterceptor.handleInCallerTx(CMTTxInterceptor.java:139) [jboss-as-ejb3-7.1.1.Final.jar:7.1.1.Final]</div><div><span class="" style="white-space:pre">        </span>at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInCallerTx(CMTTxInterceptor.java:204) [jboss-as-ejb3-7.1.1.Final.jar:7.1.1.Final]</div>

<div><span class="" style="white-space:pre">        </span>at org.jboss.as.ejb3.tx.CMTTxInterceptor.required(CMTTxInterceptor.java:306) [jboss-as-ejb3-7.1.1.Final.jar:7.1.1.Final]</div><div><span class="" style="white-space:pre">        </span>at org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:190) [jboss-as-ejb3-7.1.1.Final.jar:7.1.1.Final]</div>

<div><span class="" style="white-space:pre">        </span>at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]</div><div><span class="" style="white-space:pre">        </span>at org.jboss.as.ejb3.component.interceptors.CurrentInvocationContextInterceptor.processInvocation(CurrentInvocationContextInterceptor.java:41) [jboss-as-ejb3-7.1.1.Final.jar:7.1.1.Final]</div>

<div><span class="" style="white-space:pre">        </span>at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]</div><div><span class="" style="white-space:pre">        </span>at org.jboss.as.ejb3.component.interceptors.LoggingInterceptor.processInvocation(LoggingInterceptor.java:59) [jboss-as-ejb3-7.1.1.Final.jar:7.1.1.Final]</div>

<div><span class="" style="white-space:pre">        </span>at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]</div><div><span class="" style="white-space:pre">        </span>at org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:50) [jboss-as-ee-7.1.1.Final.jar:7.1.1.Final]</div>

<div><span class="" style="white-space:pre">        </span>at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]</div><div><span class="" style="white-space:pre">        </span>at org.jboss.as.ejb3.component.interceptors.AdditionalSetupInterceptor.processInvocation(AdditionalSetupInterceptor.java:32) [jboss-as-ejb3-7.1.1.Final.jar:7.1.1.Final]</div>

<div><span class="" style="white-space:pre">        </span>at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]</div><div><span class="" style="white-space:pre">        </span>at org.jboss.as.ee.component.TCCLInterceptor.processInvocation(TCCLInterceptor.java:45) [jboss-as-ee-7.1.1.Final.jar:7.1.1.Final]</div>

<div><span class="" style="white-space:pre">        </span>at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]</div><div><span class="" style="white-space:pre">        </span>at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]</div>

<div><span class="" style="white-space:pre">        </span>at org.jboss.as.ee.component.ViewService$View.invoke(ViewService.java:165) [jboss-as-ee-7.1.1.Final.jar:7.1.1.Final]</div><div><span class="" style="white-space:pre">        </span>at org.jboss.as.ee.component.ViewDescription$1.processInvocation(ViewDescription.java:173) [jboss-as-ee-7.1.1.Final.jar:7.1.1.Final]</div>

<div><span class="" style="white-space:pre">        </span>at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]</div><div><span class="" style="white-space:pre">        </span>at org.jboss.as.ejb3.component.stateful.StatefulComponentIdInterceptor.processInvocation(StatefulComponentIdInterceptor.java:52) [jboss-as-ejb3-7.1.1.Final.jar:7.1.1.Final]</div>

<div><span class="" style="white-space:pre">        </span>at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]</div><div><span class="" style="white-space:pre">        </span>at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]</div>

<div><span class="" style="white-space:pre">        </span>at org.jboss.as.ee.component.ProxyInvocationHandler.invoke(ProxyInvocationHandler.java:72) [jboss-as-ee-7.1.1.Final.jar:7.1.1.Final]</div><div><span class="" style="white-space:pre">        </span>at br.com.janario.testweb.cdi.StatefulService$$$view6.findById(Unknown Source) [:]</div>

<div><span class="" style="white-space:pre">        </span>at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_40]</div><div><span class="" style="white-space:pre">        </span>at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [rt.jar:1.7.0_40]</div>

<div><span class="" style="white-space:pre">        </span>at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.7.0_40]</div><div><span class="" style="white-space:pre">        </span>at java.lang.reflect.Method.invoke(Method.java:606) [rt.jar:1.7.0_40]</div>

<div><span class="" style="white-space:pre">        </span>at org.jboss.weld.util.reflection.SecureReflections$13.work(SecureReflections.java:264) [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]</div><div><span class="" style="white-space:pre">        </span>at org.jboss.weld.util.reflection.SecureReflectionAccess.run(SecureReflectionAccess.java:52) [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]</div>

<div><span class="" style="white-space:pre">        </span>at org.jboss.weld.util.reflection.SecureReflectionAccess.runAsInvocation(SecureReflectionAccess.java:137) [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]</div><div><span class="" style="white-space:pre">        </span>at org.jboss.weld.util.reflection.SecureReflections.invoke(SecureReflections.java:260) [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]</div>

<div><span class="" style="white-space:pre">        </span>at org.jboss.weld.bean.proxy.EnterpriseBeanProxyMethodHandler.invoke(EnterpriseBeanProxyMethodHandler.java:111) [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]</div><div>

<span class="" style="white-space:pre">        </span>at org.jboss.weld.bean.proxy.EnterpriseTargetBeanInstance.invoke(EnterpriseTargetBeanInstance.java:56) [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]</div><div><span class="" style="white-space:pre">        </span>at org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:105) [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]</div>

<div><span class="" style="white-space:pre">        </span>at br.com.janario.testweb.cdi.StatefulService$Proxy$_$$_Weld$Proxy$.findById(StatefulService$Proxy$_$$_Weld$Proxy$.java) [:]</div><div><span class="" style="white-space:pre">        </span>at br.com.janario.testweb.cdi.Converter.converter(Converter.java:11) [:]</div>

<div><span class="" style="white-space:pre">        </span>at br.com.janario.testweb.cdi.MyService.work(MyService.java:25) [:]</div><div><span class="" style="white-space:pre">        </span>at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_40]</div>

<div><span class="" style="white-space:pre">        </span>at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [rt.jar:1.7.0_40]</div><div><span class="" style="white-space:pre">        </span>at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.7.0_40]</div>

<div><span class="" style="white-space:pre">        </span>at java.lang.reflect.Method.invoke(Method.java:606) [rt.jar:1.7.0_40]</div><div><span class="" style="white-space:pre">        </span>at org.jboss.as.ee.component.ManagedReferenceMethodInterceptorFactory$ManagedReferenceMethodInterceptor.processInvocation(ManagedReferenceMethodInterceptorFactory.java:72) [jboss-as-ee-7.1.1.Final.jar:7.1.1.Final]</div>

<div><span class="" style="white-space:pre">        </span>at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]</div><div><span class="" style="white-space:pre">        </span>at org.jboss.invocation.InterceptorContext$Invocation.proceed(InterceptorContext.java:374) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]</div>

<div><span class="" style="white-space:pre">        </span>at org.jboss.as.weld.ejb.Jsr299BindingsInterceptor.doMethodInterception(Jsr299BindingsInterceptor.java:127) [jboss-as-weld-7.1.1.Final.jar:7.1.1.Final]</div><div><span class="" style="white-space:pre">        </span>at org.jboss.as.weld.ejb.Jsr299BindingsInterceptor.processInvocation(Jsr299BindingsInterceptor.java:135) [jboss-as-weld-7.1.1.Final.jar:7.1.1.Final]</div>

<div><span class="" style="white-space:pre">        </span>at org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:36) [jboss-as-ee-7.1.1.Final.jar:7.1.1.Final]</div><div>

<span class="" style="white-space:pre">        </span>at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]</div><div><span class="" style="white-space:pre">        </span>at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]</div>

<div><span class="" style="white-space:pre">        </span>at org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:36) [jboss-as-ee-7.1.1.Final.jar:7.1.1.Final]</div><div>

<span class="" style="white-space:pre">        </span>at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]</div><div><span class="" style="white-space:pre">        </span>at org.jboss.as.jpa.interceptor.SBInvocationInterceptor.processInvocation(SBInvocationInterceptor.java:47) [jboss-as-jpa-7.1.1.Final.jar:7.1.1.Final]</div>

<div><span class="" style="white-space:pre">        </span>at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]</div><div><span class="" style="white-space:pre">        </span>at org.jboss.as.jpa.interceptor.SFSBInvocationInterceptor.processInvocation(SFSBInvocationInterceptor.java:58) [jboss-as-jpa-7.1.1.Final.jar:7.1.1.Final]</div>

<div><span class="" style="white-space:pre">        </span>at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]</div><div><span class="" style="white-space:pre">        </span>at org.jboss.as.ejb3.component.stateful.StatefulSessionSynchronizationInterceptor.processInvocation(StatefulSessionSynchronizationInterceptor.java:156) [jboss-as-ejb3-7.1.1.Final.jar:7.1.1.Final]</div>

<div><span class="" style="white-space:pre">        </span>at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]</div><div><span class="" style="white-space:pre">        </span>at org.jboss.as.weld.ejb.EjbRequestScopeActivationInterceptor.processInvocation(EjbRequestScopeActivationInterceptor.java:82) [jboss-as-weld-7.1.1.Final.jar:7.1.1.Final]</div>

<div><span class="" style="white-space:pre">        </span>at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]</div><div><span class="" style="white-space:pre">        </span>at org.jboss.invocation.InitialInterceptor.processInvocation(InitialInterceptor.java:21) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]</div>

<div><span class="" style="white-space:pre">        </span>at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]</div><div><span class="" style="white-space:pre">        </span>at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]</div>

<div><span class="" style="white-space:pre">        </span>at org.jboss.as.ee.component.interceptors.ComponentDispatcherInterceptor.processInvocation(ComponentDispatcherInterceptor.java:53) [jboss-as-ee-7.1.1.Final.jar:7.1.1.Final]</div>

<div><span class="" style="white-space:pre">        </span>at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]</div><div><span class="" style="white-space:pre">        </span>at org.jboss.as.ejb3.component.stateful.StatefulComponentInstanceInterceptor.processInvocation(StatefulComponentInstanceInterceptor.java:66) [jboss-as-ejb3-7.1.1.Final.jar:7.1.1.Final]</div>

<div><span class="" style="white-space:pre">        </span>at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]</div><div><span class="" style="white-space:pre">        </span>at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:228) [jboss-as-ejb3-7.1.1.Final.jar:7.1.1.Final]</div>

<div><span class="" style="white-space:pre">        </span>at org.jboss.as.ejb3.tx.CMTTxInterceptor.required(CMTTxInterceptor.java:304) [jboss-as-ejb3-7.1.1.Final.jar:7.1.1.Final]</div><div><span class="" style="white-space:pre">        </span>at org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:190) [jboss-as-ejb3-7.1.1.Final.jar:7.1.1.Final]</div>

<div><span class="" style="white-space:pre">        </span>at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]</div><div><span class="" style="white-space:pre">        </span>at org.jboss.as.ejb3.component.interceptors.CurrentInvocationContextInterceptor.processInvocation(CurrentInvocationContextInterceptor.java:41) [jboss-as-ejb3-7.1.1.Final.jar:7.1.1.Final]</div>

<div><span class="" style="white-space:pre">        </span>at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]</div><div><span class="" style="white-space:pre">        </span>at org.jboss.as.ejb3.component.interceptors.LoggingInterceptor.processInvocation(LoggingInterceptor.java:59) [jboss-as-ejb3-7.1.1.Final.jar:7.1.1.Final]</div>

<div><span class="" style="white-space:pre">        </span>at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]</div><div><span class="" style="white-space:pre">        </span>at org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:50) [jboss-as-ee-7.1.1.Final.jar:7.1.1.Final]</div>

<div><span class="" style="white-space:pre">        </span>at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]</div><div><span class="" style="white-space:pre">        </span>at org.jboss.as.ejb3.component.interceptors.AdditionalSetupInterceptor.processInvocation(AdditionalSetupInterceptor.java:32) [jboss-as-ejb3-7.1.1.Final.jar:7.1.1.Final]</div>

<div><span class="" style="white-space:pre">        </span>at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]</div><div><span class="" style="white-space:pre">        </span>at org.jboss.as.ee.component.TCCLInterceptor.processInvocation(TCCLInterceptor.java:45) [jboss-as-ee-7.1.1.Final.jar:7.1.1.Final]</div>

<div><span class="" style="white-space:pre">        </span>at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]</div><div><span class="" style="white-space:pre">        </span>at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]</div>

<div><span class="" style="white-space:pre">        </span>at org.jboss.as.ee.component.ViewService$View.invoke(ViewService.java:165) [jboss-as-ee-7.1.1.Final.jar:7.1.1.Final]</div><div><span class="" style="white-space:pre">        </span>at org.jboss.as.ee.component.ViewDescription$1.processInvocation(ViewDescription.java:173) [jboss-as-ee-7.1.1.Final.jar:7.1.1.Final]</div>

<div><span class="" style="white-space:pre">        </span>at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]</div><div><span class="" style="white-space:pre">        </span>at org.jboss.as.ejb3.component.stateful.StatefulComponentIdInterceptor.processInvocation(StatefulComponentIdInterceptor.java:52) [jboss-as-ejb3-7.1.1.Final.jar:7.1.1.Final]</div>

<div><span class="" style="white-space:pre">        </span>at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]</div><div><span class="" style="white-space:pre">        </span>at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]</div>

<div><span class="" style="white-space:pre">        </span>at org.jboss.as.ee.component.ProxyInvocationHandler.invoke(ProxyInvocationHandler.java:72) [jboss-as-ee-7.1.1.Final.jar:7.1.1.Final]</div><div><span class="" style="white-space:pre">        </span>at br.com.janario.testweb.cdi.MyService$$$view5.work(Unknown Source) [:]</div>

<div><span class="" style="white-space:pre">        </span>at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_40]</div><div><span class="" style="white-space:pre">        </span>at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [rt.jar:1.7.0_40]</div>

<div><span class="" style="white-space:pre">        </span>at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.7.0_40]</div><div><span class="" style="white-space:pre">        </span>at java.lang.reflect.Method.invoke(Method.java:606) [rt.jar:1.7.0_40]</div>

<div><span class="" style="white-space:pre">        </span>at org.jboss.weld.util.reflection.SecureReflections$13.work(SecureReflections.java:264) [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]</div><div><span class="" style="white-space:pre">        </span>at org.jboss.weld.util.reflection.SecureReflectionAccess.run(SecureReflectionAccess.java:52) [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]</div>

<div><span class="" style="white-space:pre">        </span>at org.jboss.weld.util.reflection.SecureReflectionAccess.runAsInvocation(SecureReflectionAccess.java:137) [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]</div><div><span class="" style="white-space:pre">        </span>at org.jboss.weld.util.reflection.SecureReflections.invoke(SecureReflections.java:260) [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]</div>

<div><span class="" style="white-space:pre">        </span>at org.jboss.weld.bean.proxy.EnterpriseBeanProxyMethodHandler.invoke(EnterpriseBeanProxyMethodHandler.java:111) [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]</div><div>

<span class="" style="white-space:pre">        </span>at org.jboss.weld.bean.proxy.EnterpriseTargetBeanInstance.invoke(EnterpriseTargetBeanInstance.java:56) [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]</div><div><span class="" style="white-space:pre">        </span>at org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:105) [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]</div>

<div><span class="" style="white-space:pre">        </span>at br.com.janario.testweb.cdi.MyService$Proxy$_$$_Weld$Proxy$.work(MyService$Proxy$_$$_Weld$Proxy$.java) [:]</div><div><span class="" style="white-space:pre">        </span>at br.com.janario.testweb.cdi.CdiInjectionTest.work(CdiInjectionTest.java:16) [:]</div>

<div><span class="" style="white-space:pre">        </span>at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_40]</div><div><span class="" style="white-space:pre">        </span>at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [rt.jar:1.7.0_40]</div>

<div><span class="" style="white-space:pre">        </span>at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.7.0_40]</div><div><span class="" style="white-space:pre">        </span>at java.lang.reflect.Method.invoke(Method.java:606) [rt.jar:1.7.0_40]</div>

<div><span class="" style="white-space:pre">        </span>at org.apache.el.parser.AstValue.invoke(AstValue.java:262) [jbossweb-7.0.13.Final.jar:]</div><div><span class="" style="white-space:pre">        </span>at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:278) [jbossweb-7.0.13.Final.jar:]</div>

<div><span class="" style="white-space:pre">        </span>at org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:39) [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]</div><div><span class="" style="white-space:pre">        </span>at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:50) [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]</div>

<div><span class="" style="white-space:pre">        </span>at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105) [jsf-impl-2.1.7-jbossorg-2.jar:]</div><div><span class="" style="white-space:pre">        </span>at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]</div>

<div><span class="" style="white-space:pre">        </span>at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102) [jsf-impl-2.1.7-jbossorg-2.jar:]</div><div><span class="" style="white-space:pre">        </span>at javax.faces.component.UICommand.broadcast(UICommand.java:315) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]</div>

<div><span class="" style="white-space:pre">        </span>at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]</div><div><span class="" style="white-space:pre">        </span>at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1259) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]</div>

<div><span class="" style="white-space:pre">        </span>at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81) [jsf-impl-2.1.7-jbossorg-2.jar:]</div><div><span class="" style="white-space:pre">        </span>at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) [jsf-impl-2.1.7-jbossorg-2.jar:]</div>

<div><span class="" style="white-space:pre">        </span>at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118) [jsf-impl-2.1.7-jbossorg-2.jar:]</div><div><span class="" style="white-space:pre">        </span>at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]</div>

<div><span class="" style="white-space:pre">        </span>at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329) [jbossweb-7.0.13.Final.jar:]</div><div><span class="" style="white-space:pre">        </span>at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:]</div>

<div><span class="" style="white-space:pre">        </span>at org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:62) [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]</div><div><span class="" style="white-space:pre">        </span>at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.13.Final.jar:]</div>

<div><span class="" style="white-space:pre">        </span>at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:]</div><div><span class="" style="white-space:pre">        </span>at org.ocpsoft.rewrite.servlet.RewriteFilter.doFilter(RewriteFilter.java:199) [rewrite-servlet-2.0.5.Final.jar:2.0.5.Final]</div>

<div><span class="" style="white-space:pre">        </span>at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.13.Final.jar:]</div><div><span class="" style="white-space:pre">        </span>at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:]</div>

<div><span class="" style="white-space:pre">        </span>at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [jbossweb-7.0.13.Final.jar:]</div><div><span class="" style="white-space:pre">        </span>at org.apache.catalina.core.StandardContextValve.__invoke(StandardContextValve.java:161) [jbossweb-7.0.13.Final.jar:]</div>

<div><span class="" style="white-space:pre">        </span>at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java) [jbossweb-7.0.13.Final.jar:]</div><div><span class="" style="white-space:pre">        </span>at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50) [jboss-as-jpa-7.1.1.Final.jar:7.1.1.Final]</div>

<div><span class="" style="white-space:pre">        </span>at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]</div><div><span class="" style="white-space:pre">        </span>at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155) [jbossweb-7.0.13.Final.jar:]</div>

<div><span class="" style="white-space:pre">        </span>at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.13.Final.jar:]</div><div><span class="" style="white-space:pre">        </span>at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.13.Final.jar:]</div>

<div><span class="" style="white-space:pre">        </span>at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368) [jbossweb-7.0.13.Final.jar:]</div><div><span class="" style="white-space:pre">        </span>at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.13.Final.jar:]</div>

<div><span class="" style="white-space:pre">        </span>at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671) [jbossweb-7.0.13.Final.jar:]</div><div><span class="" style="white-space:pre">        </span>at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930) [jbossweb-7.0.13.Final.jar:]</div>

<div><span class="" style="white-space:pre">        </span>at java.lang.Thread.run(Thread.java:724) [rt.jar:1.7.0_40]</div><div>Caused by: javax.ejb.EJBException: JBAS011437: Found extended persistence context in SFSB invocation call stack but that cannot be used because the transaction already has a transactional context associated with it.  This can be avoided by changing application code, either eliminate the extended persistence context or the transactional context.  See JPA spec 2.0 section 7.6.3.1.  Scoped persistence unit name=TestWeb-0.0.1-SNAPSHOT.war#JanarioPU, persistence context already in transaction =ExtendedEntityManager [TestWeb-0.0.1-SNAPSHOT.war#JanarioPU], extended persistence context =ExtendedEntityManager [TestWeb-0.0.1-SNAPSHOT.war#JanarioPU].</div>

<div><span class="" style="white-space:pre">        </span>at org.jboss.as.jpa.container.ExtendedEntityManager.internalAssociateWithJtaTx(ExtendedEntityManager.java:126) [jboss-as-jpa-7.1.1.Final.jar:7.1.1.Final]</div><div><span class="" style="white-space:pre">        </span>at org.jboss.as.jpa.container.SFSBCallStack.pushCall(SFSBCallStack.java:159) [jboss-as-jpa-7.1.1.Final.jar:7.1.1.Final]</div>

<div><span class="" style="white-space:pre">        </span>at org.jboss.as.jpa.interceptor.SFSBInvocationInterceptor.processInvocation(SFSBInvocationInterceptor.java:56) [jboss-as-jpa-7.1.1.Final.jar:7.1.1.Final]</div><div><span class="" style="white-space:pre">        </span>at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]</div>

<div><span class="" style="white-space:pre">        </span>at org.jboss.as.ejb3.component.stateful.StatefulSessionSynchronizationInterceptor.processInvocation(StatefulSessionSynchronizationInterceptor.java:156) [jboss-as-ejb3-7.1.1.Final.jar:7.1.1.Final]</div>

<div><span class="" style="white-space:pre">        </span>at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]</div><div><span class="" style="white-space:pre">        </span>at org.jboss.as.weld.ejb.EjbRequestScopeActivationInterceptor.processInvocation(EjbRequestScopeActivationInterceptor.java:82) [jboss-as-weld-7.1.1.Final.jar:7.1.1.Final]</div>

<div><span class="" style="white-space:pre">        </span>at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]</div><div><span class="" style="white-space:pre">        </span>at org.jboss.invocation.InitialInterceptor.processInvocation(InitialInterceptor.java:21) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]</div>

<div><span class="" style="white-space:pre">        </span>at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]</div><div><span class="" style="white-space:pre">        </span>at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]</div>

<div><span class="" style="white-space:pre">        </span>at org.jboss.as.ee.component.interceptors.ComponentDispatcherInterceptor.processInvocation(ComponentDispatcherInterceptor.java:53) [jboss-as-ee-7.1.1.Final.jar:7.1.1.Final]</div>

<div><span class="" style="white-space:pre">        </span>at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]</div><div><span class="" style="white-space:pre">        </span>at org.jboss.as.ejb3.component.stateful.StatefulComponentInstanceInterceptor.processInvocation(StatefulComponentInstanceInterceptor.java:66) [jboss-as-ejb3-7.1.1.Final.jar:7.1.1.Final]</div>

<div><span class="" style="white-space:pre">        </span>at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final.jar:1.1.1.Final]</div><div><span class="" style="white-space:pre">        </span>at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInCallerTx(CMTTxInterceptor.java:202) [jboss-as-ejb3-7.1.1.Final.jar:7.1.1.Final]</div>

<div><span class="" style="white-space:pre">        </span>... 140 more</div></div><div><br></div></div>