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

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -