History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: APF-1016
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Minor Minor
Assignee: Matt Raible
Reporter: Tobias Vogel
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
AppFuse

NullPointerException in MailEngine

Created: 14/Feb/08 12:09 PM   Updated: 03/May/08 02:58 PM
Component/s: Service Layer
Affects Version/s: 2.0.1
Fix Version/s: 2.0.2

Environment: Windows XP SP2, Java(TM) SE Runtime Environment (build 1.6.0_03-b05), Microsoft Exchange 2003


 Description  « Hide
I edited my mail.properties (in core and web) to use our internal Exchange server to send mails. During the build process a test mail gets sent (password hint), resulting in a NullPointerException. This exception is not caused by wrong settings, as my mail actually gets delivered.

The strange thing is, the "mailSender" later on seems to anyhow throw an exception (though having successfully delivered the mail), which breaks the exception logging code in MailSender. The reason should be, that there's no cause in the exception, leading to brak the following code in MailSender:

> log.error(ex.getCause().getMessage());

The relevant part of the stacktrace:

[INFO] [talledLocalContainer] SCHWERWIEGEND: Servlet.service() for servlet dispatcher threw exception
[INFO] [talledLocalContainer] java.lang.NullPointerException[INFO] [talledLocalContainer] at org.appfuse.service.MailEngine.send(MailEngine.java:77)
[INFO] [talledLocalContainer] at org.appfuse.webapp.controller.PasswordHintController.handleRequest(PasswordHintController.java:84)
[INFO] [talledLocalContainer] at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
[INFO] [talledLocalContainer] at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:874)
[INFO] [talledLocalContainer] at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:808)
[INFO] [talledLocalContainer] at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:476)
[INFO] [talledLocalContainer] at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:431)
...

 All   Comments   Change History   FishEye      Sort Order:
Matt Raible - 14/Feb/08 12:30 PM
Can you change:

log.error(ex.getCause().getMessage());

to:

ex.printStackTrace();

And report the output?

Thanks,

Matt

Tobias Vogel - 15/Feb/08 05:46 AM
Okay, I tried it out (with tag 2.0.1 from svn).

The problem was inside the web-test, as it tries to send to 'signup-user@raibledesigns.com', while mail-server denies to relay to foreign domains for my development (and any other unknown) host. This initial cause triggered the NullPointerException in MailEngine to show up, as ex.getCause() is null in this case.

Here's the relevant part of the stacktrace:

[INFO] [talledLocalContainer] org.springframework.mail.MailSendException; nested exception details (1) are:
[INFO] [talledLocalContainer] Failed message 1:
[INFO] [talledLocalContainer] javax.mail.SendFailedException: Invalid Addresses;
[INFO] [talledLocalContainer] nested exception is:
[INFO] [talledLocalContainer] com.sun.mail.smtp.SMTPAddressFailedException: 550 5.7.1 Unable to relay for signup-user@raibledesigns.com
[INFO] [talledLocalContainer]
[INFO] [talledLocalContainer] at com.sun.mail.smtp.SMTPTransport.rcptTo(SMTPTransport.java:1196)
[INFO] [talledLocalContainer] at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:584)
[INFO] [talledLocalContainer] at org.springframework.mail.javamail.JavaMailSenderImpl.doSend(JavaMailSenderImpl.java:403)
[INFO] [talledLocalContainer] at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:308)
[INFO] [talledLocalContainer] at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:297)
[INFO] [talledLocalContainer] at org.appfuse.service.MailEngine.send(MailEngine.java:74)
[INFO] [talledLocalContainer] at org.appfuse.service.MailEngine.sendMessage(MailEngine.java:64)
[INFO] [talledLocalContainer] at org.appfuse.webapp.controller.BaseFormController.sendUserMessage(BaseFormController.java:193)
...

As with my modification the Exception now doesn't break the code in MailEngine, an additional NullPointerException now pops up in SignupController on line 87, with exactly the same cause:

> saveError(request, me.getCause().getLocalizedMessage());

The relevant part of this problem's stacktrace:

[INFO] [talledLocalContainer] SCHWERWIEGEND: Servlet.service() for servlet default threw exception
[INFO] [talledLocalContainer] java.lang.NullPointerException
[INFO] [talledLocalContainer] at org.appfuse.webapp.controller.SignupController.onSubmit(SignupController.java:87)
[INFO] [talledLocalContainer] at org.springframework.web.servlet.mvc.SimpleFormController.processFormSubmission(SimpleFormController.java:267)
[INFO] [talledLocalContainer] at org.appfuse.webapp.controller.BaseFormController.processFormSubmission(BaseFormController.java:150)
[INFO] [talledLocalContainer] at org.springframework.web.servlet.mvc.AbstractFormController.handleRequestInternal(AbstractFormController.java:265)
...

Tobias Vogel - 15/Feb/08 05:52 AM
Note: The first stacktrace is the output of ex.printStackTrace()

Matt Raible - 22/Feb/08 12:40 PM
If you change the following line:

saveError(request, me.getCause().getLocalizedMessage());

To:

saveError(request, me.getCause().getMessage());

Does it solve the NPE?

Tobias Vogel - 25/Feb/08 04:26 AM
I'm sorry, I can't get the web module with the SignupController to install correctly (from a vanilla 2.0.1-tag checkout from svn), as tests are failing.

I can anyhow back up, that it will not solve the NPE. The call stack looks like this:
- SignupController.onSubmit(...)
    - SignupController.sendUserMessage(...)
        - MailEngine.sendMessage(...) [throws MailException]

The cause of the MailException in MailEngine is NULL (verified it and wrote it to the console). After the exception has been logged in MailEngine, it gets thrown again (MailEngine:78) and therefore bubbles up to the SignupController, where the cause still will be NULL as it's the exact same object. Thus the NPE will occur for the second time.