Hi people,
I am trying to initiate Javax.transaction on jcr resource and storing content on AEM localhost:4502, I just could not get the way out to initialize UserTransaction to jcr repository, Not sure whats the JNDI lookup context jn that case, because jcr repository is not the data source.i just want transactions to rollback/commit dependending on sucess/failure rates. Doea anyone have idea??
Solved! Go to Solution.
when you deal with JCR solely, you don't need JTA.
Not a lot of transaction inforomation online about JCR and transactions. See this doc that may help -- JCR 2.0: 21 Transactions (Content Repository for Java Technology API v2.0)
Views
Replies
Total Likes
Why would you use javax.transaction API? The JCR session API already offers transaction support. Of course you cannot span a transaction multiple datasources (for example a SQL database which should be updated in the same transaction as JCR).
It's that what you want to do?
Jörg
Views
Replies
Total Likes
No, I dont want to update JCR and data source simultaneously, I want to save all the JCR transactions once in the end, by utx.commit() if there are no failure rates, and utx.rollback() in case of single failure. So I think if anyway we can make use of JTA transactions, to store transient data and submit and rollback as needed
repository = JcrUtils.getRepository("http://localhost:4502/crx/server");
//Create a Session
javax.jcr.Session session = repository.login( new SimpleCredentials("admin", "admin".toCharArray()));
Object sling;
//final SlingRepository repository = sling.getService(SlingRepository.class);
// Session session = repository.loginAdministrative(null);
Node root = session.getRootNode();
Hashtable env = new Hashtable();
Context ctx = null;
env.put(Context.PROVIDER_URL, "http://localhost:4502/crx/server");
env.put(Context.INITIAL_CONTEXT_FACTORY,"jcr/repository");
ctx = new InitialContext(env);
UserTransaction utx = (UserTransaction)
ctx.lookup("javax.transaction.UserTransaction");
Views
Replies
Total Likes
yes agree.. I came across the link and I m facing issues with setting context to UserTransaction Object.
Views
Replies
Total Likes
when you deal with JCR solely, you don't need JTA.
Views
Likes
Replies
Views
Like
Replies