Using EntityLinkService

I am trying to create a link between a Jira Project and a Confluence Space.

JiraApplicationLinkService jals = ((JiraApplicationLinkService) ComponentAccessor.getComponent(JiraApplicationLinkService.class));
ApplicationLink confluenceLink = jals.getPrimaryApplicationLink(ConfluenceApplicationType.class);
DefaultTypeAccessor ta = new DefaultTypeAccessor(ComponentAccessor.getPluginAccessor(), ComponentAccessor.getPluginEventManager());

MutatingEntityLinkService els = ((MutatingEntityLinkService) ComponentAccessor.getComponent(MutatingEntityLinkService.class));
EntityLinkBuilderFactory entityLinkBuilderFactory = els.getEntityLinkBuilderFactory();

EntityLink link = entityLinkBuilderFactory.builder().key(“NEW”).name(“NEW”).type(ta.getEntityType(ConfluenceSpaceEntityType.class)).primary(true).applicationLink(confluenceLink).build();

els.addEntityLink(createdProject.getKey(), JiraProjectEntityType.class, link);

The problem is that the MutatingEntityLinkService (interface for DefaultEntityLinkService) is null. I am able to get the simple EntityLinkService and fetch the existing entityLink, but that interface does not allow to create a new EntityLink. Is there a way to fetch the EntityLinkService that allows for EntityLink creation?

I found a way to do it using the private REST API “/rest/applinks/1.0/entitylink/{type}/{key}”. However, I wish there was another way…