Maven dependencies for Transaction & OSGiUtils | Community
Skip to main content
Siva_Sogalapalli
New Participant
Oct 13, 2017 7:44 AM UTC
Solved

Maven dependencies for Transaction & OSGiUtils

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.
smacdonald2008
smacdonald2008Accepted solution
Level 10
Oct 17, 2017 7:33 PM UTC

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
Oct 16, 2017 5:37 PM UTC

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.

Translate
kautuk_sahni
Employee
Oct 16, 2017 9:38 AM UTC

Thanks a lot, neerava for the information.

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

~kautuk

Translate
Kautuk Sahni
Employee
Oct 16, 2017 9:11 AM UTC

You can lookup TransactionManager by declaring a reference to it:

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

Translate
smacdonald2008
Level 10
Oct 13, 2017 2:47 PM UTC

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.

Translate
smacdonald2008
Level 10
Oct 13, 2017 2:36 PM UTC

We asked the Doc Services team to look here.

Translate