Custom Replication Agent problem



Hi everyone! Im new with adobe aem, actually Im working with 6.4 and Im trying to create a custom replication agent.

My problem is that when I build the code into aem and select the "Serialization Type" into the agent it fail and I receiving
"Agent is not valid. ContentBuilder not available"


I have following the next steps:

>I have tried creating a new agent, add the serialization type (custom) and fail.

>Copying from an existing agent, and also fails.

Im implementing ContentBuilder and TransportHandler, I just have only some logs into the implemented methods,I already have looked into Nate Yolles example

Im not copying the code because I want to understand how it works, also I have noticed there are some deprecated features in the annotations used in this example,

I have fix that, but Im not sure at all if the new annotations are causing the problem, also I have checked some documentation but so far it was not very helpful.

Im only using the @component annotation as you can see in the following code Im currently using:

Any sort of help highly appreciated.

Thanks in advance!.

------------------------------- TRANSPORT HANDLER ------------------------------------------------

@Component(name = "Custom Agent",immediate = true, enabled = true)

public class MyTransportHandler implements TransportHandler {

public boolean canHandle(AgentConfig config) {"+++++FROM CANHANDLE!!++++++");

return true;


public ReplicationResult deliver(TransportContext ctx, ReplicationTransaction tx) throws ReplicationException {

        ReplicationActionType replicationType = tx.getAction().getType();"+++++FROM DELIVER!!++++++");

return ReplicationResult.OK;



@Component (service = ContentBuilder.class, enabled = true, name = "name")

public class TestContentBuilder implements ContentBuilder{

public ReplicationContent create(Session arg0, ReplicationAction arg1, ReplicationContentFactory arg2)

            throws ReplicationException {

        // TODO Auto-generated method stub

        return create(arg0,arg1,null);



    public ReplicationContent create(Session session, ReplicationAction action, ReplicationContentFactory factory,

            Map<String, Object> parameters) throws ReplicationException {"---- FROM CONTENT BUILDER -----");

return ReplicationContent.VOID;



    public String getName() {

        // TODO Auto-generated method stub

        return "Test AK";



    public String getTitle() {

        // TODO Auto-generated method stub

        return "Test AK Description";



Accepted Solutions (1)

Accepted Solutions (1)




My recommendation would be to copy-paste code and make it compile without any issues to isolate multiple issues (libraries vs AEM-version vs archetype vs your own source code related issues) that you're trying to deal with in a single shot. Once it compiles and you're able to test it then tweak per your requirements.

I copied that code as-is, modified a couple of libs in pom.xml and I don't see any ContentBuilder related error.

Answers (5)

Answers (5)



Just add the following annotation in the class ContentBuilder.

@Component (service = ContentBuilder.class, enabled = true,property={"name=akamai",Constants.SERVICE_RANKING +":Integer=1001"})

public class AkamaiContentBuilder implements ContentBuilder {


for TransportHandler

@Component(service = TransportHandler.class,immediate = true, enabled = true,property={Constants.SERVICE_RANKING +":Integer=1001"})

public class AkamaiTransportHandler implements TransportHandler {


Also there are other helpful links that explain the new annotations.

Re: AEM 6.4 beta, Apache Sling JCR Resource Resolver not present




I am also facing same issue,

  • Agent is not valid. ContentBuilder not available

created multi module aem project using archetype 15. Below is my content builder code

@Component(name="Custom Content Builder", service=ContentBuilder.class)

public class CustomContentBuilder implements ContentBuilder {

private static final Logger LOGGER = LoggerFactory.getLogger(CustomContentBuilder.class);


    private ResourceResolverFactory resolverFactory;

public static final String NAME = "Custom Content Builder";

public static final String TITLE = "Custom Content Builder";

  public ReplicationContent create(Session session, ReplicationAction action,

   ReplicationContentFactory factory) throws ReplicationException {"Inside create!!!");

  return ReplicationContent.VOID; 


public String getName() {"Inside getName!!!");

  return TITLE;


public String getTitle() {"Inside getTitle!!!");

  return TITLE;


public ReplicationContent create(Session session, ReplicationAction action,

   ReplicationContentFactory factory, Map<String, Object> arg3){"Inside create new!!!");"Action type ::: "+action.getType());

String pagePath = action.getPath();"Page Path ::: "+pagePath);

try {

Map<String, Object> authenticationInfo = new HashMap<>();

authenticationInfo.put(JcrResourceConstants.AUTHENTICATION_INFO_SESSION, session);

ResourceResolver resourceResolver = resolverFactory.getResourceResolver(authenticationInfo);

Page page = resourceResolver.getResource(pagePath).adaptTo(Page.class);"Page original path ::: "+page.getPath());

} catch(Exception ex) {

LOGGER.error("Error in create ::: ", ex);


  return ReplicationContent.VOID;



Please advise what dependencies you have modified to make it working?