Scheduling Tasks With Admin Users only

Hi Team ,

Currently we are scheduling tasking , it is working fine ,
But the user that is used while creating tasks is only admin user , when trying to make it with any other user , it is not working ,
Even while creating new user with administrator role and set it as the user for the scheduling task it is not working also ,
only admin username is working

please advise how we can create schedule task with use other than admin

Hi @abd.ibrahim.allam ,

How do you verify that a scheduled task has started? Using the Execution History screen?
Did you specify the administrator as the user on behalf of whom the task will be executed?

Below I gave an example of the process of launching a scheduled task.

To start a scheduled task, you need to take several steps:

  • To enable the CUBA scheduling task processing you should set the cuba.schedulingActive application property to true. You can do it either in the Administration > Application Properties screen, or through the app-core.cuba:type=Scheduling JMX bean (see its Active attribute).
  • Register the scheduled task in Administration → Scheduled Tasks.
  • Make the scheduled task Active in Scheduled Tasks browser.
  • To see the execution history of the scheduled task, when registering the task, you need to set the flags logStart and logEnd to true. Then you can see the execution history in Execution History screen (open this screen from Scheduled Tasks browser).
  • To see the running scheduled tasks at a given time, open the Running tasks screen.

It works for all types of users.

Also, you can find an example of using the Scheduling Tasks in the documentation.

Regards,
Gleb

1 Like

Hi Gleb ,

Thanks for your explanation , I already did the same previously and it is working fine and the schedule is working and do its job ,

But My Question is related to the user that is assigned to the task while creation

When you are creating Task you are selecting user if the user is not admin the the task is not executed automatically. so how can i put any other user other than admin and make the scheduler working automatically .

What do you mean by the automatic work of the scheduler?

1 Like

Hi Gleb ,

What I meant by Automatic Execution is Activating the task ,

But My main issue is was related to the user assigned to the task while creating the task .

when i was assigning any other user other than Admin , I was getting Authentication issue .

But Now after creating user with only Default role is working properly

Thanks for your support .

Hi Gleb ,

please give me feedback for below behavior ,

As before regarding the assigned user on the scheduled tasks .
After creating user to be used while creating the tasks as per below .and activating the tasks to start working .

POT1

Tasks worked for only one day with the new user as per below screen shot

POT2

Then today while checking status of the tasks as we figured out that the notification that is supposed to be sent by the scheduler is not received . and below exception logged into server log.

2019-11-07 07:11:19.097 ERROR [cuba_core_scheduler-1] org.springframework.scheduling.support.TaskUtils$LoggingErrorHandler - Unexpected error occurred in scheduled task.
java.lang.RuntimeException: Unable to perform system login
    at com.haulmont.cuba.security.app.Authentication.begin(Authentication.java:131) ~[classes/:na]
    at com.haulmont.cuba.security.app.Authentication.begin(Authentication.java:149) ~[classes/:na]
    at com.haulmont.cuba.core.app.scheduling.Scheduling.processScheduledTasks(Scheduling.java:108) ~[classes/:na]
    at com.haulmont.cuba.core.app.scheduling.Scheduling.processScheduledTasks(Scheduling.java:95) ~[classes/:na]
    at sun.reflect.GeneratedMethodAccessor228.invoke(Unknown Source) ~[na:na]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_181]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_181]
    at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:65) ~[shared/:na]
    at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54) ~[shared/:na]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [na:1.8.0_181]
    at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308) [na:1.8.0_181]
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180) [na:1.8.0_181]
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294) [na:1.8.0_181]
    at com.haulmont.cuba.core.sys.CubaThreadPoolTaskScheduler$TaskDecorator.run(CubaThreadPoolTaskScheduler.java:120) [classes/:na]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [na:1.8.0_181]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [na:1.8.0_181]
    at java.lang.Thread.run(Thread.java:748) [na:1.8.0_181]
Caused by: com.haulmont.cuba.security.global.LoginException: Unknown login name or bad password 'admin'
    at com.haulmont.cuba.security.auth.providers.SystemAuthenticationProvider.authenticate(SystemAuthenticationProvider.java:56) ~[classes/:na]
    at com.haulmont.cuba.security.auth.AuthenticationManagerBean.authenticateInternal(AuthenticationManagerBean.java:253) ~[classes/:na]
    at com.haulmont.cuba.security.auth.AuthenticationManagerBean.login(AuthenticationManagerBean.java:118) ~[classes/:na]
    at com.haulmont.cuba.security.app.Authentication.begin(Authentication.java:128) ~[classes/:na]
    ... 16 common frames omitted

> can you please clarify why such strange behavior happened.

Hi,

If you would try to debug the code or analyze the place in the code where exception has occured you would see that the exception fails when the system tried to obtain system session by logging in as a system user, before loading any scheduled tasks.

Shortly:
You need to have an active super-user in your application that is going to be used for internal system stuff.
Login of this user is defined by the Appendix B: Application Properties - CUBA Platform. Developer’s Manual application property (“admin” by default).

If you want to prevent this user to log in to the web client - you can set the “password” field of this user to empty string in the database.

1 Like