Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Spring Boot app getting crash at startup due to JobRunr cron job 'JobRunrException' #189

Closed
RahulSDeshpande opened this issue Aug 10, 2021 · 9 comments
Labels
documentation Improvements or additions to documentation wontfix This will not be worked on
Milestone

Comments

@RahulSDeshpande
Copy link

RahulSDeshpande commented Aug 10, 2021

Are you running the latest version of JobRunr?
Yes

How to Reproduce
I am strangely facing similar issue since yesterday.

I don't know what is wrong going, I didn't change any line of code in this file since long.

Here is my code:

@PostConstruct
fun startJobRunr() {
    jobScheduler.scheduleRecurrently(Cron.minutely()) {
        runJob1()
        runJob2()
    }
}

@Job
fun runJob2() {
    ..
}

@Job
fun runJob2() {
    ..
}

Crash log stack-trace

Caused by: org.jobrunr.JobRunrException: JobRunr encountered a problematic exception. Please create a bug report (if possible, provide the code to reproduce this and the stacktrace)
	at org.jobrunr.JobRunrException.shouldNotHappenException(JobRunrException.java:43) ~[jobrunr-3.2.1.jar:na]
	at org.jobrunr.jobs.details.JobDetailsGeneratorUtils.createObjectViaMethod(JobDetailsGeneratorUtils.java:70) ~[jobrunr-3.2.1.jar:na]
	at org.jobrunr.jobs.details.instructions.JobDetailsInstruction.getObject(JobDetailsInstruction.java:79) ~[jobrunr-3.2.1.jar:na]
	at org.jobrunr.jobs.details.instructions.JobDetailsInstruction.invokeInstruction(JobDetailsInstruction.java:44) ~[jobrunr-3.2.1.jar:na]
	at org.jobrunr.jobs.details.instructions.AbstractJVMInstruction.invokeInstructionAndPushOnStack(AbstractJVMInstruction.java:18) ~[jobrunr-3.2.1.jar:na]
	at org.jobrunr.jobs.details.JobDetailsBuilder.invokeInstructions(JobDetailsBuilder.java:92) ~[jobrunr-3.2.1.jar:na]
	at org.jobrunr.jobs.details.JobDetailsBuilder.getJobDetails(JobDetailsBuilder.java:70) ~[jobrunr-3.2.1.jar:na]
	at org.jobrunr.jobs.details.AbstractJobDetailsFinder.getJobDetails(AbstractJobDetailsFinder.java:84) ~[jobrunr-3.2.1.jar:na]
	at org.jobrunr.jobs.details.KotlinJobDetailsFinder.getJobDetails(KotlinJobDetailsFinder.java:16) ~[jobrunr-3.2.1.jar:na]
	at org.jobrunr.jobs.details.JobDetailsAsmGenerator.toJobDetails(JobDetailsAsmGenerator.java:16) ~[jobrunr-3.2.1.jar:na]
	at org.jobrunr.scheduling.JobScheduler.scheduleRecurrently(JobScheduler.java:542) ~[jobrunr-3.2.1.jar:na]
	at org.jobrunr.scheduling.JobScheduler.scheduleRecurrently(JobScheduler.java:506) ~[jobrunr-3.2.1.jar:na]
	at org.jobrunr.scheduling.JobScheduler.scheduleRecurrently(JobScheduler.java:472) ~[jobrunr-3.2.1.jar:na]
	at ******* HIDDEN AS ITS A PRIVATE PROJECT FILE PATH **.startJobRunr(ScheduledTasks.kt:97) ~[classes/:na]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_282]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_282]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_282]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_282]
	at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:389) ~[spring-beans-5.3.5.jar:5.3.5]
	at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:333) ~[spring-beans-5.3.5.jar:5.3.5]
	at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:157) ~[spring-beans-5.3.5.jar:5.3.5]

Environment
I'm using JobRunr version: 3.2.1

My IntelliJ config

IntelliJ IDEA 2021.1.1 (Ultimate Edition)
Build #IU-211.7142.45, built on April 30, 2021
Runtime version: 11.0.10+9-b1341.41 x86_64
VM: Dynamic Code Evolution 64-Bit Server VM by JetBrains s.r.o.
macOS 11.2.3
GC: ParNew, ConcurrentMarkSweep
Memory: 4012M
Cores: 12
Non-Bundled Plugins: com.markskelton.one-dark-theme (5.3.0), net.ashald.envfile (3.2.1), wu.seal.tool.jsontokotlin (3.7.2), org.jetbrains.plugins.vue (211.7142.13), org.jetbrains.kotlin (211-1.5.21-release-317-IJ7442.40), com.nbadal.ktlint (0.7.6), ru.adelf.idea.dotenv (2021.1)
Kotlin: 211-1.5.21-release-317-IJ7442.40

Expected behavior
All the jobs should run & the spring boot instance should not crash.

@rdehuyss
Copy link
Contributor

The caused by of the stacktrace is missing so I can't really help now.

@rdehuyss
Copy link
Contributor

Did your kotlin version change?

@RahulSDeshpande
Copy link
Author

RahulSDeshpande commented Aug 10, 2021

@rdehuyss

That is the only stack trace I see in the logs.

And no I didn't change the project's Kotlin version.

@rdehuyss
Copy link
Contributor

Yes, it's the only stack trace but the caused by part is missing. See https://github.com/jobrunr/jobrunr/blob/master/core/src/main/java/org/jobrunr/jobs/details/JobDetailsGeneratorUtils.java#L70 (the variable e)/

@RahulSDeshpande
Copy link
Author

Hi @rdehuyss

I finally fixed it.

Seems like, a single scheduleRecurrently() { .. } won't accept multiple job method calls 😄
So I wrote multiple scheduleRecurrently() { .. }s for all the job method calls.

This is the final code.

@PostConstruct
fun startJobRunr() {

    jobScheduler.scheduleRecurrently(Cron.minutely()) {
        runJob1()
    }

    jobScheduler.scheduleRecurrently(Cron.minutely()) {
        runJob2()
    }
}

@Job
fun runJob2() {
    ..
}

@Job
fun runJob2() {
    ..
}

I am not sure whether this is mentioned in the JobRunr docs or I missed reading it.

But this is strange.
The library should allow multiple jobs calls from a single scheduleRecurrently call I think.

Is this design by purpose?

Anyways great library!

Cheers 💯

@RahulSDeshpande
Copy link
Author

Closing this issue 👍🏼

@rdehuyss
Copy link
Contributor

Documentation needs to be updated

@rdehuyss rdehuyss added documentation Improvements or additions to documentation and removed Awaiting feedback labels Aug 11, 2021
@rdehuyss rdehuyss added this to the 4.0 milestone Aug 11, 2021
rdehuyss added a commit that referenced this issue Aug 24, 2021
@stale
Copy link

stale bot commented Aug 27, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix This will not be worked on label Aug 27, 2021
@rdehuyss
Copy link
Contributor

Solved in 4.0.0-RC2 (somewhere tomorrow in Maven Central) and in docs once deployed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants