java - @Resource UserTransaction is Null -
i have restful webservice implementation. maintaining transaction using usertransaction object injecting @resource. , see usertransaction object seems null. reason behind this?
import javax.transaction.usertransaction; @path("user") public class userimpl { @resource private usertransaction tx; @context httpservletrequest httpservletrequest; public void doaction() { try { tx.begin(); // work... } { tx.commit(); } } }
the reason behind usertransaction can injected managed component supports transactions. usual component supports transactions in java ee ejb bean. annotate userimpl class @stateless that. usertransaction indicates want manually manage transaction, have tell container @transactionmanagement. this:
@stateless @transactionmanagement(transactionmanagementtype.bean) @path("user") public class userimpl
Comments
Post a Comment