Expand my Community achievements bar.

SOLVED

Installing a package to AEM using Java not Maven

Avatar

Community Advisor

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

1 Accepted Solution

Avatar

Correct answer by
Level 9

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

Thanks,

Kishore

View solution in original post

10 Replies

Avatar

Correct answer by
Level 9

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

Thanks,

Kishore

Avatar

Administrator

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-ide... ).

 

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

I hope this would help you.

Thanks and Regards

Kautuk Sahni



Kautuk Sahni

Avatar

Level 9

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

Avatar

Community Advisor

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.

Avatar

Level 9

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

Avatar

Community Advisor

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

Avatar

Level 9

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

Avatar

Community Advisor

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)