-
Dec 16th, 2008, 11:48 AM
#1
Email Sending with Maven Does not work
Hi There,
I have selected spring batch as the platform to do batch processing. I have created a project with different ItemReaders, writers and tasklets. It reads, flat files, applies business logic and writes it to back end DB. It also sends a summary email message to admins. I have been using eclipse to develop these modules and stuff was working fine. But as in production environment, I would be using maven to run these modules at command line, when I try to run it using maven, every thing works except sending email part. I get following error message: 
Encountered an error executing the step: class java.lang.IllegalStateException: Not connected
java.lang.IllegalStateException: Not connected
at com.sun.mail.smtp.SMTPTransport.checkConnected(SMT PTransport.java:1664)
at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTr ansport.java:590)
at javax.mail.Transport.send(Transport.java:80)
at javax.mail.Transport.send(Transport.java:46)
at com.compsych.batch.util.EmailNotifier.notify(Email Notifier.java:60)
Code in Email Notifier:
Properties mailProps = new Properties();
Session session;
InternetAddress sender = new InternetAddress(senderEmail,senderName);
InternetAddress recipient;
InternetAddress[] recipients = InternetAddress.parse(recipientEmail);
mailProps.put("mail.smtp.host", mailServer);
mailProps.put("mail.debug", "true");
mailProps.put("mail.socket", "25");
session = Session.getInstance(mailProps, null);
session.setDebug(true);
MimeMessage email = new MimeMessage(session);
email.setFrom(sender);
email.setSubject(subject);
email.setContent(message,content_type);
for(int i=0; i<recipients.length; i++) {
recipient = recipients[i];
email.addRecipients(Message.RecipientType.TO, recipient.toString());
}
Transport.send(email);
I tried spending quite a lot of time on this one but no luck. I tried setting classpaths, I tried setting dependencies in POM.xml but nothing seems to resolve it. Any help would be greatly appreciated as I am the one who is promoting spring batch in my organization and I am really hoping this issue is resolved ASAP with the collaboration of community members here.
Thanks
Sanjay
Last edited by sanjaygarje; Dec 16th, 2008 at 11:49 AM.
Reason: Missed some code
-
Dec 18th, 2008, 06:03 AM
#2
This looks like a simple configuration problem with your mail server (nothing to do with Spring Batch, or Spring at all I would guess). Can you try posting in a more general forum, or something more specific, but not Spring related?
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules