Skip to Content

@schedule in spring-boot does not work in Java instance in sap cloud platform

Dear all,

I found that In SAP Cloud Platform, using spring-boot version 1.3.5 if I want to have a scheduled task using @schedule annotation, it doesn't work in HCP.

However, the same code works in localhost using my own computer.

I'm wondering whether there is anything wrong with my code or configuration file in the project or HCP simply doesn't support schedule in Spring-boot?

Here are the code snippets:

Main function:


import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.scheduling.annotation.EnableScheduling;

public class Application {
    public static void main(String[] args) throws Exception {;

Scheduled Job


import java.sql.Timestamp;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

public class ScheduledTasks {
	private static final Logger log = LoggerFactory.getLogger(ScheduledTasks.class);
	private static final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

	@Scheduled(fixedRate = 10000)
	public void updateDateAvailable() throws ParseException {"The time is now {}", dateFormat.format(new Date()));
		long time = System.currentTimeMillis();
		Date date = new Date();
		long minus = 86400000L;
		long endTime = new Date().getTime();
		long startTime = endTime-minus;"endTime´╝Ü"+endTime);"startTime:"+startTime);"date:"+date.toString());

The result is that I cannot find any log in HCP.

Also trying to insert a record to DB in a schedule doesn't work while it works in localhost.

Has anyone met the issue before? Thanks.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    May 12, 2017 at 07:05 AM

    I found the solution. It seems that in log information defined in code is not contained in HCP's log file. But the schedule function works fine.

    Add comment
    10|10000 characters needed characters exceeded