Like thread local caches, transaction local caches should only by accessed where the correct context (transaction) exists.
public void myMethod() {
...
Cache<String, String> txnCache = CacheManagerEjb.
getTransactionLocalCacheGroup().getCache("mycache");
String value = txnCache.get("key");
if(value == null) {
// perform expensive operation to calculate value - this
// processing only happens once per transaction
...
// and store the result
txnCache.put("key", "value");
}
...
}