Comments (10)
Hello,
You are trying to use the plugin in environment where a hibernate session is absent. Just use withNew Session
. http://docs.grails.org/2.5.x/ref/Domain%20Classes/withNewSession.html
AsynchronousMailMessage.withNewSession {
asynchronousMailService.sendMail {
multipart true
to inParam?.user
subject "Report ${obj?.reportFileName}.pdf"
body "Your report is generated and attached with this mail."
attachBytes "${obj?.reportFileName}.pdf", "application/pdf", obj?.generatedBytes
}
}
If it will be OK, please close this issue.
from grails-asynchronous-mail.
Thanks a lot Vitali. Appreciate your help.
I’ll close the issue.
Regards,
Abhay
From: Vitalii Samolovskikh [email protected]
Reply-To: kefirfromperm/grails-asynchronous-mail [email protected]
Date: Friday, May 20, 2016 at 6:10 PM
To: kefirfromperm/grails-asynchronous-mail [email protected]
Cc: Abhay Goel [email protected], Author [email protected]
Subject: Re: [kefirfromperm/grails-asynchronous-mail] Hibernate Exception while sending mail from an asynchronous Event Listener in Grails 2.5.2 (#59)
Hello,
You are trying to use the plugin in environment where a hibernate session is absent. Just use withNew Session. http://docs.grails.org/2.5.x/ref/Domain%20Classes/withNewSession.html
AsynchronousMailMessage.withNewSession {
asynchronousMailService.sendMail {
multipart true
to inParam?.user
subject "Report ${obj?.reportFileName}.pdf"
body "Your report is generated and attached with this mail."
attachBytes "${obj?.reportFileName}.pdf", "application/pdf", obj?.generatedBytes
}
}
If it will be OK, please close this issue.
—
You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
from grails-asynchronous-mail.
Hi Vitalii,
Unfortunately, I’m getting another error this time.
Here’s the updated code:
AsynchronousMailMessage.withNewSession {
asynchronousMailService.sendMail {
multipart true
to user
subject "Report ${reportFileName}.pdf"
body "Your report is generated and attached with this mail."
attach("${reportFileName}.pdf", "application/pdf", generatedBytes)
}
}
Stacktrace:
grails.validation.ValidationException: Validation Error(s) occurred during save():
- Field error in object 'grails.plugin.asyncmail.AsynchronousMailMessage' on field 'attachments[0].attachmentName': rejected value [null]; codes [grails.plugin.asyncmail.AsynchronousMailAttachment.attachmentName.nullable.error.grails.plugin.asyncmail.AsynchronousMailMessage.attachments[0].attachmentName,grails.plugin.asyncmail.AsynchronousMailAttachment.attachmentName.nullable.error.grails.plugin.asyncmail.AsynchronousMailMessage.attachments.attachmentName,grails.plugin.asyncmail.AsynchronousMailAttachment.attachmentName.nullable.error.attachments[0].attachmentName,grails.plugin.asyncmail.AsynchronousMailAttachment.attachmentName.nullable.error.attachments.attachmentName,grails.plugin.asyncmail.AsynchronousMailAttachment.attachmentName.nullable.error.attachmentName,grails.plugin.asyncmail.AsynchronousMailAttachment.attachmentName.nullable.error.java.lang.String,grails.plugin.asyncmail.AsynchronousMailAttachment.attachmentName.nullable.error,asynchronousMailAttachment.attachmentName.nullable.error.grails.plugin.asyncmail.AsynchronousMailMessage.attachments[0].attachmentName,asynchronousMailAttachment.attachmentName.nullable.error.grails.plugin.asyncmail.AsynchronousMailMessage.attachments.attachmentName,asynchronousMailAttachment.attachmentName.nullable.error.attachments[0].attachmentName,asynchronousMailAttachment.attachmentName.nullable.error.attachments.attachmentName,asynchronousMailAttachment.attachmentName.nullable.error.attachmentName,asynchronousMailAttachment.attachmentName.nullable.error.java.lang.String,asynchronousMailAttachment.attachmentName.nullable.error,grails.plugin.asyncmail.AsynchronousMailAttachment.attachmentName.nullable.grails.plugin.asyncmail.AsynchronousMailMessage.attachments[0].attachmentName,grails.plugin.asyncmail.AsynchronousMailAttachment.attachmentName.nullable.grails.plugin.asyncmail.AsynchronousMailMessage.attachments.attachmentName,grails.plugin.asyncmail.AsynchronousMailAttachment.attachmentName.nullable.attachments[0].attachmentName,grails.plugin.asyncmail.AsynchronousMailAttachment.attachmentName.nullable.attachments.attachmentName,grails.plugin.asyncmail.AsynchronousMailAttachment.attachmentName.nullable.attachmentName,grails.plugin.asyncmail.AsynchronousMailAttachment.attachmentName.nullable.java.lang.String,grails.plugin.asyncmail.AsynchronousMailAttachment.attachmentName.nullable,asynchronousMailAttachment.attachmentName.nullable.grails.plugin.asyncmail.AsynchronousMailMessage.attachments[0].attachmentName,asynchronousMailAttachment.attachmentName.nullable.grails.plugin.asyncmail.AsynchronousMailMessage.attachments.attachmentName,asynchronousMailAttachment.attachmentName.nullable.attachments[0].attachmentName,asynchronousMailAttachment.attachmentName.nullable.attachments.attachmentName,asynchronousMailAttachment.attachmentName.nullable.attachmentName,asynchronousMailAttachment.attachmentName.nullable.java.lang.String,asynchronousMailAttachment.attachmentName.nullable,nullable.grails.plugin.asyncmail.AsynchronousMailMessage.attachments[0].attachmentName,nullable.grails.plugin.asyncmail.AsynchronousMailMessage.attachments.attachmentName,nullable.attachments[0].attachmentName,nullable.attachments.attachmentName,nullable.attachmentName,nullable.java.lang.String,nullable]; arguments [attachmentName,class grails.plugin.asyncmail.AsynchronousMailAttachment]; default message [Property [{0}] cannot be null]
- Field error in object 'grails.plugin.asyncmail.AsynchronousMailMessage' on field 'attachments[0].content': rejected value [null]; codes [grails.plugin.asyncmail.AsynchronousMailAttachment.content.nullable.error.grails.plugin.asyncmail.AsynchronousMailMessage.attachments[0].content,grails.plugin.asyncmail.AsynchronousMailAttachment.content.nullable.error.grails.plugin.asyncmail.AsynchronousMailMessage.attachments.content,grails.plugin.asyncmail.AsynchronousMailAttachment.content.nullable.error.attachments[0].content,grails.plugin.asyncmail.AsynchronousMailAttachment.content.nullable.error.attachments.content,grails.plugin.asyncmail.AsynchronousMailAttachment.content.nullable.error.content,grails.plugin.asyncmail.AsynchronousMailAttachment.content.nullable.error.[B,grails.plugin.asyncmail.AsynchronousMailAttachment.content.nullable.error,asynchronousMailAttachment.content.nullable.error.grails.plugin.asyncmail.AsynchronousMailMessage.attachments[0].content,asynchronousMailAttachment.content.nullable.error.grails.plugin.asyncmail.AsynchronousMailMessage.attachments.content,asynchronousMailAttachment.content.nullable.error.attachments[0].content,asynchronousMailAttachment.content.nullable.error.attachments.content,asynchronousMailAttachment.content.nullable.error.content,asynchronousMailAttachment.content.nullable.error.[B,asynchronousMailAttachment.content.nullable.error,grails.plugin.asyncmail.AsynchronousMailAttachment.content.nullable.grails.plugin.asyncmail.AsynchronousMailMessage.attachments[0].content,grails.plugin.asyncmail.AsynchronousMailAttachment.content.nullable.grails.plugin.asyncmail.AsynchronousMailMessage.attachments.content,grails.plugin.asyncmail.AsynchronousMailAttachment.content.nullable.attachments[0].content,grails.plugin.asyncmail.AsynchronousMailAttachment.content.nullable.attachments.content,grails.plugin.asyncmail.AsynchronousMailAttachment.content.nullable.content,grails.plugin.asyncmail.AsynchronousMailAttachment.content.nullable.[B,grails.plugin.asyncmail.AsynchronousMailAttachment.content.nullable,asynchronousMailAttachment.content.nullable.grails.plugin.asyncmail.AsynchronousMailMessage.attachments[0].content,asynchronousMailAttachment.content.nullable.grails.plugin.asyncmail.AsynchronousMailMessage.attachments.content,asynchronousMailAttachment.content.nullable.attachments[0].content,asynchronousMailAttachment.content.nullable.attachments.content,asynchronousMailAttachment.content.nullable.content,asynchronousMailAttachment.content.nullable.[B,asynchronousMailAttachment.content.nullable,nullable.grails.plugin.asyncmail.AsynchronousMailMessage.attachments[0].content,nullable.grails.plugin.asyncmail.AsynchronousMailMessage.attachments.content,nullable.attachments[0].content,nullable.attachments.content,nullable.content,nullable.[B,nullable]; arguments [content,class grails.plugin.asyncmail.AsynchronousMailAttachment]; default message [Property [{0}] cannot be null]
at grails.plugin.asyncmail.AsynchronousMailPersistenceService.save(AsynchronousMailPersistenceService.groovy:8)
at GrailsMelodyGrailsPlugin$_closure4$_closure16$_closure17.doCall(GrailsMelodyGrailsPlugin.groovy:184)
at grails.plugin.asyncmail.AsynchronousMailService$_sendAsynchronousMail_closure1.doCall(AsynchronousMailService.groovy:42)
at grails.plugin.asyncmail.AsynchronousMailService.sendAsynchronousMail(AsynchronousMailService.groovy:41)
at GrailsMelodyGrailsPlugin$_closure4$_closure16$_closure17.doCall(GrailsMelodyGrailsPlugin.groovy:184)
at AsynchronousMailGrailsPlugin$_configureSendMail_closure8.doCall(AsynchronousMailGrailsPlugin.groovy:128)
at GrailsMelodyGrailsPlugin$_closure4$_closure16$_closure17.doCall(GrailsMelodyGrailsPlugin.groovy:184)
at MailGrailsPlugin$_configureSendMail_closure7.doCall(MailGrailsPlugin.groovy:175)
at GrailsMelodyGrailsPlugin$_closure4$_closure16$_closure17.doCall(GrailsMelodyGrailsPlugin.groovy:184)
at com.bq.export.BqExportService$__tt__generateReportAsByteArray_closure7.doCall(BqExportService.groovy:252)
at com.bq.export.BqExportService.$tt__generateReportAsByteArray(BqExportService.groovy:251)
at GrailsMelodyGrailsPlugin$_closure4$_closure16$_closure17.doCall(GrailsMelodyGrailsPlugin.groovy:184)
at com.bq.export.BqExportController$_generateReportAndMail_closure1.doCall(BqExportController.groovy:41)
at groovyx.gpars.group.PGroup$3.call(PGroup.java:289)
at groovyx.gpars.group.PGroup$4.run(PGroup.java:313)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
2016-05-20 18:56:21,706 +0530 [Actor Thread 1] TRACE AsynchronousMailService:104 - Start send job immediately.
2016-05-20 18:56:21,718 +0530 [quartzScheduler_Worker-4] TRACE AsynchronousMailJob:104 - Entering execute method.
2016-05-20 18:56:21,728 +0530 [quartzScheduler_Worker-4] TRACE AsynchronousMailJob:104 - Exiting execute method. Execution time = 10ms
From: Vitalii Samolovskikh [email protected]
Reply-To: kefirfromperm/grails-asynchronous-mail [email protected]
Date: Friday, May 20, 2016 at 6:10 PM
To: kefirfromperm/grails-asynchronous-mail [email protected]
Cc: Abhay Goel [email protected], Author [email protected]
Subject: Re: [kefirfromperm/grails-asynchronous-mail] Hibernate Exception while sending mail from an asynchronous Event Listener in Grails 2.5.2 (#59)
Hello,
You are trying to use the plugin in environment where a hibernate session is absent. Just use withNew Session. http://docs.grails.org/2.5.x/ref/Domain%20Classes/withNewSession.html
AsynchronousMailMessage.withNewSession {
asynchronousMailService.sendMail {
multipart true
to inParam?.user
subject "Report ${obj?.reportFileName}.pdf"
body "Your report is generated and attached with this mail."
attachBytes "${obj?.reportFileName}.pdf", "application/pdf", obj?.generatedBytes
}
}
If it will be OK, please close this issue.
—
You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
from grails-asynchronous-mail.
Try to set
grailsApplication.config.asynchronous.mail.newSessionOnImmediateSend = false
from grails-asynchronous-mail.
Hi Vitalli,
No luck Still the same problem.
Regards,
Abhay
From: Vitalii Samolovskikh [email protected]
Reply-To: kefirfromperm/grails-asynchronous-mail [email protected]
Date: Friday, May 20, 2016 at 10:52 PM
To: kefirfromperm/grails-asynchronous-mail [email protected]
Cc: Abhay Goel [email protected], Author [email protected]
Subject: Re: [kefirfromperm/grails-asynchronous-mail] Hibernate Exception while sending mail from an asynchronous Event Listener in Grails 2.5.2 (#59)
Try to set
grailsApplication.config.asynchronous.mail.newSessionOnImmediateSend = false
—
You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
from grails-asynchronous-mail.
Please print all parameters "${reportFileName}.pdf", "application/pdf", generatedBytes
before call attach. All of them is not null and not blank?
from grails-asynchronous-mail.
Yup. Already did that. I have printed them inside the sendMail closure and all are not null. I have tried with standard mail plugin (non-asynchronous) and it works fine.
From: Vitalii Samolovskikh [email protected]
Reply-To: kefirfromperm/grails-asynchronous-mail [email protected]
Date: Saturday, May 21, 2016 at 12:36 PM
To: kefirfromperm/grails-asynchronous-mail [email protected]
Cc: Abhay Goel [email protected], Author [email protected]
Subject: Re: [kefirfromperm/grails-asynchronous-mail] Hibernate Exception while sending mail from an asynchronous Event Listener in Grails 2.5.2 (#59)
Please print all parameters "${reportFileName}.pdf", "application/pdf", generatedBytes before call attach. All of them is not null and not blank?
—
You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
from grails-asynchronous-mail.
Which database do you use?
Please attach latest log.
from grails-asynchronous-mail.
@abhaygoel Maybe you could create a sample application describing the problem scenario and share the github link here so that we can try to solve it.
from grails-asynchronous-mail.
Can't reproduce.
from grails-asynchronous-mail.
Related Issues (20)
- Grails 3.2.8 and asynchronous-mail:2.0.0.RC7 - startJobs causes NullPointerException HOT 1
- NPE with new version of quartz plugin HOT 3
- Wrong import path for enums
- Add support of List-Unsubscribe HOT 1
- Sending Multipart Emails fails (Text + HTML)
- grails 3.3.1 can not work with grails-asynchronous-mail 2.0.0.RC7 HOT 5
- Add support the method sendMail(Config)
- Too strict emails validation HOT 12
- onStartup() not called HOT 1
- Use gorm data services
- Triggers on cluster in Grails 3.3.x and Quartz 2.0.13
- HibernateOptimisticLockingFailureException after upgrade to grails 3.3 HOT 3
- alternative should be text instead of varchar(255)
- Exception thrown after upgrading to Grails 3.3.8 HOT 1
- Grails 4.0 and OpenJDK11 happened problem HOT 3
- TransactionRequiredException in Grails 4 HOT 3
- How to know if the mail was sent failed? HOT 1
- Table name and DB Configurable
- Release version in maven HOT 1
- Preventing send duplicate email if multiple servers instance are running
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from grails-asynchronous-mail.