Hi guys,
I have an error when trying to send an email from inside a job.
The error I get is :
2015-11-19 11:09:16,507 ERROR o.x.m.i.DatabaseMailListener - Failed to save mail status
[messageId = [04e467fb-0982-475b-9e8d-e3b1cc58c3a1], batchId =
[9e5aa5f2-2372-40c9-b4c0-f6c5b7579560], state = [ready], date = [Thu Nov 19 11:09:16 CET
2015], recipients = [p.huisman(a)ximml.nl], wiki = [testwiki]] to the database
org.xwiki.mail.MailStoreException: Failed to save mail status [messageId =
[04e467fb-0982-475b-9e8d-e3b1cc58c3a1], batchId = [9e5aa5f2-2372-40c9-b4c0-f6c5b7579560],
state = [ready], date = [Thu Nov 19 11:09:16 CET 2015], recipients = [p.huisman(a)ximm.nl],
wiki = [testwiki]] to the database.
at org.xwiki.mail.internal.DatabaseMailStatusStore.save(DatabaseMailStatusStore.java:88)
~[xwiki-platform-mail-send-storage-6.4.4.jar:na]
at org.xwiki.mail.internal.DatabaseMailListener.saveStatus(DatabaseMailListener.java:151)
[xwiki-platform-mail-send-storage-6.4.4.jar:na]
at org.xwiki.mail.internal.DatabaseMailListener.onPrepare(DatabaseMailListener.java:82)
[xwiki-platform-mail-send-storage-6.4.4.jar:na]
at
org.xwiki.mail.internal.thread.PrepareMailRunnable.prepareSingleMail(PrepareMailRunnable.java:162)
[xwiki-platform-mail-send-default-6.4.4.jar:na]
at
org.xwiki.mail.internal.thread.PrepareMailRunnable.prepareMail(PrepareMailRunnable.java:133)
[xwiki-platform-mail-send-default-6.4.4.jar:na]
at org.xwiki.mail.internal.thread.PrepareMailRunnable.run(PrepareMailRunnable.java:94)
[xwiki-platform-mail-send-default-6.4.4.jar:na]
at java.lang.Thread.run(Thread.java:745) [na:1.7.0_79]
Caused by: org.xwiki.mail.MailStoreException: Failed to delete mail status (message id
[04e467fb-0982-475b-9e8d-e3b1cc58c3a1]) from the database.
at
org.xwiki.mail.internal.DatabaseMailStatusStore.delete(DatabaseMailStatusStore.java:194)
~[xwiki-platform-mail-send-storage-6.4.4.jar:na]
at org.xwiki.mail.internal.DatabaseMailStatusStore.save(DatabaseMailStatusStore.java:76)
~[xwiki-platform-mail-send-storage-6.4.4.jar:na]
... 6 common frames omitted
Caused by: com.xpn.xwiki.XWikiException: Error number 0 in 3: Exception while hibernate
execute
at com.xpn.xwiki.store.XWikiHibernateBaseStore.execute(XWikiHibernateBaseStore.java:1305)
~[xwiki-platform-legacy-oldcore-6.4.4.jar:na]
at
com.xpn.xwiki.store.XWikiHibernateBaseStore.executeWrite(XWikiHibernateBaseStore.java:1413)
~[xwiki-platform-legacy-oldcore-6.4.4.jar:na]
at
org.xwiki.mail.internal.DatabaseMailStatusStore.delete(DatabaseMailStatusStore.java:182)
~[xwiki-platform-mail-send-storage-6.4.4.jar:na]
... 7 common frames omitted
Caused by: org.hibernate.QueryParameterException: could not locate named parameter [id]
at
org.hibernate.engine.query.ParameterMetadata.getNamedParameterDescriptor(ParameterMetadata.java:101)
~[hibernate-core-3.6.9.Final.jar:3.6.9.Final]
at
org.hibernate.engine.query.ParameterMetadata.getNamedParameterExpectedType(ParameterMetadata.java:107)
~[hibernate-core-3.6.9.Final.jar:3.6.9.Final]
at org.hibernate.impl.AbstractQueryImpl.determineType(AbstractQueryImpl.java:460)
~[hibernate-core-3.6.9.Final.jar:3.6.9.Final]
at org.hibernate.impl.AbstractQueryImpl.setParameter(AbstractQueryImpl.java:430)
~[hibernate-core-3.6.9.Final.jar:3.6.9.Final]
at
org.xwiki.mail.internal.DatabaseMailStatusStore$4.doInHibernate(DatabaseMailStatusStore.java:189)
~[xwiki-platform-mail-send-storage-6.4.4.jar:na]
at com.xpn.xwiki.store.XWikiHibernateBaseStore.execute(XWikiHibernateBaseStore.java:1299)
~[xwiki-platform-legacy-oldcore-6.4.4.jar:na]
... 9 common frames omitted
The code I use is base on the example on
http://extensions.xwiki.org/xwiki/bin/view/Extension/Mail+Sender+API#HCompa…
<http://extensions.xwiki.org/xwiki/bin/view/Extension/Mail+Sender+API#HCompatibilitywiththeMailSenderPlugin>
:
I Inject the following:
@Inject
MailSenderConfiguration mailConfiguration;
@Inject
@Named("text/html")
MimeBodyPartFactory<String> htmlPartFactory;
@Inject
@Named("database")
private Provider<MailListener> mailListenerProvider;
@Inject
MailSender mailSender;
The calls are:
[…]
MailListener maillistener = this.mailListenerProvider.get();
Session session = Session.getInstance(this.mailConfiguration.getAllProperties());
MimeMessage message = new MimeMessage(session);
message.setFrom(new InternetAddress("p.huisman(a)ximm.nl"))nl"));
message.addRecipient(RecipientType.TO, new
InternetAddress("p.huisman(a)ximm.nl"))nl"));
message.setSubject("XML Export");
Multipart multipart = new MimeMultipart("mixed");
Map<String, Object> parameters = new HashMap<>();
parameters.put("alternative", "text");
multipart.addBodyPart(this.htmlPartFactory.create(resultaat, parameters));
message.setContent(multipart);
MailResult result = this.mailSender.sendAsynchronously(Arrays.asList(message), session,
maillistener);
[…]
The error is created on the this.mailSender.sendAsynchronously call. I’m using the 6.4.4
version.
Any help and suggestions of what I’m doing wrong is appreciated.
With kind regards,
Peter