javaspringspring-bootschedulerpcf

Java Spring Scheduler not working in PCF server


I have a spring boot project in which spring scheduler is working fine as i have added logger in scheduler method in my local system using Cron expression.

Problem:

When same spring boot app is deployed over PCF(Pivotal Cloud Foundary) it does not enable the scheduler and no logs are printed neither any error is shown in pcf logs related to scheduler.

While if i hit any controller through postman, logs are printing for that but not of scheduler.

I also provided cron expression value like for every minute in pcf environment variables in app and restarted the app. But that didn't help.

Can anyone suggest me something in this issue?

Thank you in advance for your valuable time!!


Solution

  • When you deploy your application in PCF Cloud space, it takes your code, scan it against available buildpacks unless explicitly provided by user and then creates a container image also known as Droplet using code, build-pack and base container.

    If you use cloud config to manage the configurations for spring boot scheduler, it uses auto configurations to load the properties at runtime. In some cases due to the difference in the OS configuration and loading of these configurations at runtime, there will be mismatch between what timezone your app expects and the one that the server understands.

    Most of the time it can be resolved by explicitly defining the timezone configuration in PCF manifest file or command line when pushing the application.

    E.g. set environment TZ variable.

    cf set-env {app-name} TZ 'America/Chicago'
    

    OR by adding following in manifest.yml file:

    env: TZ: America/Chicago