1. Like Norbert mentioned, use tx now. There is a known problem in locking when tx is not used. We are fixing that in release 1.2.
2. If you are using TreeCacheAop, I'd suggest you try the latest pre-1.2 release in jboss-head. I have done some refactoring and bug fixing on the aop part.
3. If you still are seeing the problem, the best way to help me out to troubleshoot is to write a JUnit test case. That can cut down the time that I need to generate one by myself. Besides, I can check in your test case in the src tree as well. :-)
getInstance() doesn't fail, it just throws a NamingException. That's fine you can simply ignore it.
So you can do this programmatically:
or via XML
Hmmm.. fair enough. Thank you, though I'm having trouble connecting the TreeCache to the TransactionManager. I'm quite sure it's my fault for not understanding it well enough.
There doesn't appear to be a TreeCache.setTransactionManager(..) method as implied by your snippet. Distilling from many examples of how to use the factory I get the following (code abbreviated for legibility):
String FACTORY = "org.jboss.cache.transaction.DummyContextFactory"; Properties properties = new Properties(); properties.put(Context.INITIAL_CONTEXT_FACTORY, FACTORY); DummyTransactionManager transactionManager = DummyTransactionManager.getInstance(); org.jboss.cache.TreeCache tc = new org.jboss.cache.TreeCache(); PropertyConfigurator config = new PropertyConfigurator(); config.configure(tc, "Private-TreeCache.xml"); tc.start();
And the Lookup class is in the xml:
Then during use most examples call for the something akin to the following, but the lookup always gives me a null.
UserTransaction tx = (UserTransaction) new InitialContext(properties).lookup("UserTransaction"); //UserTransaction tx = new DummyUserTransaction(transactionManager); tx.begin(); tc.put(node, key, value); tx.commit();
Your pseudo-code snippet implies that there is an easier way for the default case?
Thank you very much..
On a side note, I do seem to get the safe behavior I want with a SERIALIZABLE IsolationLevel and access code like (other code from above is unchanged):
//UserTransaction tx = (UserTransaction) new InitialContext(properties).lookup("UserTransaction"); //UserTransaction tx = new DummyUserTransaction(transactionManager); //tx.begin(); TreeCacheProvider.tc.put(node, key, value); //tx.commit();
Though I would assume that's just because of the SERIALIZABLE spec.
There's an Interface TransactionManagerLookup that you may implement. Your TransactionManagerLookup-class simply returns the TransactionManager of your choice.
Than you let TreeCache use this transactionmanagerlookup-class to make use of the assigned transactionmanager by either passing an instance to TreeCache via setTransactionManagerLookup(TransactionManagerLookup transactionmanagerlookupinstance), or you specify the className via setTransactionManagerLookupClass(String classname)
You may want to look into the sources of org.jboss.cache.DummyTransactionManagerLookup to have a working example.