Usage of "com.atlassian.confluence.api.service" in Atlassian Scheduler runJob

Hi everyone!

I am in the process of submitting an app for Data Center approval and it is required to remove deprecated APIs usage.

I am making use of the “old” manager classes, such as PageManager, SpaceManager etc, and as those are deprecated, I found that I have to use the “new” service classes, such as PageService, SpaceService and alike.

To give an example, this SpaceManagergetSpace” method is deprecated: SpaceManager (Atlassian Confluence 7.13.1 API).

I followed the deprecation notes, and re-implemented parts of my code with SpaceServicefind” method: SpaceService (Atlassian Confluence 7.13.1 API)…-.

Everything worked out until I started using the SpaceService in one of my Atlassian scheduler implementation, that is in class that implements the com.atlassian.scheduler.JobRunner interface, if I would do something like:

final Space space = this.spaceService.find ().withKeys ("ds").fetchOrNull ();

space is always null. However I do have a “ds” space, and from REST apis or other contexts it actually works just fine.

I am initializing the SpaceService wired in the constructor, as I was doing for the SpaceManager.

Does anyone have an idea why is this the case? And perhaps show a portion of code where such services are used in a scheduler contexts?


1 Like

Is anyone just using the “Managers” in Data Center and not caring about deprecation?
Or no one has an idea how to solve this?

I am also struggling to use SpaceService in my plugin.

I am unable to successfully inject it using Spring Java configuration of app components

Caused by: java.lang.ClassNotFoundException: org.springframework.cglib.proxy.Factory not found by com.atlassian.plugin.osgi.bridge [1]
	at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(
	at org.apache.felix.framework.BundleWiringImpl.access$200(
	at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(
	at java.base/java.lang.ClassLoader.loadClass(

If anyone is successfully using Spring Java configuration and the SpaceService I’d like to know how they got that service injected into their classes.

The mechanism I’m using for all the other services (like the old SpaceManager, etc.) works fine.

I am able to inject SpaceService using Spring Java configuration. In my configuration class:

  public SpaceService spaceService() {
    return importOsgiService(SpaceService.class);

I created a public repo, that you can use to reproduce the issue I have:

In the README you can see the job code and the log.

If anyone can follow up on helping me out, would be great.

try this:

package deprec.impl;

import com.atlassian.confluence.api.model.content.Space;
import com.atlassian.confluence.api.service.content.SpaceService;
import com.atlassian.scheduler.JobRunner;
import com.atlassian.scheduler.JobRunnerRequest;
import com.atlassian.scheduler.JobRunnerResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.atlassian.confluence.user.UserAccessor;
import com.atlassian.confluence.user.ConfluenceUser;
import com.atlassian.confluence.user.AuthenticatedUserThreadLocal;

public class TestJob implements JobRunner
    private final SpaceService m_spaceService;
    private final ConfluenceUser runAsUser;
    public TestJob (final SpaceService spaceService, UserAccessor userAccessor)
        this.m_spaceService = spaceService;
        this.runAsUser=userAccessor.getUserByName("admin"); //or another user with permitions
    private static final Logger LOG = LoggerFactory.getLogger (TestJob.class);
    public JobRunnerResponse runJob (final JobRunnerRequest request)
        final Space space = this.m_spaceService.find ().withKeys ("ds").fetchOrNull ();
        LOG.error ("TEST");
        LOG.error (space.getName ());
        return JobRunnerResponse.success ();        

For anyone who would face same issue, I was able to solve it in a Jira plugin by switching to factoryBeanForOsgiService instantiation:

    public FactoryBean<SpaceService> globalPermissionManager() {
        return factoryBeanForOsgiService(SpaceService.class);

Hope this helps.