[jboss-jira] [JBoss JIRA] (WFLY-4384) ContextService (JSR236): transactional context always suspended

Maxim Frolov (JIRA) issues at jboss.org
Tue Feb 24 10:06:49 EST 2015


     [ https://issues.jboss.org/browse/WFLY-4384?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Maxim Frolov updated WFLY-4384:
-------------------------------
    Description: 
According to §3.3.5 of JSR-236 specification: 
??By using an execution property when creating the contextual proxy object, application components can choose to not suspend the transactional context on the thread ...??

Given the following EJB and Task:

{code:java}
@WebService(serviceName = "Jsr236WebService")
@Stateless
public class Jsr236WebService {
    @Inject Jsr236ManagedTask jsr236ManagedTask;
    @Resource ManagedExecutorService executor;
    @Resource ContextService contextService;
 
    @WebMethod(operationName = "hello")
    public String hello(@WebParam(name = "name") String txt) {
        Map<String, String> execProps = new HashMap<>();
        execProps.put(ManagedTask.TRANSACTION, ManagedTask.USE_TRANSACTION_OF_EXECUTION_THREAD);
        Future<String> future = executor.submit(
                contextService.createContextualProxy(jsr236ManagedTask, execProps, Callable.class));

        try {
            return future.get();
        } catch (InterruptedException | ExecutionException e) {
            throw new RuntimeException(e);
        }
    }
}
{code}

{code:java}
@Dependent
@Transactional(Transactional.TxType.MANDATORY)
public class Jsr236ManagedTask implements Callable<String>, ManagedTask {
    @Override
    public String call() {
        return "called";
    }

    @Override
    public Map<String, String> getExecutionProperties() {
       Map<String, String> execProps = new HashMap<>();
        execProps.put(ManagedTask.TRANSACTION, ManagedTask.USE_TRANSACTION_OF_EXECUTION_THREAD);
        return execProps;
    }
}
{code}


When the {{call()}} Method of the task is called the following exception occurs:
{noformat}
javax.transaction.TransactionalException: ARJUNA016110: Transaction is required for invocation
{noformat}


See maven test project [https://github.com/wrungel/bugs/tree/master/jsr236-test] on GitHub.




  was:
According to §3.3.5 of JSR-236 specification: 
??By using an execution property when creating the contextual proxy object, application components can choose to not suspend the transactional context on the thread ...??

Given the following EJB and Task:

{code:title=Jsr236WebService.java|borderStyle=solid}
@WebService(serviceName = "Jsr236WebService")
@Stateless
public class Jsr236WebService {
    @Inject Jsr236ManagedTask jsr236ManagedTask;
    @Resource ManagedExecutorService executor;
    @Resource ContextService contextService;
 
    @WebMethod(operationName = "hello")
    public String hello(@WebParam(name = "name") String txt) {
        Map<String, String> execProps = new HashMap<>();
        execProps.put(ManagedTask.TRANSACTION, ManagedTask.USE_TRANSACTION_OF_EXECUTION_THREAD);
        Future<String> future = executor.submit(
                contextService.createContextualProxy(jsr236ManagedTask, execProps, Callable.class));

        try {
            return future.get();
        } catch (InterruptedException | ExecutionException e) {
            throw new RuntimeException(e);
        }
    }
}
{code}

{code:java}
@Dependent
@Transactional(Transactional.TxType.MANDATORY)
public class Jsr236ManagedTask implements Callable<String>, ManagedTask {
    @Override
    public String call() {
        return "called";
    }

    @Override
    public Map<String, String> getExecutionProperties() {
       Map<String, String> execProps = new HashMap<>();
        execProps.put(ManagedTask.TRANSACTION, ManagedTask.USE_TRANSACTION_OF_EXECUTION_THREAD);
        return execProps;
    }
}
{code}


When the {{call()}} Method of the task is called the following exception occurs:
{noformat}
javax.transaction.TransactionalException: ARJUNA016110: Transaction is required for invocation
{noformat}


See maven test project [https://github.com/wrungel/bugs/tree/master/jsr236-test] on GitHub.






> ContextService (JSR236): transactional context always suspended
> ---------------------------------------------------------------
>
>                 Key: WFLY-4384
>                 URL: https://issues.jboss.org/browse/WFLY-4384
>             Project: WildFly
>          Issue Type: Bug
>            Reporter: Maxim Frolov
>            Assignee: Jason Greene
>            Priority: Critical
>
> According to §3.3.5 of JSR-236 specification: 
> ??By using an execution property when creating the contextual proxy object, application components can choose to not suspend the transactional context on the thread ...??
> Given the following EJB and Task:
> {code:java}
> @WebService(serviceName = "Jsr236WebService")
> @Stateless
> public class Jsr236WebService {
>     @Inject Jsr236ManagedTask jsr236ManagedTask;
>     @Resource ManagedExecutorService executor;
>     @Resource ContextService contextService;
>  
>     @WebMethod(operationName = "hello")
>     public String hello(@WebParam(name = "name") String txt) {
>         Map<String, String> execProps = new HashMap<>();
>         execProps.put(ManagedTask.TRANSACTION, ManagedTask.USE_TRANSACTION_OF_EXECUTION_THREAD);
>         Future<String> future = executor.submit(
>                 contextService.createContextualProxy(jsr236ManagedTask, execProps, Callable.class));
>         try {
>             return future.get();
>         } catch (InterruptedException | ExecutionException e) {
>             throw new RuntimeException(e);
>         }
>     }
> }
> {code}
> {code:java}
> @Dependent
> @Transactional(Transactional.TxType.MANDATORY)
> public class Jsr236ManagedTask implements Callable<String>, ManagedTask {
>     @Override
>     public String call() {
>         return "called";
>     }
>     @Override
>     public Map<String, String> getExecutionProperties() {
>        Map<String, String> execProps = new HashMap<>();
>         execProps.put(ManagedTask.TRANSACTION, ManagedTask.USE_TRANSACTION_OF_EXECUTION_THREAD);
>         return execProps;
>     }
> }
> {code}
> When the {{call()}} Method of the task is called the following exception occurs:
> {noformat}
> javax.transaction.TransactionalException: ARJUNA016110: Transaction is required for invocation
> {noformat}
> See maven test project [https://github.com/wrungel/bugs/tree/master/jsr236-test] on GitHub.



--
This message was sent by Atlassian JIRA
(v6.3.11#6341)



More information about the jboss-jira mailing list