Installing a package to AEM using Java not Maven | Community
Skip to main content
Singaiah_Chintalapudi
February 19, 2016
Solved

Installing a package to AEM using Java not Maven

  • February 19, 2016
  • 10 replies
  • 2270 views

Hi All,

I am creating content nodes grammatically using Java and I want to zip that folder and deploy it to AEM using Java. Is there a way to do this in Java? 

Please help.

Thanks

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 GK-007

As Scot said,create whatever nodes you want to create using JAVA and package them using PackageManager API.

Thanks,

Kishore

10 replies

smacdonald2008
February 19, 2016
GK-007
GK-007Accepted solution
February 20, 2016

As Scot said,create whatever nodes you want to create using JAVA and package them using PackageManager API.

Thanks,

Kishore

kautuk_sahni
Community Manager
Community Manager
February 22, 2016

Hi 

Apart from what Scott and Kishore mentioned, we can also use CURL. We can execute Curl commands from Java to install Package.

Link:- https://gist.github.com/sergeimuller/2916697

But, i would recommend you to use Package Manager APIs (Because, read https://cqdump.wordpress.com/2014/03/10/using-curl-to-install-cq-packages-and-why-it-isnt-a-good-idea/ ).

 

Documentation link:- https://docs.adobe.com/content/docs/en/crx/2-3/how_to/package_manager.html#Package%20Manager%20HTTP%20Service%20API

I hope this would help you.

Thanks and Regards

Kautuk Sahni

Kautuk Sahni
Jitendra_S_Toma
February 22, 2016

Hi All,

  With all due respect, Package manager isn't easy to use. You have to build own module just like the AEM content packaging. And, I don't think this is a good idea.

@NoKSC,

I have a few questions.

  • Where do you create content nodes?. Is it in separate CRX?.
  • Does your Java class not run OSGI Container?. 

If Java classes are OSGI components & content nodes in a separate CRX, Then I think, you are looking for content migration from one system to another without creating content nodes again.

If Above assumptions are correct, Use Curl which is the easiest way to migrate content from one system to another. Curl command can be executed through Java process.

Let me know if this make sense to you.

---

Jitendra

Singaiah_Chintalapudi
February 22, 2016

Jitendra S.Tomar wrote...

Hi All,

  With all due respect, Package manager isn't easy to use. You have to build own module just like the AEM content packaging. And, I don't think this is a good idea.

@NoKSC,

I have a few questions.

  • Where do you create content nodes?. Is it in separate CRX?.
  • Does your Java class not run OSGI Container?. 

If Java classes are OSGI components & content nodes in a separate CRX, Then I think, you are looking for content migration from one system to another without creating content nodes again.

If Above assumptions are correct, Use Curl which is the easiest way to migrate content from one system to another. Curl command can be executed through Java process.

Let me know if this make sense to you.

---

Jitendra

 

Thanks Jitendra. I've created a package in package manager manually and I downloaded that package. Once I extract it, I get the file system structure (jcr:root and META-INF folders) and I am creating the nodes inside this structure (jcr_root\content\test\en). So I can zip these and deploy the package back to AEM after I create the content nodes.

My java classes are stand alone and does not run on OSGI container. I have lone simple main method and once I run this method, it will create all the content nodes.

Please let me know if you have any questions.

Jitendra_S_Toma
February 22, 2016

Each node requires .content.xml to be there. Is below idea working for now?

Once I extract it, I get the file system structure (jcr:root and META-INF folders) and I am creating the nodes inside this structure (jcr_root\content\test\en). So I can zip these and deploy the package back to AEM after I create the content nodes.

A simple idea could be, Use JCR API to connect to CRX repository from a standalone application and create nodes on the CRX directly. Which version of AEM, you are running?.

-----

Jitendra

Jitendra_S_Toma
February 22, 2016

Here is an article which talks about creating & connecting with Repo.

http://blogs.adobe.com/experiencedelivers/experience-management/starting_with_apacheoak/

Singaiah_Chintalapudi
February 22, 2016

Jitendra S.Tomar wrote...

Each node requires .content.xml to be there. Is below idea working for now?

Once I extract it, I get the file system structure (jcr:root and META-INF folders) and I am creating the nodes inside this structure (jcr_root\content\test\en). So I can zip these and deploy the package back to AEM after I create the content nodes.

A simple idea could be, Use JCR API to connect to CRX repository from a standalone application and create nodes on the CRX directly. Which version of AEM, you are running?.

-----

Jitendra

 

I am using AEM 6.1

Jitendra_S_Toma
February 22, 2016

Does below code make things clear to you?.

A simple idea could be, Use JCR API to connect to the CRX repository from a standalone application and create nodes on the CRX directly. 

Jitendra

Singaiah_Chintalapudi
February 22, 2016

Jitendra S.Tomar wrote...

Does below code make things clear to you?.

A simple idea could be, Use JCR API to connect to the CRX repository from a standalone application and create nodes on the CRX directly. 

Jitendra

 

Yeah. I've tried this before but I am always getting below exception:

 

Exception in thread "main" javax.jcr.RepositoryException: Unable to access a repository with the following settings:
    org.apache.jackrabbit.repository.uri: http://localhost:4502/crx/server
The following RepositoryFactory classes were consulted:
Perhaps the repository you are trying to access is not available at the moment.
    at org.apache.jackrabbit.commons.JcrUtils.getRepository(JcrUtils.java:223)
    at org.apache.jackrabbit.commons.JcrUtils.getRepository(JcrUtils.java:263)
    at org.kp.fdl.mydoctor.core.models.Testt.main(Testt.java:24)