Results 1 to 4 of 4

Thread: Null session in JavaMailSenderImpl

  1. #1
    Join Date
    Oct 2005
    Location
    Miami, Fl
    Posts
    2

    Default Null session in JavaMailSenderImpl

    I have a problem using JavaMailSenderImpl. When i try to send an email from a standalone class (main or junit) i get a null pointer

    java.lang.NullPointerException
    at org.springframework.mail.javamail.JavaMailSenderIm pl.getTransport(JavaMailSenderImpl.java:412)

    at org.springframework.mail.javamail.JavaMailSenderIm pl.doSend(JavaMailSenderImpl.java:372)
    at org.springframework.mail.javamail.JavaMailSenderIm pl.send(JavaMailSenderImpl.java:291)
    at org.springframework.mail.javamail.JavaMailSenderIm pl.send(JavaMailSenderImpl.java:277)
    at com.todo1.bole2.services.base.notification.SendSin gleMailTest.testSendEmail(SendSingleMailTest.java: 25)


    but if i run a similar code under the app server (sun 7), it runs fine... it actually sends the email.

    The test sample is:

    public void testSendEmail() throws Exception {
    JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
    mailSender.setHost("mail.mycompany.com");
    //
    SimpleMailMessage mailmessagetext = new SimpleMailMessage();
    mailmessagetext.setTo("to@mycompany.com");
    mailmessagetext.setFrom("from@mycompany.com");
    mailmessagetext.setSubject("TEXT test");
    mailmessagetext.setText("Test text");
    mailSender.send(mailmessagetext);


    Any idea why this happens?

  2. #2
    Join Date
    Jul 2005
    Location
    Idaho
    Posts
    231

    Default

    Check your mapping. If your junit is coming from a different machine adding this:
    Code:
    <property name="javaMailProperties">
        <props>
          <prop key="mail.smtp.auth">true</prop>
       </props>
    </property>
    may help.

    Steve O

  3. #3
    Join Date
    Oct 2005
    Location
    Miami, Fl
    Posts
    2

    Default

    Actually the problem is not in Spring but JavaMail, for some reason this 2 calls in JavaMailSenderImpl always return null

    private Session session = Session.getInstance(new Properties());

    public void setJavaMailProperties(Properties javaMailProperties) {
    this.session = Session.getInstance(javaMailProperties);
    }

    I'm still researching why, i must be missing a property or something in the classpath. If you have any clue please let me know.

    Thanks

  4. #4

    Default Answer

    Hi there,

    Did you find the answer to the null problem?

Similar Threads

  1. Replies: 2
    Last Post: Oct 13th, 2005, 02:47 PM
  2. Replies: 4
    Last Post: Sep 27th, 2005, 11:31 PM
  3. Replies: 3
    Last Post: May 16th, 2005, 07:04 AM
  4. Strange Data Access Error
    By webifyit in forum Data
    Replies: 2
    Last Post: Dec 28th, 2004, 11:06 AM
  5. Replies: 8
    Last Post: Sep 23rd, 2004, 01:12 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •