Re: SendMailServlet example & server setup ?




"Chris Smith" <cdsmith@xxxxxxx> je napisao u poruci interesnoj
grupi:MPG.1f0705c462b866a19896f3@xxxxxxxxxxxxxxxxxxx
Dado <mario_zupan@xxxxxxx> wrote:
public void init(ServletConfig config) throws ServletException
{
super.init(config);

// get the SMTP server from the servlet properties
smtpServer = config.getInitParameter("smtpServer");
}

[...]

// set the SMTP host property value
Properties properties = System.getProperties();
properties.put("smtp.mail.yahoo.com", smtpServer);

[...]

java.lang.NullPointerException
java.util.Hashtable.put(Hashtable.java:396)
SendMailServlet.doPost(SendMailServlet.java:40)
javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:362)

The problem is that you need a mail server that can send the mail. You
are supposed to have found one, and configured the context init param
called smtpServer with the address of that mail server. You haven't
done so, and therefore smtpServer remains null, which generates the
error above when you try to add it to a list of properties to send mail.

The solution is to add this parameter to web.xml (or some web container
config file, such as Tomcat's server.xml).

--
Chris Smith - Lead Software Developer / Technical Trainer
MindIQ Corporation


I put:
<Resource name="mail/Session" auth="Container"
type="javax.mail.Session" mail.smtp.host="mail.iskon.hr" />
inside
</Host>
</Engine>
tags

as I find on Net and restart Tomcat. Then I noticed that tomcat log gives
me:


2006.06.24 12:45:10 org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextInitialized()
2006.06.24 12:45:10 org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextInitialized()
2006.06.24 12:46:11 org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: sessionDestroyed('57DDD22BA86E9B5929E4F9B6FC11343E')
2006.06.24 13:45:54 org.apache.catalina.core.ApplicationContext log
SEVERE: StandardWrapper.Throwable
java.lang.NullPointerException
at java.util.Hashtable.put(Hashtable.java:396)
at SendMailServlet.init(SendMailServlet.java:25)
at
org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1091)
at
org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:750)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:130
....
line 25 is
super.init(config);

in SendMailServlet.

What I'm doing wrong ?


.



Relevant Pages

  • Re: SendMailServlet example & server setup ?
    ... The problem is that you need a mail server that can send the mail. ... called smtpServer with the address of that mail server. ... config file, such as Tomcat's server.xml). ...
    (comp.lang.java.help)
  • Re: What doesnt lend itself to OO?
    ... > system design within that context seriously). ... >>The first line exists in the server. ... > objects between client and server i.e. as far as the client code is ... the message data packet data in the server between requests, ...
    (comp.object)
  • Re: Outlook wont send large attachments
    ... the one operating your own personal mail server. ... header to the e-mail client while they interrogate the message but that only ... the timeout due to excessive delay. ...
    (microsoft.public.outlook)
  • RE: No delivery report 4.4.7
    ... mail.rabarberlandet.dk is a mail server host on our ISP. ... Please let me know where the mail.rabarberlandet.dk host on. ... Microsoft CSS Online Newsgroup Support ...
    (microsoft.public.windows.server.sbs)
  • Re: SBS 2003 Standard IIS Issue
    ... and grant permission to the ASP.NET account on your video server? ... Theoretically it all works as long as I use the URL Forward in IIS, ... exception occurred during the execution of the current web request. ... Context context) +98 ...
    (microsoft.public.windows.server.sbs)