I am new for this SMTP Server. I need to send a confirmation mail from
using JSP..but when i run the application i get these exceptions..can
anyone tell me whats the reason for these exceptions.
[java] javax.mail.SendFailedException: Sending failed;
[java] nested exception is:
[java] javax.mail.MessagingException: Could not connect to
SMTP host: l
ocalhost, port: 25;
[java] nested exception is:
[java] java.net.ConnectException: Connection refused: connect
[java] at javax.mail.Transport.send0(Transport.java:219)
[java] at javax.mail.Transport.send(Transport.java:81)
[java] at com.sun.ebxml.soapmsh.SMTPConnection.send(SMTPConnection.java
:157)
[java] at org.apache.soap.messaging.Message.send(Message.java:123)
[java] at com.sun.ebxml.soapmsh.SOAPMessageImpl.send(SOAPMessageImpl.ja
va:331)
[java] at com.laura.customers.mbis.send(mbis.java:196)
[java] at com.laura.customers.mbis.confirmOrder(mbis.java:165)
[java] at actions._0002factions_0002fconfirm_0005fsend_0002ejspconfirm_
0005fsend_jsp_0._jspService(_0002factions_0002fconfirm_0005fsend_0002ejspconfirm
_0005fsend_jsp_0.java:192)
[java] at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.jav
a:119)
[java] at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
[java] at org.apache.jasper.servlet.JspServlet$JspServletWrapper.servic
e(JspServlet.java:177)
[java] at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServle
t.java:318)
[java] at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:
391)
[java] at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
[java] at org.apache.tomcat.core.ServletWrapper.doService(ServletWrappe
r.java:404)
[java] at org.apache.tomcat.core.Handler.service(Handler.java:286)
[java] at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.
java:372)
[java] at org.apache.tomcat.core.ContextManager.internalService(Context
Manager.java:797)
[java] at org.apache.tomcat.core.ContextManager.service(ContextManager.
java:743)
[java] at org.apache.tomcat.service.http.HttpConnectionHandler.processC
onnection(HttpConnectionHandler.java:210)
[java] at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoi
nt.java:416)
[java] at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadP
ool.java:498)
[java] at java.lang.Thread.run(Thread.java:534)
[java] SOAPMessageImpl ERROR: Sending failed;
[java] nested exception is:
[java] javax.mail.MessagingException: Could not connect to
SMTP host: l
ocalhost, port: 25;
[java] nested exception is:
[java] java.net.ConnectException: Connection refused: connect
[java] Exception is: [SOAPException:
faultCode=SOAP-ENV:Client; msg=Se
nding failed;
[java] nested exception is:
[java] javax.mail.MessagingException: Could not connect to
SMTP host: l
ocalhost, port: 25;
[java] nested exception is:
[java] java.net.ConnectException: Connection refused:
connect; targetEx
ception=javax.mail.SendFailedException: Sending failed;
[java] nested exception is:
[java] javax.mail.MessagingException: Could not connect to
SMTP host: l
ocalhost, port: 25;
[java] nested exception is:
[java] java.net.ConnectException: Connection refused:
connect]
[java] at com.sun.ebxml.soapmsh.SMTPConnection.send(SMTPConnection.java
:160)
[java] at org.apache.soap.messaging.Message.send(Message.java:123)
[java] at com.sun.ebxml.soapmsh.SOAPMessageImpl.send(SOAPMessageImpl.ja
va:331)
[java] at com.laura.customers.mbis.send(mbis.java:196)
[java] at com.laura.customers.mbis.confirmOrder(mbis.java:165)
[java] at actions._0002factions_0002fconfirm_0005fsend_0002ejspconfirm_
0005fsend_jsp_0._jspService(_0002factions_0002fconfirm_0005fsend_0002ejspconfirm
_0005fsend_jsp_0.java:192)
[java] at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.jav
a:119)
[java] at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
[java] at org.apache.jasper.servlet.JspServlet$JspServletWrapper.servic
e(JspServlet.java:177)
[java] at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServle
t.java:318)
[java] at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:
391)
[java] at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
[java] at org.apache.tomcat.core.ServletWrapper.doService(ServletWrappe
r.java:404)
[java] at org.apache.tomcat.core.Handler.service(Handler.java:286)
[java] at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.
java:372)
[java] at org.apache.tomcat.core.ContextManager.internalService(Context
Manager.java:797)
[java] at org.apache.tomcat.core.ContextManager.service(ContextManager.
java:743)
[java] at org.apache.tomcat.service.http.HttpConnectionHandler.processC
onnection(HttpConnectionHandler.java:210)
[java] at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoi
nt.java:416)
[java] at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadP
ool.java:498)
[java] at java.lang.Thread.run(Thread.java:534)
My Java file for com.laura.customers.mbis.send and
com.laura.customers.mbis.confirmorder is as follows:
public SOAPMessageImpl confirmOrder(SOAPMessageImpl request,
byte[] payload)
throws SOAPException {
if (state != mbis.ORDERMESSAGE_RECD)
throw new SOAPException(org.apache.soap.Constants.FAULT_CODE_CLIENT,
"Choreography error: ");
String service = ORDERSERVICE;
String action = CONFIRMACTION;
String refmsgid = request.getProperty(com.sun.ebxml.soapmsh.Constants.MSGID);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
StreamResult res = new StreamResult(baos);
Hashtable params = new Hashtable();
params.put("ConversationId", request.getProperty("convid"));
try {
transform(new ByteArrayInputStream(payload), res, confXsl, params);
}
catch (TransformerException x) {
x.printStackTrace(System.err);
throw new SOAPException(org.apache.soap.Constants.FAULT_CODE_CLIENT,
"unable to transform confirmation!");
}
SOAPMessageImpl msg = send(service, action, refmsgid,
"confirm.xml", payload, "confirm.html", baos.toByteArray());
setState(mbis.SUCCESS);
return msg;
}
protected SOAPMessageImpl send(String service,
String action, String refmsgid, String loc, byte[]
payload,
String loc2, byte[] payload2)
throws SOAPException {
try {
byte [] payloadBytes = Utils.prettyPrint(payload);
InternetHeaders hdrs = new InternetHeaders();
hdrs.addHeader("Content-Type", "application/xml");
hdrs.addHeader("Content-Location", loc);
String _cid = MimeUtils.getUniqueValue();
String cid = '<' + _cid + '>';
hdrs.addHeader("Content-ID", cid);
MimeBodyPart payloadPart = new MimeBodyPart(hdrs,
payloadBytes);
SOAPMessageImpl msg = createMessage(service, action,
refmsgid, _cid);
msg.addBodyPart(payloadPart);
InternetHeaders hdrs2 = new InternetHeaders();
hdrs2.addHeader("Content-Type", "text/html");
hdrs2.addHeader("Content-Location", loc2);
String cid2 = '<' + MimeUtils.getUniqueValue() + '>';
hdrs2.addHeader("Content-ID", cid2);
payloadPart = new MimeBodyPart(hdrs2, payload2);
msg.addBodyPart(payloadPart);
msg.send();
return msg;
}
catch (Exception x) {
x.printStackTrace();
throw new
SOAPException(org.apache.soap.Constants.FAULT_CODE_CLIENT,
x.getMessage(), x);
}
}
I am waiting for a hint to locate my error. Thanx in advance.
regads,
Jagdeesh
>
> Hi everyone,
>
> I am new for this SMTP Server. I need to send a confirmation mail
> from using JSP..but when i run the application i get these
> exceptions..can anyone tell me whats the reason for these
> exceptions.
Javamail requires you to define an SMTP host as part of its properties.
Absent this, it assumes that the localhost has an SMTP server running.
In this case you do not (3rd line down). So you need the address of an
SMTP server and tell Javamail of it, or you need to run one on your
localhost (a risky endeavor and not to done without absolute surity you
are not creating an open relay for spammers to exploit).
See the the package documentation for the Javamail API for further
information on the properties.
Gary
Are you sure you have a correctly installed, configured, running, mail
agent (like sendmail) on localhost, if this is the host you want to
use to send the mail ?
--
Olivier
This space for sale.
The exception tells you everything you need to know. The application
is trying to connect to the SMTP daemon at the "well-known port" (25)
on the localhost. You apparently don't have the daemon running.
Without additional configuration information (O/S, program launcher,
etc.) then it's not possible to tell you how to proceed.
: Hi everyone,
: I am new for this SMTP Server.
[...]
: regads,
: Jagdeesh
This post shows signs of being sent from my Google Groups account.
It may be a mix up by Google - or I may need to change my password.
--
__________
|im |yler http://timtyler.org/ t...@tt1.org
I'm curious to know what signs you mean, since I can't see that he
claims to be Tim Tyler. AFAICT, yours is the only post in this thread
that appears (to me anyway) to come from you.
The post you've replied to has these headers:
From: jagg...@yahoo.com (Jagdeesh)
Newsgroups: comp.lang.java.programmer
Subject: Problem in sending mails through SMTP
Date: 8 Aug 2003 03:55:32 -0700
Organization: http://groups.google.com/
Lines: 189
Message-ID: <96e27709.03080...@posting.google.com>
NNTP-Posting-Host: 141.44.242.67
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
X-Trace: posting.google.com 1060340133 25653 127.0.0.1 (8 Aug 2003 10:55:33 GMT)
X-Complaints-To: groups...@google.com
NNTP-Posting-Date: 8 Aug 2003 10:55:33 GMT
Except for the NNTP-Posting-Host (is it your IP?), most of these are
pretty generic.
/gordon
--
[ do not send me private copies of your followups ]
g o r d o n . b e a t o n @ e r i c s s o n . c o m
>SMTP host: l
>ocalhost, port: 25;
I suggest firing up Eudora or some similar mail program and see if
you can send mail to your local host mailserver.
I suspect you don't have a localHost mail server. Instead you have to
configure JavaMail to use your ISP mail server, likely with
login/password. Get it working with Eudora, and then note the eudora
settings that work.
--
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.