Hi Eduardo,
I have a similar situation to what you have.
I am getting the error message below due to the fact that I use SessionData bean to pass data around in my application and there is a need to call restful service from within a background task.
Error creating bean with name ‘core_SessionData’: Scope ‘session’ is not active for the current thread; consider defining a scoped proxy for this bean if you intend to refer to it from a singleton
Is there a cleaner solution different from what Krivopustov provided?
Right now, I need to email a pdf report from within a background task. The pdf is an output from e report with a dataset connected to an additional datastore that get its data from a restful service.
public void emailRFQ(QuotationRequest quoteReq) throws EmailException {
//set the tenant email smtp details
getMailPropertiesByTenant(quoteReq.getTenant());
String msg = String.format("Request for Quotation %s emailed",quoteReq.getRfqNo());
ReportOutputDocument rfqPDF = reportRunner.byReportCode(“RFQ”)
.addParam(“entity”,quoteReq)
.run();
byte[] content = rfqPDF.getContent();
EmailAttachment emailAtt = new EmailAttachment(content, rfqPDF.getDocumentName());
EmailInfo emailInfo = EmailInfoBuilder.create()
.setFrom(utilityService.getTenant(quoteReq.getTenant()).getSenderEmail())
.setAddresses(quoteReq.getCustomer().getSalesPerson().getEmail())
.setSubject(String.format("Request for Quotation: %s ",quoteReq.getRfqNo()))
.setBody(msg)
.setAttachments(emailAtt)
.build();
//emailer.sendEmailAsync(emailInfo);
emailer.sendEmail(emailInfo);
}
The solution provided above is not working for me because I don’t have the means of performing the solution above.
Please assist me here
Thanks in advance