[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openejb-cvs
Subject:    [jira] [Commented] (TOMEE-509) Injected extended EntityManager is not registered (cannot be used for
From:       "Romain Manni-Bucau (JIRA)" <jira () apache ! org>
Date:       2012-10-30 16:08:12
Message-ID: 978401523.45034.1351613292642.JavaMail.jiratomcat () arcas
[Download RAW message or body]


    [ https://issues.apache.org/jira/browse/TOMEE-509?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13486970#comment-13486970 \
] 

Romain Manni-Bucau commented on TOMEE-509:
------------------------------------------

can match 1 or 1bis ;): stateful can hold business code. What i meant is stateful are \
not evil and can be used as any other bean. This way you avoid the side effects you \
can get with 2  
> Injected extended EntityManager is not registered (cannot be used for DB \
>                 operations)
> ------------------------------------------------------------------------------------
>  
> Key: TOMEE-509
> URL: https://issues.apache.org/jira/browse/TOMEE-509
> Project: TomEE
> Issue Type: Bug
> Affects Versions: 1.5.0, 1.5.1
> Environment: Windows 7 x64; jdk1.7.0_09 32 bit; \
>                 apache-tomee-1.5.1-20121026.064316-51-webprofile.zip
> Reporter: Donatas Ciuksys
> Priority: Critical
> 
> 1. Create class EntityManagerProducer:
> @SessionScoped
> @Stateful
> public class EntityManagerProducer implements Serializable {
> 
> @PersistenceContext(type=PersistenceContextType.EXTENDED)
> private EntityManager em;
> 
> @Produces
> public EntityManager getEntityManager() {
> return em;
> }
> }
> 2. Create injection client:
> @Named
> public class A {
> 
> @Inject
> private EntityManager em;
> public String getDelegateClassName() {
> return em.getDelegate().getClass().getCanonicalName();
> }
> 
> }
> 3. Create JSF page and try to call getDelegateClassName():
> <h:body>
> EntityManager is open: #{a.delegateClassName}
> </h:body>
> 4. Deploy (successful) and run the application - observe error message (printed in \
> browser): An Error Occurred:
> InternalError: an entity manager should already be registered for this extended \
> persistence unit viewId=/index.xhtml
> location=D:\dev\proj\templates\InjectionDemo\build\web\index.xhtml
> phaseId=RENDER_RESPONSE(6)
> Caused by:
> java.lang.IllegalStateException - InternalError: an entity manager should already \
> be registered for this extended persistence unit at \
> org.apache.openejb.persistence.JtaEntityManagerRegistry.getEntityManager(JtaEntityManagerRegistry.java:99)
>                 
> - Stack Trace
> java.lang.IllegalStateException: InternalError: an entity manager should already be \
> registered for this extended persistence unit  at \
> org.apache.openejb.persistence.JtaEntityManagerRegistry.getEntityManager(JtaEntityManagerRegistry.java:99)
>   at org.apache.openejb.persistence.JtaEntityManager.getEntityManager(JtaEntityManager.java:80)
>   at org.apache.openejb.persistence.JtaEntityManager.getDelegate(JtaEntityManager.java:114)
>   at org.apache.openejb.persistence.JtaEntityManager.getDelegate(JtaEntityManager.java:53)
>   at beans.A.getDelegateClassName(A.java:19)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> ...

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic