Jmix 2 Quartz: User not found

Jmix 2.2.3 Hello, I have some problems with Quartz - I copied the database to another server and started the application, however, these 2 errors are constantly showing in the log, pessimistic locking and email sending is quite worrisome

2024-11-13 00:02:00 - Unable to notify JobListener(s) of Job to be executed: (Job will NOT be executed!). trigger= DEFAULT.emailSendingCronTrigger job= DEFAULT.emailSending
org.quartz.SchedulerException: JobListener 'quartz_JobExecutionListener' threw exception: User not found

How to diagnose what’s wrong? Emails are being sent, but it’s a bad feeling :slight_smile:

2024-11-13 00:01:00 - Unable to notify JobListener(s) of Job to be executed: (Job will NOT be executed!). trigger= DEFAULT.pessimisticLockExpiringTrigger job= DEFAULT.pessimisticLockExpiring
org.quartz.SchedulerException: JobListener 'quartz_JobExecutionListener' threw exception: User not found
	at org.quartz.core.QuartzScheduler.notifyJobListenersToBeExecuted(QuartzScheduler.java:1929)
	at org.quartz.core.JobRunShell.notifyListenersBeginning(JobRunShell.java:324)
	at org.quartz.core.JobRunShell.run(JobRunShell.java:173)
	at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)
Caused by: org.springframework.security.core.userdetails.UsernameNotFoundException: User not found
	at io.jmix.securitydata.user.AbstractDatabaseUserRepository.loadUserByUsername(AbstractDatabaseUserRepository.java:186)
	at io.jmix.core.security.impl.SystemAuthenticationProvider.authenticate(SystemAuthenticationProvider.java:48)
	at org.springframework.security.authentication.ProviderManager.authenticate(ProviderManager.java:182)
	at io.jmix.core.security.impl.SystemAuthenticatorImpl.begin(SystemAuthenticatorImpl.java:75)
	at io.jmix.core.security.impl.SystemAuthenticatorImpl.runWithUser(SystemAuthenticatorImpl.java:117)
	at io.jmix.flowui.UiEventPublisher.sendEventToUserSessions(UiEventPublisher.java:105)
	at io.jmix.flowui.UiEventPublisher.publishEventForUsersInternal(UiEventPublisher.java:88)
	at io.jmix.flowui.UiEventPublisher.onUiUserEvent(UiEventPublisher.java:83)
	at jdk.internal.reflect.GeneratedMethodAccessor170.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:569)
	at org.springframework.context.event.ApplicationListenerMethodAdapter.doInvoke(ApplicationListenerMethodAdapter.java:365)
	at org.springframework.context.event.ApplicationListenerMethodAdapter.processEvent(ApplicationListenerMethodAdapter.java:237)
	at org.springframework.context.event.ApplicationListenerMethodAdapter.onApplicationEvent(ApplicationListenerMethodAdapter.java:168)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:185)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:178)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:156)
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:451)
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:384)
	at io.jmix.core.cluster.ClusterApplicationEventPublisher.onAppEventMessage(ClusterApplicationEventPublisher.java:56)
	at io.jmix.core.cluster.LocalApplicationEventChannelSupplier$1.lambda$send$0(LocalApplicationEventChannelSupplier.java:52)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
	at io.jmix.core.cluster.LocalApplicationEventChannelSupplier$1.send(LocalApplicationEventChannelSupplier.java:52)
	at org.springframework.messaging.MessageChannel.send(MessageChannel.java:45)
	at io.jmix.core.cluster.ClusterApplicationEventPublisher.publish(ClusterApplicationEventPublisher.java:70)
	at io.jmix.flowui.UiEventPublisher.publishEventForUsers(UiEventPublisher.java:163)
	at io.jmix.quartzflowui.event.JobExecutionListener.jobToBeExecuted(JobExecutionListener.java:67)
	at org.quartz.core.QuartzScheduler.notifyJobListenersToBeExecuted(QuartzScheduler.java:1927)
	... 3 common frames omitted
2024-11-13 00:02:00 - Unable to notify JobListener(s) of Job to be executed: (Job will NOT be executed!). trigger= DEFAULT.emailSendingCronTrigger job= DEFAULT.emailSending
org.quartz.SchedulerException: JobListener 'quartz_JobExecutionListener' threw exception: User not found
	at org.quartz.core.QuartzScheduler.notifyJobListenersToBeExecuted(QuartzScheduler.java:1929)
	at org.quartz.core.JobRunShell.notifyListenersBeginning(JobRunShell.java:324)
	at org.quartz.core.JobRunShell.run(JobRunShell.java:173)
	at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)
