Ai galera q está acontecendo de errado na minha aplicação
tenho a seguinte classe:
/**
* @ejb.interface-method
* @param sugestao
* @return
*/
public void salvar(Sugestao sugestao) {
if (log.isDebugEnabled()) {
log.debug("Sugestao.salvar()");
}
DAOFactory factory = (DAOFactory) DAOFactory
.getDAOFactory(DAOFactory.HIBERNATE);
SugestaoDAO dao = (SugestaoDAO) factory.getSugestaoDAO();
dao.salvar(sugestao);
String de = "robson_vs@yahoo.com.br";
String para = "robson_vs@yahoo.com.br";
String assunto = "Sugestão do Sistema FaleGreen";
String mensagem = sugestao.getSugestao().toString();
enviarEmail(de, para, assunto, mensagem);
}
/**
* @ejb.interface-method
* @return
*/
public void enviarEmail(String de, String para, String assunto,
String mensagem) {
if (log.isDebugEnabled()) {
log.debug("Sugestao.enviarEmail()");
}
final boolean debug = false;
Properties props = new Properties();
//props.put("mail.host", "smtp2.locaweb.com.br");
Session session = Session.getDefaultInstance(props, new SmtpAuthenticator());
session.setDebug(debug);
Message message = new MimeMessage(session);
try {
InternetAddress remetente = new InternetAddress(de);
message.setFrom(remetente);
InternetAddress destinatario = new InternetAddress(para);
message.setRecipient(Message.RecipientType.TO, destinatario);
message.setSentDate(new Date());
message.setSubject(assunto);
message.setText(mensagem);
message.setContent(mensagem.toString(), "text/plain");
Transport.send(message);
} catch (AddressException e) {
e.printStackTrace();
} catch (MessagingException e) {
e.printStackTrace();
}
}
private class SmtpAuthenticator extends Authenticator {
protected javax.mail.PasswordAuthentication getPasswordAuthentication() {
return new javax.mail.PasswordAuthentication(
"webmaster@app.greenlinesaude.com.br", "glemail10");
}
}
e o seguinte erro:
08:09:45,823 INFO [STDOUT] Hibernate: select departamen0_.id as id0_, departamen0_.nome_departamento as nome2_0_, departamen0_.fk_funcionario as fk3_0_ from departamentos departamen0_
08:09:46,286 INFO [STDOUT] Hibernate: select nextval ('departamentos_id_seq')
08:09:46,554 INFO [STDOUT] Hibernate: insert into sugestoes (fk_departamento, data, sugestao, identificacao, id) values (?, ?, ?, ?, ?)
08:10:13,744 ERROR [STDERR] javax.mail.SendFailedException: Sending failed;
nested exception is:
class javax.mail.MessagingException: Could not connect to SMTP host: localhost, port: 25;
nested exception is:
java.net.ConnectException: Connection refused
08:10:13,745 ERROR [STDERR] at javax.mail.Transport.send0(Transport.java:218)
08:10:13,745 ERROR [STDERR] at javax.mail.Transport.send(Transport.java:80)
08:10:13,745 ERROR [STDERR] at br.com.greenline.falegreen.ejb.SugestaoEJB.enviarEmail(SugestaoEJB.java:171)
08:10:13,745 ERROR [STDERR] at br.com.greenline.falegreen.ejb.SugestaoEJB.salvar(SugestaoEJB.java:118)
08:10:13,745 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
08:10:13,745 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
08:10:13,745 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
08:10:13,745 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:585)
08:10:13,746 ERROR [STDERR] at org.jboss.invocation.Invocation.performCall(Invocation.java:359)
08:10:13,746 ERROR [STDERR] at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:237)
08:10:13,746 ERROR [STDERR] at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:158)
08:10:13,747 ERROR [STDERR] at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:169)
08:10:13,747 ERROR [STDERR] at org.jboss.ws.server.ServiceEndpointInterceptor.invoke(ServiceEndpointInterceptor.java:64)
08:10:13,747 ERROR [STDERR] at org.jboss.ejb.plugins.CallValidationInterceptor.invoke(CallValidationInterceptor.java:63)
08:10:13,748 ERROR [STDERR] at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:121)
08:10:13,748 ERROR [STDERR] at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:350)
08:10:13,748 ERROR [STDERR] at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:181)
08:10:13,748 ERROR [STDERR] at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:168)
08:10:13,748 ERROR [STDERR] at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:205)
08:10:13,748 ERROR [STDERR] at org.jboss.ejb.plugins.CleanShutdownInterceptor.invoke(CleanShutdownInterceptor.java:278)
08:10:13,748 ERROR [STDERR] at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:136)
08:10:13,748 ERROR [STDERR] at org.jboss.ejb.SessionContainer.internalInvoke(SessionContainer.java:648)
08:10:13,748 ERROR [STDERR] at org.jboss.ejb.Container.invoke(Container.java:954)
08:10:13,748 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
08:10:13,748 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
08:10:13,748 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
08:10:13,748 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:585)
08:10:13,748 ERROR [STDERR] at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
08:10:13,748 ERROR [STDERR] at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
08:10:13,748 ERROR [STDERR] at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
08:10:13,748 ERROR [STDERR] at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
08:10:13,749 ERROR [STDERR] at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
08:10:13,749 ERROR [STDERR] at org.jboss.invocation.jrmp.server.JRMPInvokerHA.invoke(JRMPInvokerHA.java:177)
08:10:13,749 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
08:10:13,749 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
08:10:13,749 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
08:10:13,749 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:585)
08:10:13,749 ERROR [STDERR] at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:294)
08:10:13,749 ERROR [STDERR] at sun.rmi.transport.Transport$1.run(Transport.java:153)
08:10:13,749 ERROR [STDERR] at java.security.AccessController.doPrivileged(Native Method)
08:10:13,750 ERROR [STDERR] at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
08:10:13,750 ERROR [STDERR] at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
08:10:13,750 ERROR [STDERR] at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
08:10:13,750 ERROR [STDERR] at java.lang.Thread.run(Thread.java:595)