Maven dependencies for Transaction & OSGiUtils

Avatar

Avatar
Give Back 5
Level 3
sivaprasadreddy
Level 3

Likes

9 likes

Total Posts

92 posts

Correct reply

7 solutions
Top badges earned
Give Back 5
Give Back 3
Give Back
Ignite 5
Ignite 3
View profile

Avatar
Give Back 5
Level 3
sivaprasadreddy
Level 3

Likes

9 likes

Total Posts

92 posts

Correct reply

7 solutions
Top badges earned
Give Back 5
Give Back 3
Give Back
Ignite 5
Ignite 3
View profile
sivaprasadreddy
Level 3

13-10-2017

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

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,409 likes

Total Posts

12,671 posts

Correct reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,409 likes

Total Posts

12,671 posts

Correct reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile
smacdonald2008
Level 10

17-10-2017

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();

Answers (14)

Answers (14)

Avatar

Avatar
Boost 5
Employee
neerava
Employee

Likes

7 likes

Total Posts

33 posts

Correct reply

14 solutions
Top badges earned
Boost 5
Boost 3
Boost 1
Affirm 5
Affirm 3
View profile

Avatar
Boost 5
Employee
neerava
Employee

Likes

7 likes

Total Posts

33 posts

Correct reply

14 solutions
Top badges earned
Boost 5
Boost 3
Boost 1
Affirm 5
Affirm 3
View profile
neerava
Employee

16-10-2017

You can lookup TransactionManager by declaring a reference to it:

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

Avatar

Avatar
Level 1
shafiuddinm1989
Level 1

Likes

0 likes

Total Posts

1 post

Correct reply

0 solutions
View profile

Avatar
Level 1
shafiuddinm1989
Level 1

Likes

0 likes

Total Posts

1 post

Correct reply

0 solutions
View profile
shafiuddinm1989
Level 1

24-10-2019

Is this issue ever resolved? I tried this piece of code

import javax.transaction.TransactionManager;

import javax.transaction.Transaction;

TransactionManager tmx = new TransactionManager();Maven dependencies for Transaction & OSGiUtils

Transaction tx = tmx.getTransaction();

    // Begin transaction

    if (tx == null)

    tmx.begin();

Still there is error saying, Cannot instantiate the type TransactionManager

Avatar

Avatar
Boost 5
Level 3
vaibhavs7024655
Level 3

Likes

18 likes

Total Posts

28 posts

Correct reply

6 solutions
Top badges earned
Boost 5
Boost 3
Boost 10
Boost 1
Affirm 5
View profile

Avatar
Boost 5
Level 3
vaibhavs7024655
Level 3

Likes

18 likes

Total Posts

28 posts

Correct reply

6 solutions
Top badges earned
Boost 5
Boost 3
Boost 10
Boost 1
Affirm 5
View profile
vaibhavs7024655
Level 3

17-10-2017

This is a Livecycle internal api for which the fully qualifed package is: com.adobe.aemds.bedrock.internal.OSGiUtils

​But not sure if it is a part of Uber jar or not.

Avatar

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,409 likes

Total Posts

12,671 posts

Correct reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,409 likes

Total Posts

12,671 posts

Correct reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile
smacdonald2008
Level 10

16-10-2017

This looks like the POM dep for this API:

<!-- https://mvnrepository.com/artifact/javax.transaction/transaction-api -->

<dependency>

    <groupId>javax.transaction</groupId>

    <artifactId>transaction-api</artifactId>

    <version>1.1-rev-1</version>

    <scope>provided</scope>

</dependency>

https://mvnrepository.com/artifact/javax.transaction/transaction-api/1.1-rev-1

It would have been much easier if the PDF Gen code example showed all import statements as we do in HELPX articles.

Avatar

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,409 likes

Total Posts

12,671 posts

Correct reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,409 likes

Total Posts

12,671 posts

Correct reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile
smacdonald2008
Level 10

16-10-2017

Looks like this JAR does not expose this API either.

Avatar

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,409 likes

Total Posts

12,671 posts

Correct reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,409 likes

Total Posts

12,671 posts

Correct reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile
smacdonald2008
Level 10

16-10-2017

Ok - here is what you can try - i am trying too.

See this KB - AEM 6.1 Forms Help | Using AEM Document Services Programmatically

You can download the DOC Services API JAR.

I assume this JAR file has this API in it. I am looking all the class files in it.

Then you can upload this JAR file to the Maven Repo as a local JAR file - see this (still need an end to end that explains this in a HELPX):

HOW CAN I WORK WITH CUSTOM JARS THAT ARE NOT IN THE MAVEN REPOSITORY

You can place the JAR in your local Maven Repository and then reference it in your POM file. For example, to resolve myCustomJAR_1.0.0.jar within an AEM service, the myCustomJAR_1.0.0.jar file must be located in the Maven repository. You can upload the myCustomJAR_1.0.0.jar to Maven by using this Maven command:

