Replicator.replicate throwing null pointer exception : AEM 6.2 | Community
Skip to main content
cquser1
Level 7
Mar 19, 2017 5:20 PM UTC
Solved

Replicator.replicate throwing null pointer exception : AEM 6.2

Hi All,

I have a class which  extends AbstractProductImporter[com.adobe.cq.commerce.pim.common.AbstractProductImporter] and implements ProductImporter[com.adobe.cq.commerce.pim.api.ProductImporter]. It has @Component, @Service annotations declared at the top.

Here, custom logic is written which checks if a flag present[for every product] in json, got from PIM system is update/create etc and based on that code is present. Here I am trying to use, replicator.replicate(resourceResolver.adaptTo(Session.class), ReplicationActionType.ACTIVATE, pagePath). 

    @Reference
    public Replicator replicator; is made use of in the java file.

But I am getting Nullpointerexception on hitting this replicator.replicate line.

I have spent quite some time on this, but no clue as to what is going on.'pagePath' is pointing to existing page in the repository.

Don't know what is happening. 

Any thoughts on this will be really really helpful.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
joerghoh
joerghohAccepted solution
Employee
Mar 20, 2017 8:11 PM UTC

Hi,

if you use a simple

@Reference
Replicator replicator;

the reference must alwas be non-null when the service gets active. Because this is the default semantic of the @Reference annotation. Can you post the source code of your class? And can you make sure, that the service is properly registered within OSGI? Just have a look at /system/console/components and look for your class.

Jörg

4 replies

Level 3
Feb 2, 2021 2:56 PM UTC

HI All,

- Check at /system/console/components and search for replicationstatusprov and ensure that it is in start status

- Turning it back ( stop & Start) with  additional step to resolve the error in crx/de:
/system/console/bundles -> search for crxde -> click "refresh package imports"

- issue will be fixed after refresh the page

Translate
gargsahil099
Level 3
Jun 5, 2018 11:04 AM UTC

Can you please share the root cause of this as we are also facing the same issue and not able to resolve it.

Translate
joerghoh
joerghohAccepted solution
Employee
Mar 20, 2017 8:11 PM UTC

Hi,

if you use a simple

@Reference
Replicator replicator;

the reference must alwas be non-null when the service gets active. Because this is the default semantic of the @Reference annotation. Can you post the source code of your class? And can you make sure, that the service is properly registered within OSGI? Just have a look at /system/console/components and look for your class.

Jörg

Translate
cquser1
cquser1Author
Level 7
Mar 20, 2017 5:00 AM UTC

Hi All, 

Any thoughts on the below will be helpful.

Translate