2

In Wildfly 10 standalone mode I am getting SessionContext object using below snippet

InitialContext context = new InitialContext();
UserTransaction userTrans = null;
userTrans = (UserTransaction) m_Context.lookup("java:jboss/UserTransaction");
userTrans.setTransactionTimeout(600000);

then in SLSB I use

@Resource
protected SessionContext sessionontext;

But same code when executed in DOMAIN mode it fails to use SessionContext as its value is null.

Update

@Stateless(mappedName="AppManager")
@Local(value = AppManager.class)
@Remote(value = AppManagerRemote.class)
@TransactionAttribute(TransactionAttributeType.REQUIRED)
@TransactionManagement(TransactionManagementType.CONTAINER)


    public class AppManagerBean extends AppManagerAdapter implements AppManagerRemote
    {
      try
      {
      }
      catch(Exp..)
      {
        sessionontext.setRollbackOnly();  ///Here sessionontext is null
      }
    }

    public class AppManagerAdapter
    {
        @Resource
        protected SessionContext sessionontext;
    //
    }
happy
  • 2,550
  • 17
  • 64
  • 109
  • Your first code fragment does not seem to have anything to do with `SessionContext`. Please review and add more details – Steve C Sep 27 '17 at 00:37
  • @SteveC updated the question. This works in standalone mode of Wildfly – happy Sep 27 '17 at 06:09

1 Answers1

0

SessionContext injection should be in the stateless bean itself . So moved

@Resource
        protected SessionContext sessionontext;

from AppManagerAdapter to AppManagerBean then it worked.

happy
  • 2,550
  • 17
  • 64
  • 109