Multiple "Scheduled Tasks" issues with CUBA legacy-support and Jmix

Jmix version: 1.1.2
Jmix Studio plugin version: 1.1.4-213
IntelliJ IDEA 2021.3 CE - Build #IC-213.5744.223, built on November 27, 2021
Operating System: macOS 12.0.1 (21A559)
File System: Case-Sensitive Journaled HFS+ (APFS)
Datebase: PostgreSQL 13

Hi Everyone

I was trying to test a Scheduled Task that I originally developed in CUBA and found the following issues with both the legacy CUBA “Scheduled Tasks” support (1 - 5) and the new Quarz implementation (6 and 7).

And after my initial 1 - 5 findings listed below, I found the following statement from Natalia here - Administration menu

Hi.
We made the decision to stop support for our scheduled tasks engine and use https://www.quartz-scheduler.org instead.

So maybe points 1 - 5 are no longer relevant but if that’s the case, I would not expect to find this legacy implementation in Jmix, so this situation is not completely clear to me. Do you intend to use the Scheduled Tasks screen with the new Quarz backend in the future or are we expected to create our own UI for our Quarz implementation?

  1. In the Scheduled Tasks screen it is only possible to find beans that have an Interface definition. My CUBA-to-Jmix migration removed my Interfaces and generating a new bean (Component) does not generate an Interface source file, so you have to manually create one if you want to use it as a Scheduled Task with the Bean selection.

  2. When I try and run my Scheduled Task I receive this error…

2022-01-09 19:46:09.897 ERROR 11881 — [nio-8080-exec-1] c.h.c.w.a.s.ScheduledTaskBrowser : Can’t execute ScheduledTask{beanName=nf_MembershipService, methodName=expireAllMemberships, className=null, scriptName=null, singleton=true, period=36000, startDate=2022-01-10 00:00:00.000, cron=null}: not in permitted hosts or not a master.

I do not have this problem with CUBA (I leave the “Permitted Servers” field blank) and tried setting the “Permitted Servers” to localhost and to my computer’s hostname in Jmix but that did not have any affect.

  1. And when I receive the error notification the message in point 2, the text contents are missing:

Jmix_Scheduled_Tasks_Execute_Error

  1. The Scheduled Tasks “User Name” is not a mandatory field but if I do enter a User, e.g. admin, I cannot remove it later. Notice that the screen components are different in CUBA and Jmix:

CUBA
CUBA_Scheduled_Tasks_User_Name_field

Jmix
Jmix_Scheduled_Tasks_User_Name_field

  1. And I when I try to “Remove” my Scheduled Task, I receive this NPE after pressing the OK button in the confirmation dialog…

java.lang.NullPointerException
at com.haulmont.cuba.gui.components.actions.RemoveAction.doRemove(RemoveAction.java:331)
at com.haulmont.cuba.gui.components.actions.RemoveAction.remove(RemoveAction.java:247)
at com.haulmont.cuba.gui.components.actions.RemoveAction.lambda$confirmAndRemove$0(RemoveAction.java:225)
at io.jmix.core.common.event.EventHub.publish(EventHub.java:170)
at io.jmix.ui.action.BaseAction.actionPerform(BaseAction.java:220)
at io.jmix.ui.sys.DialogsImpl$OptionDialogBuilderImpl.lambda$show$0(DialogsImpl.java:344)
at io.jmix.ui.widget.JmixButton.fireClick(JmixButton.java:77)
at com.vaadin.ui.Button$1.click(Button.java:57)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at com.vaadin.server.ServerRpcManager.applyInvocation(ServerRpcManager.java:153)
at com.vaadin.server.ServerRpcManager.applyInvocation(ServerRpcManager.java:115)
at com.vaadin.server.communication.ServerRpcHandler.handleInvocation(ServerRpcHandler.java:442)
at com.vaadin.server.communication.ServerRpcHandler.handleInvocations(ServerRpcHandler.java:407)
at com.vaadin.server.communication.ServerRpcHandler.handleRpc(ServerRpcHandler.java:275)
at com.vaadin.server.communication.UidlRequestHandler.synchronizedHandleRequest(UidlRequestHandler.java:83)
at com.vaadin.server.SynchronizedRequestHandler.handleRequest(SynchronizedRequestHandler.java:40)
at com.vaadin.server.VaadinService.handleRequest(VaadinService.java:1636)
at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:465)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:750)

  1. In the Jmix Quartz documentation Quartz Job Scheduler Setup :: Jmix Documentation it states that you should add the following line to the application.properties file…

main.datasource.studio.liquibase.excludePrefixes = qrtz_

However, the application.properties already contains the following similar definition…

main.datasource.studio.liquibase.exclude-prefixes=audit_,email_,sec_,sys_,ui_

so I assume that the documentation needs to be updated(?) and that I may set the property as follows…

main.datasource.studio.liquibase.exclude-prefixes=audit_,email_,sec_,sys_,ui_,qrtz_

Which is correct excludePrefixes or exclude-prefixes or both?

  1. After following the steps for the Quartz implementation (for my Postgres config.) I receive the following log message at startup…

2022-01-09 11:15:51.385 INFO 8604 — [ main] s.a.ScheduledAnnotationBeanPostProcessor : More than one TaskScheduler bean exists within the context, and none is named ‘taskScheduler’. Mark one of them as primary or name it ‘taskScheduler’ (possibly as an alias); or implement the SchedulingConfigurer interface and call ScheduledTaskRegistrar#setScheduler explicitly within the configureTasks() callback: [core_ThreadPoolTaskScheduler, ui_ThreadPoolTaskScheduler]

What should I do to correct this?

That’s it (so far). Sorry for so many items but I hope that this information is useful.

Best regards
Chris