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?

Thanks!
Br,
Alessio.

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(BundleWiringImpl.java:1639)
	at org.apache.felix.framework.BundleWiringImpl.access$200(BundleWiringImpl.java:80)
	at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:2053)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)

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.

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

@Bean
  public SpaceService spaceService() {
    return importOsgiService(SpaceService.class);
  }