Announcement Announcement Module
No announcement yet.
Email Sending with Maven Does not work Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTr
    at javax.mail.Transport.send(
    at javax.mail.Transport.send(
    at com.compsych.batch.util.EmailNotifier.notify(Email

    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("", mailServer);
    mailProps.put("mail.debug", "true");
    mailProps.put("mail.socket", "25");

    session = Session.getInstance(mailProps, null);
    MimeMessage email = new MimeMessage(session);

    for(int i=0; i<recipients.length; i++) {
    recipient = recipients[i];
    email.addRecipients(Message.RecipientType.TO, recipient.toString());

    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.

    Last edited by sanjaygarje; Dec 16th, 2008, 11:49 AM. Reason: Missed some code

  • #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?