Maven dependencies for Transaction & OSGiUtils | Community
Skip to main content
Siva_Sogalapalli
New Participant
October 13, 2017
Solved

Maven dependencies for Transaction & OSGiUtils

  • October 13, 2017
  • 15 replies
  • 5402 views

Hi All,

I'm following below forms resource and referring PDF Generator Service section on the page.

AEM 6.2 Forms Help | Using AEM Document Services Programmatically

I see the below piece of code. But I couldn't find package names/dependencies for Transaction & OSGiUtils class. 

Transaction tx = OSGiUtils.getTransactionManager().getTransaction();

    // Begin transaction

    if (tx == null)

        OSGiUtils.getTransactionManager().begin();

Please advise.

Thanks

Siva

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by smacdonald2008

Here is the information i got back from ENG.

OSGIUtils is an internal class which is not exposed but Transaction manager is a public java class which can be imported directly. It can be used directly and no forms dependency should be required for the same.

Transaction tx = OSGiUtils.getTransactionManager().getTransaction();

    // Begin transaction

    if (tx == null)

    OSGiUtils.getTransactionManager().begin();

Should be changed to

import javax.transaction.TransactionManager;

import javax.transaction.Transaction;

TransactionManager tmx = new TransactionManager();

Transaction tx = tmx.getTransaction();

    // Begin transaction

    if (tx == null)

    tmx.begin();

15 replies

Siva_Sogalapalli
New Participant
October 16, 2017

Thanks a lot @neerava​ for the information.

I tried to use same piece of code and the error says,TransactionManager cannot be resolved to a type.

That means, we have to import that class package. Again, to use that class, we need to add some dependency.I'm looking for that dependency. Please provide me the dependencies which resolve the issue.

kautuk_sahni
Employee
October 16, 2017

Thanks a lot, neerava for the information.

And sivaprasadreddys we have created a documentation issue for modifying the information within.

~kautuk

Kautuk Sahni
Employee
October 16, 2017

You can lookup TransactionManager by declaring a reference to it:

@Reference(name = "transactionManager", referenceInterface = TransactionManager.class)

smacdonald2008
New Participant
October 13, 2017

There does seem to be an issue as I cannot find any Java Doc for this API - which should not be the case. All APIS in all AEM Code examples should be listed in a public Javadoc.

smacdonald2008
New Participant
October 13, 2017

We asked the Doc Services team to look here.