Caused by: org.springframework.security.core.userdetails.UsernameNotFoundException: User not found
	at io.jmix.securitydata.user.AbstractDatabaseUserRepository.loadUserByUsername(AbstractDatabaseUserRepository.java:186)
	at io.jmix.core.security.impl.SystemAuthenticationProvider.authenticate(SystemAuthenticationProvider.java:48)
	at org.springframework.security.authentication.ProviderManager.authenticate(ProviderManager.java:182)
	at io.jmix.core.security.impl.SystemAuthenticatorImpl.begin(SystemAuthenticatorImpl.java:75)
	at io.jmix.core.security.impl.SystemAuthenticatorImpl.runWithUser(SystemAuthenticatorImpl.java:117)
	at io.jmix.flowui.UiEventPublisher.sendEventToUserSessions(UiEventPublisher.java:105)
	at io.jmix.flowui.UiEventPublisher.publishEventForUsersInternal(UiEventPublisher.java:88)
	at io.jmix.flowui.UiEventPublisher.onUiUserEvent(UiEventPublisher.java:83)
	at jdk.internal.reflect.GeneratedMethodAccessor170.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:569)
	at org.springframework.context.event.ApplicationListenerMethodAdapter.doInvoke(ApplicationListenerMethodAdapter.java:365)
	at org.springframework.context.event.ApplicationListenerMethodAdapter.processEvent(ApplicationListenerMethodAdapter.java:237)
	at org.springframework.context.event.ApplicationListenerMethodAdapter.onApplicationEvent(ApplicationListenerMethodAdapter.java:168)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:185)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:178)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:156)
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:451)
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:384)
	at io.jmix.core.cluster.ClusterApplicationEventPublisher.onAppEventMessage(ClusterApplicationEventPublisher.java:56)
	at io.jmix.core.cluster.LocalApplicationEventChannelSupplier$1.lambda$send$0(LocalApplicationEventChannelSupplier.java:52)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
	at io.jmix.core.cluster.LocalApplicationEventChannelSupplier$1.send(LocalApplicationEventChannelSupplier.java:52)
	at org.springframework.messaging.MessageChannel.send(MessageChannel.java:45)
	at io.jmix.core.cluster.ClusterApplicationEventPublisher.publish(ClusterApplicationEventPublisher.java:70)
	at io.jmix.flowui.UiEventPublisher.publishEventForUsers(UiEventPublisher.java:163)
	at io.jmix.quartzflowui.event.JobExecutionListener.jobToBeExecuted(JobExecutionListener.java:67)
	at org.quartz.core.QuartzScheduler.notifyJobListenersToBeExecuted(QuartzScheduler.java:1927)
	... 3 common frames omitted (edited)

Kind regards,
Mladen

Hello,

Looks like you have the following issue - Quartz Job Sending Notification to all users when they have no User in the User Database · Issue #3269 · jmix-framework/jmix · GitHub.
It has been fixed within Rework job statuses acquiring · Issue #3281 · jmix-framework/jmix · GitHub.

Is it acceptable for you to update to Jmix 2.3 at least?

Regards,
Ivan

Thank you Ivan,

I can not update the application yet because moving to this version includes changes in the navigation to the views and that would affect the way I’m calling BPM input dialog process forms. I intend to upgrade to 2.3 or even 2.4 asap but that will take some time.

**Additional changes**

* Removed events:
  * io.jmix.quartzflowui.event.QuartzJobEndExecutionEvent
  * io.jmix.quartzflowui.event.QuartzJobStartExecutionEvent
* Changed package of listener
  * io.jmix.quartzflowui.event.JobExecutionListener -> io.jmix.quartzflowui.listener.JobExecutionListener

Do you think this can be backported easily? If not many io.jmix files were changed, maybe I can override them as a temporary fix?
Can this error cause a memory leak? Otherwise if it is just logging the failed operation, it can wait.

Kind regards,
Mladen

These are not the only files that have been changed.
I don’t think we will backport it to 2.2, but I will check the possibility to override it on project side.

It doesn’t look like it can cause a memory leak.
I’m more concerned about execution of Job if this error is occurred. Are you sure your Jobs actualy execute their logic?

Additional questions:

  • Does application run in cluster environment?
  • Does it use default Jmix user management and authentication or some external provider (OIDC)?

Regards,
Ivan

If it takes a lot of your time, I will upgrade when possible.

I’m sure about the emailing job being executed, emails are going out.
For the pessimistic locking job, I’m not sure, but so far I had no problems.
It is not a clustered environment; it is a single Amazon Linux 2023 EC2 instance with the application, connecting to a RDS Postgres database instance, and a bastion VPN on the same VPC.

Kind regards,
Mladen

One of the parts of JobExecutionListener is sending the UI events to change the state of some job (when it starts/finishes execution) in real-time within current UI (and that failed in your case).
And we got rid of it in the fix mentioned above besides additional fixes and QoL changes related to job states.

So as a bare minimum you can override io.jmix.quartzflowui.event.JobExecutionListener bean (Extending Functionality :: Jmix Documentation) and remove events sending.

public class ExtJobExecutionListener extends JobExecutionListener {

    private static final Logger log = LoggerFactory.getLogger(ExtJobExecutionListener.class);

    @Override
    public void jobToBeExecuted(JobExecutionContext context) {
        log.debug("jobToBeExecuted: {}", context);
        runningJobCache.put(context.getJobDetail().getKey(), context.getJobDetail());
    }

    @Override
    public void jobWasExecuted(JobExecutionContext context, JobExecutionException jobException) {
        log.debug("jobWasExecuted: {}", context);
        runningJobCache.invalidate(context.getJobDetail().getKey());
    }
}

All the rest remains the same.

Regards,
Ivan

Thank you very much,
I will go to implement this. :slight_smile:

Kind regards,
Mladen