mvn install:install-file -Dfile=C:/plugins/myCustomJAR_1.0.0.jar-DgroupId=com.foo.reports -DartifactId=jrurbersrt1.0 -Dversion=1.0 -Dpackaging=jar -DgeneratePom=true

Notice that you must specify the location of the myCustomJAR file in the -Dfile argument. Also notice that you specify the Dgroup and DartifactID values. Once you upload the JAR to Maven using this command, you can reference this JAR file using this Dependency.

<groupId>com.foo.reports</groupId>

<artifactId>jrurbersrt1.0</artifactId>

<version>1.0</version>

<scope>system</scope>

<systemPath>C:\Users\scottm\.m2\repository\com\foo\reports\jrurbersrt1.0\1.0\myCustomJAR_1.0.0.jar</systemPath>

</dependency>

Notice that scope element is system and systemPath references the location of the JAR file in the repository. (This dependency is used later in this article to build the AEM service)

Avatar

Avatar
Give Back 5
Level 3
sivaprasadreddy
Level 3

Likes

9 likes

Total Posts

92 posts

Correct reply

7 solutions
Top badges earned
Give Back 5
Give Back 3
Give Back
Ignite 5
Ignite 3
View profile

Avatar
Give Back 5
Level 3
sivaprasadreddy
Level 3

Likes

9 likes

Total Posts

92 posts

Correct reply

7 solutions
Top badges earned
Give Back 5
Give Back 3
Give Back
Ignite 5
Ignite 3
View profile
sivaprasadreddy
Level 3

16-10-2017

That would be great help smacdonald2008

Avatar

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,409 likes

Total Posts

12,671 posts

Correct reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,409 likes

Total Posts

12,671 posts

Correct reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile
smacdonald2008
Level 10

16-10-2017

YOu are correct - there is missing information from the AEM Forms docs, I am trying to get a worknig example so i can build it and get full code - including POM dependencies into a HELPX community article.

Avatar

Avatar
Give Back 5
Level 3
sivaprasadreddy
Level 3

Likes

9 likes

Total Posts

92 posts

Correct reply

7 solutions
Top badges earned
Give Back 5
Give Back 3
Give Back
Ignite 5
Ignite 3
View profile

Avatar
Give Back 5
Level 3
sivaprasadreddy
Level 3

Likes

9 likes

Total Posts

92 posts

Correct reply

7 solutions
Top badges earned
Give Back 5
Give Back 3
Give Back
Ignite 5
Ignite 3
View profile
sivaprasadreddy
Level 3

16-10-2017

Yes smacdonald2008​, I'm using below AEM 6.3 uber jar dependency.

<dependency>

<groupId>com.adobe.aem</groupId>

<artifactId>uber-jar</artifactId>

<version>6.3.0</version>

<classifier>apis</classifier>

<scope>provided</scope>

</dependency>

Avatar

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,409 likes

Total Posts

12,671 posts

Correct reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,409 likes

Total Posts

12,671 posts

Correct reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile
smacdonald2008
Level 10

16-10-2017

Are you using AEM UBER JAR in your POM File?

Avatar

Avatar
Give Back 5
Level 3
sivaprasadreddy
Level 3

Likes

9 likes

Total Posts

92 posts

Correct reply

7 solutions
Top badges earned
Give Back 5
Give Back 3
Give Back
Ignite 5
Ignite 3
View profile

Avatar
Give Back 5
Level 3
sivaprasadreddy
Level 3

Likes

9 likes

Total Posts

92 posts

Correct reply

7 solutions
Top badges earned
Give Back 5
Give Back 3
Give Back
Ignite 5
Ignite 3
View profile
sivaprasadreddy
Level 3

16-10-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.

Avatar

Avatar
Establish
Community Manager
kautuk_sahni
Community Manager

Likes

1,199 likes

Total Posts

6,394 posts

Correct reply

1,147 solutions
Top badges earned
Establish
Coach
Originator
Contributor 2
Contributor
View profile

Avatar
Establish
Community Manager
kautuk_sahni
Community Manager

Likes

1,199 likes

Total Posts

6,394 posts

Correct reply

1,147 solutions
Top badges earned
Establish
Coach
Originator
Contributor 2
Contributor
View profile
kautuk_sahni
Community Manager

16-10-2017

Thanks a lot, neerava for the information.

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

~kautuk

Avatar

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,409 likes

Total Posts

12,671 posts

Correct reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,409 likes

Total Posts

12,671 posts

Correct reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile
smacdonald2008
Level 10

13-10-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.

Avatar

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,409 likes

Total Posts

12,671 posts

Correct reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,409 likes

Total Posts

12,671 posts

Correct reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile
smacdonald2008
Level 10

13-10-2017

We asked the Doc Services team to look here.