logo
down
shadow

Spring Boot App runs scheduled job twice


Spring Boot App runs scheduled job twice

By : user2948585
Date : November 14 2020, 04:51 PM
wish of those help My Problem is that the scheduled method "updateMembers" is called twice. I googled for hours now and all i found was that the Problem may is that the class Scheduler is initialized twice but i don't know how to fix this. Any suggestions? , Problem solved with another Cron String: cron = "0 */15 * * * *"
code :


Share : facebook icon twitter icon
Does spring @Scheduled annotated methods runs on different threads?

Does spring @Scheduled annotated methods runs on different threads?


By : Mike Cook
Date : March 29 2020, 07:55 AM
I wish did fix the issue. For completeness, code below shows the simplest possible way to configure scheduler with java config:
code :
@Configuration
@EnableScheduling
public class SpringConfiguration {

    @Bean(destroyMethod = "shutdown")
    public Executor taskScheduler() {
        return Executors.newScheduledThreadPool(5);
    }
    ...
Spring @Scheduled task runs twice

Spring @Scheduled task runs twice


By : josepepe1991
Date : March 29 2020, 07:55 AM
seems to work fine I believe this is caused by same config file being loaded twice in your web.xml
code :
<servlet>
    <servlet-name>servlet</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/spring_config.xml</param-value> <!-- FIRST -->
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/spring_config.xml</param-value> <!-- SECOND -->
</context-param>
<beans>
    <context:component-scan base-package="web.controllers"/>
    <mvc:annotation-driven/>
    <mvc:default-servlet-handler/>
</beans>
<beans>
    <task:annotation-driven />
    <context:component-scan base-package="services"/>
    <context:component-scan base-package="dao"/>
    <context:component-scan base-package="scheduled"/>
    <context:property-placeholder location="/WEB-INF/application.properties"/>
</beans>
<servlet>
    <servlet-name>servlet</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>
Spring Boot runs scheduled job twice, But it works fine in the local

Spring Boot runs scheduled job twice, But it works fine in the local


By : Ed Norton
Date : March 29 2020, 07:55 AM
wish of those help
Check is there any two instance of your server? this cron job will be unique for only one server.
In eclipse a spring boot webflux websocket application runs correctly as gradle boot run but errors as a spring boot app

In eclipse a spring boot webflux websocket application runs correctly as gradle boot run but errors as a spring boot app


By : user3629449
Date : March 29 2020, 07:55 AM
it should still fix some issue I had to first of all run the application as a Java Application
Get command line parameter as spring batch job parameters for @Scheduled spring boot

Get command line parameter as spring batch job parameters for @Scheduled spring boot


By : Nahanian
Date : March 29 2020, 07:55 AM
I wish did fix the issue. You can inject a bean of type ApplicationArguments and use it to get application arguments:
code :
@EnableScheduling
@EnableBatchProcessing
@SpringBootApplication
public class MyMain {

    @Autowired
    private JobLauncher jobLauncher;

    @Autowired
    private Job job;

    @Autowired
    private ApplicationArguments applicationArguments;


    public static void main(String[] args) throws Exception {
        SpringApplication.run(MyMain.class, args);
    }

    @Scheduled(cron = "0 00 05 * * ?")
    private void perform() throws Exception {
        String[] sourceArgs = applicationArguments.getSourceArgs();
        JobParameters jobParameters; // create job parameters from sourceArgs
        jobLauncher.run(job, jobParameters);
    }
}
Related Posts Related Posts :
  • Stream corrupted exception - invalid code type AC [java]
  • Routing Sysout values to JTextArea
  • GWT RPC serialization for Dynamic Host Page
  • Best Approch of Returning Value from 'getter' Method
  • Understanding xml schemalocation
  • Checking if a PDF is PDF/A 1-a format or not using PDFBOX in java
  • Difference Between Variable and Identifier
  • How to compute two aggregate functions with Java streams?
  • Parse the value of the json to baseadapter in android?
  • JavaFX animation on raspberry pi
  • Solve "unchecked warning" in Java avoiding @suppressWarnings
  • How to specify a new name for a file while moving it to another directory in Java?
  • Popup window not showing up with spinner item selection?
  • how to iterate through json objects in java
  • Caused by: java.lang.NoClassDefFoundError: org/springframework/aop/framework/AbstractAdvisingBeanPostProcessor
  • Getting NoClassDefFoundError while running PMD task from Gradle
  • Matlab drag and drop file from windows explorer to figure (gui)
  • How does scala's actor model make use of C threads and native system threads?
  • Store java.util.Date as key in a Map based on reference equality instead of "value" equality
  • Error when logging into FTP from AsyncTask class using org.apache.commons.net.ftp.FTPClient
  • creating unique index in mongoDB
  • hibernate Query to find record based on substring
  • How many strings are in jvm string pool intern
  • Unable to initialize native-platform. on Jenkins
  • How to create a list of dummy files in Java?
  • Docker: Which approach is better? WAR embedded in image or base image + war?
  • java.lang.InternalError: CallerSensitive annotation expected at frame 1
  • How to write a method to read JSON files of different structures and return different POJO objects in Java?
  • Reference to Classes in Java
  • Unable to call function via companion object
  • REST: convert XML content passed with POST to a java object, attribute inside the element
  • Device not receive message from GCM
  • How to increase Openfire concurrent connection limit?
  • Android send custom parameter on AsyncTask
  • GWT - Get dom element's value from another page
  • How can i initialize an array in Java?
  • Is it possible to increase a java process's(when is running) size?
  • Getting Node Address instead of Value in Binary Search Tree
  • PdfByteContent not adding in iText pdf
  • Spring JpaRepository: delete() with subsequent save() in the same transaction
  • producer-consumer using arraydeque working only in breakpoint
  • Adding a JPanel to another JPanel
  • Comparison with operator ==, how does it work?
  • Error buildling with maven for openshift
  • What is the java equivilant to MySQL's smallint
  • proxy trouble on eclipse with https
  • Spring-Jdbc Template and Prepared statement
  • Mule - exception in Outbound endpoint Message payload is of type: byte[]
  • Modify package names for java classes generated from wsdl
  • How to download multiple images and have one progressBar using AsynTask (Android)
  • Implementing Service Provider, IdP and user in java with SAML (POC)
  • Why does my scanner repeat?
  • Can I forget ResultSetFuture in Cassandra java driver without facing memory leak?
  • XML to JAXB binding having nested elements?
  • Java: ToString() prints the same hashcode each time
  • Why am I getting a thread exception in my graphics program?
  • Can we read 4th byte from hexadecimal value?
  • How to create watermark in image just like Google maps watermarks
  • how come Thread class called inside another class?
  • AssertionError: Unexpected schema version 0: Unexpected schema version 0
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org