[ 
https://issues.apache.org/jira/browse/DELTASPIKE-552?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13954364#comment-13954364
 ] 

Akhbar Falafel commented on DELTASPIKE-552:
-------------------------------------------

Hmmmm...  I've tried incorporating the code in that workaround, but it isn't 
being called.  Here's what I've got implemented:

{code}
@Dependent
@Alternative
public class CustomUserTransactionStrategy extends
                BeanManagedUserTransactionStrategy {

        private static final long serialVersionUID = 820285503281945663L;

        /*
         * (non-Javadoc)
         * 
         * @see
         * 
org.apache.deltaspike.jpa.impl.transaction.BeanManagedUserTransactionStrategy
         * #resolveUserTransaction()
         */
        @Override
        protected UserTransaction resolveUserTransaction() {
                InitialContext context = null;
                try {
                        context = new InitialContext();
                        UserTransaction returnUserTransaction = 
(javax.transaction.UserTransaction) context
                                        .lookup("java:comp/UserTransaction");
                        return returnUserTransaction;
                } catch (NamingException ne) {
                        try {
                                javax.transaction.UserTransaction ut = 
(javax.transaction.UserTransaction) context
                                                .lookup("UserTransaction");
                                ut.getStatus();
                                return ut;
                        } catch (NamingException ne2) {
                                // // Try the other JBoss location
                                // return (UserTransaction) context
                                // .lookup("java:jboss/UserTransaction");
                        } catch (Exception e) {
                                // throw ne;
                        }
                }

                UserTransaction returnUserTransaction = 
super.resolveUserTransaction();
                return returnUserTransaction;
        }
}
{code}

Am I missing something?  Is there something more I need to do?  beans.xml 
modifications?

> "Failed to Create Component Instance" when using EntityRepository
> -----------------------------------------------------------------
>
>                 Key: DELTASPIKE-552
>                 URL: https://issues.apache.org/jira/browse/DELTASPIKE-552
>             Project: DeltaSpike
>          Issue Type: Bug
>          Components: Data-Module, JPA-Module
>    Affects Versions: 0.6
>         Environment: Wildfly 8.0.0
>            Reporter: Akhbar Falafel
>            Assignee: Thomas Hug
>
> I have code being deployed to Wildfly 8.0.0 that makes use of an 
> EntityRepository from the Deltaspike Data Module, injected into a stateless 
> EJB.  When I attempt to call a method within the code, I get the following 
> Exception:
> Caused by: java.lang.IllegalStateException: JBAS011048: Failed to construct 
> component instance
>       at 
> org.jboss.as.ee.component.BasicComponent.constructComponentInstance(BasicComponent.java:162)
>       at 
> org.jboss.as.ee.component.BasicComponent.constructComponentInstance(BasicComponent.java:133)
>       at 
> org.jboss.as.ee.component.BasicComponent.createInstance(BasicComponent.java:89)
>       at 
> org.jboss.as.ejb3.component.interceptors.NonPooledEJBComponentInstanceAssociatingInterceptor.processInvocation(NonPooledEJBComponentInstanceAssociatingInterceptor.java:53)
>  [wildfly-ejb3-8.0.0.Final.jar:8.0.0.Final]
>       at 
> org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
>       at 
> org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:273)
>  [wildfly-ejb3-8.0.0.Final.jar:8.0.0.Final]
>       ... 100 more
> ...
> Caused by: java.lang.IllegalStateException: JBAS014237: Only session and 
> message-driven beans with bean-managed transaction demarcation are allowed to 
> access UserTransaction
>       at 
> org.jboss.as.ejb3.component.allowedmethods.AllowedMethodsInformation.realCheckPermission(AllowedMethodsInformation.java:138)
>  [wildfly-ejb3-8.0.0.Final.jar:8.0.0.Final]
>       at 
> org.jboss.as.ejb3.component.allowedmethods.AllowedMethodsInformation.checkAllowed(AllowedMethodsInformation.java:112)
>  [wildfly-ejb3-8.0.0.Final.jar:8.0.0.Final]
>       at 
> org.jboss.as.ejb3.subsystem.EJB3UserTransactionAccessControlService$1.authorizeAccess(EJB3UserTransactionAccessControlService.java:53)
>  [wildfly-ejb3-8.0.0.Final.jar:8.0.0.Final]
>       at 
> org.jboss.as.txn.service.UserTransactionAccessControlService.authorizeAccess(UserTransactionAccessControlService.java:83)
>       at 
> org.jboss.as.txn.service.UserTransactionBindingService$1.getReference(UserTransactionBindingService.java:71)
>       at 
> org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:140)
>       ... 198 more
> This code worked flawlessly on JBoss EAP 6.2, so it appears to be something 
> specific to Wildfly.  It has not been modified at all.  However, if I remove 
> references to my EntityRepository and re-run my code it works without issue.



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to