I have an schedule task interface defined as: -
/**
* Interface the defines bean methods that can be accessed by the Scheduled Tasks feature of CUBA.
*/
public interface FinsScheduledTasksService {
String NAME = "fins_FinsScheduledTasksService";
/**
* Performs updates to the StdMasterWaterbody entity. For example, if a water is a lake and has no reach, then
* a default one is created.
* @return Returns a string with the result of updating waters. If an exception occurs, then the result will be
* the Exception.toString() result.
*/
String updateWaters();
/**
* Identifies photos uploaded from the iPad without a thumbnail and creates one for it.
* @return Returns a string with the number of thumbnails generated. If an exception occurs, then the result will be
* the Exception.toString() result.
*/
String addPhotoThumbnail();
}
The addPhotoThumbnail implementation looks like this: -
/**
* Actual implementation of the scheduled task service interfaces.
*/
@Component(FinsScheduledTasksService.NAME)
public class FinsScheduledTasksServiceBean implements FinsScheduledTasksService {
// create logger
private Logger log = LoggerFactory.getLogger(FinsScheduledTasksServiceBean.class);
@Inject
private Persistence persistence;
@Inject
private UserSessionSource userSessionSource;
@Inject
private FileStorageService fileStorageService;
@Inject
private Metadata metadata;
/**
* Generates thumbnail images for photos uploaded from the iPad for faster rending when viewing a fish record.
* @return Returns a string with the number of thumbnails generated. If an exception occurs, then the result will be
* the Exception.toString() result.
*/
@Transactional
@Override
public String addPhotoThumbnail() {
String result;
Integer thumbnailsAdded = 0;
log.warn("Start addPhotoThumbnail Service Method: Retrieve Photos without thumbnails.");
Transaction tx = persistence.createTransaction();
try {
// logic
tx.commit();
result = String.format("End addPhotoThumbnail Service Method: There are %s Photos without thumbnails. Added %s thumbnails.", photos.size(), thumbnailsAdded);
log.warn(result);
return result;
}
catch (Exception ex) {
return ex.toString();
}
finally {
tx.end();
}
}
}
The scheduled task registers and runs successfully, however I cannot figure out how to debug using IntelliJ. Debugging works fine for screens and another service bean I have registered in the middleware.
How do I debug a scheduled task using Tomcat?
Regards, Mike.