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

Hello Chris!

In Jmix we’ve decided to use Quartz API instead of our implementation for scheduled tasks, and currently, work is still in progress. Hoping soon this new add-on will be available for you.
Regarding the issues you reported - I have tried to create a CUBA project and migrate it to Jmix to reproduce them. There is my results.

  1. Bean with an interface from the CUBA project migrated successfully to Jmix without removing the interface, as is. Unable to reproduce.
  2. If I have property “cuba.schedulingActive” set to “true”, I’m able to create a new scheduled task with migrated bean and successfully run it. Unable to reproduce.
  3. Cause I haven’t any problem on the second step it is also not reproduced.
  4. It is unable to clear ‘User’ field after setting it. Issue raised https://github.com/Haulmont/jmix-cuba/issues/124
  5. Removing scheduled task failed with an NPE exception. Issue raised https://github.com/Haulmont/jmix-cuba/issues/123
  6. Since Jmix 1.1 uses kebab-case for properties naming, so “exclude-prefixes” more preferable, although both variants - “exclude-prefixes” and “excludePrefixes” are still working in runtime. We recommend to use kebab-case.
  7. I guess it is just INFO message and does not affect scheduler functionality. Nothing special is required.

Regards, Artem.

Hello Artem!

Thank you for your feedback and efforts and for opening the issues.

I was able to reproduce the problems in points 2 and 3 every time I tried to run the task but I did not have the time to try and reproduce it with an example project. If I find time to do this, then I will upload the project.

And I was not able to immediately implement a Quartz example from their website documentation, so I moved onto other post-migration refactoring. I will probably wait until you have released your new implementation before trying anything else. I have more than enough to do right now.

Best regards
Chris