Hi,
I’m trying to add a scheduled job to my Confluence Data Center plugin by using a Job Config module. I have this in my atlassian-plugin.xml
:
<job-config name="My Test Job" key="myJobId">
<!-- Class name is MyJobRunner -->
<job key="myJobRunner"/>
<!-- Only run once -->
<schedule repeat-interval="3600000" repeat-count="0"/>
<!-- Show in admin UI, but don't let them edit the schedule -->
<managed editable="false" keepingHistory="true" canRunAdhoc="true" canDisable="false"/>
</job-config>
This is what the MyJobRunner
class looks like:
package com.lucidchart.confluence.plugins.jobs;
import java.time.LocalDateTime;
import com.atlassian.scheduler.JobRunner;
import com.atlassian.scheduler.JobRunnerRequest;
import com.atlassian.scheduler.JobRunnerResponse;
import org.springframework.stereotype.Component;
@Component
class MyJobRunner implements JobRunner {
@Override
public JobRunnerResponse runJob(JobRunnerRequest request) {
return JobRunnerResponse.success("Demo job succeeded! " + java.time.LocalDate.now());
}
}
I see this in the Confluence server logs when I install the module:
2022-10-17 23:25:06,311 ERROR [UpmAsynchronousTaskManager:thread-3] [scheduler.spi.descriptor.JobConfigModuleDescriptor] getJobRunnerFromModuleDescriptor Job key myJobRunner is not a bean or a component in plugin com.lucidchart.confluence.plugins.lucid-confluence
-- url: /rest/plugins/1.0/ | referer: https://atlassian-dev-7.lucidstaging.app/plugins/servlet/upm?source=side_nav_manage_addons | traceId: bb3cbe905a2922f0 | userName: admin
2022-10-17 23:25:06,312 ERROR [UpmAsynchronousTaskManager:thread-3] [scheduler.spi.descriptor.JobConfigModuleDescriptor] getJobRunnerFromOsgiBundleContext Job key myJobRunner does not reference a com.atlassian.scheduler.JobRunner bean in plugin com.lucidchart.confluence.plugins.lucid-confluence
-- url: /rest/plugins/1.0/ | referer: https://atlassian-dev-7.lucidstaging.app/plugins/servlet/upm?source=side_nav_manage_addons | traceId: bb3cbe905a2922f0 | userName: admin
org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'myJobRunner' is expected to be of type 'com.atlassian.scheduler.JobRunner' but was actually of type 'com.lucidchart.confluence.plugins.jobs.MyJobRunner'
at org.springframework.beans.factory.support.AbstractBeanFactory.adaptBeanInstance(AbstractBeanFactory.java:417)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:398)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:213)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1160)
at com.atlassian.confluence.plugins.scheduler.spi.descriptor.JobConfigModuleDescriptor.lambda$getJobRunnerFromOsgiBundleContext$0(JobConfigModuleDescriptor.java:433)
...
The last error message, Bean named 'myJobRunner' is expected to be of type 'com.atlassian.scheduler.JobRunner' but was actually of type 'com.lucidchart.confluence.plugins.jobs.MyJobRunner'
, is really confusing. The MyJobRunner
class does implement the JobRunner
interface, so I’m not sure what’s going wrong here.
What am I doing wrong?
Update: following this tutorial seems to work for a new plugin. So it must be something in the existing plugin code that’s incorrect: https://examples.javacodegeeks.com/software-development/atlassian/atlassian-confluence-job-config-module-example/