我正在将Wildfly 10.0.1.0中的应用程序移植到Wildly Swarm 2017.7.0。
除了使用YAML的SMTP电子邮件配置外,一切都进展顺利:
我尝试了一些替代方案,但这里是基于我认为yaml来自standalone.xml映射的最新版本 - project-defaults.yml
swarm:
socket-binding-groups:
mail-socket:
outbound-socket-bindings:
mail-smtp:
remote-host: smtp.someprovider.com
remote-port: 587
mail:
mail-sessions:
smtpSession:
jndi-name: java:/smtpSession
smtp-server:
username: username_here
password: password_here
tls: true
outbound-socket-binding-ref: mail-smtp
但是我仍然会收到错误:
2017-08-05 11:17:36,100 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("add") failed - address: ([
("subsystem" => "mail"),
("mail-session" => "smtpSession")
]) - failure description: {
"WFLYCTL0412: Required services that are not installed:" => ["jboss.outbound-socket-binding.mail-smtp"],
"WFLYCTL0180: Services with missing/unavailable dependencies" => ["jboss.mail-session.smtpSession is missing [jboss.outbound-socket-binding.mail-smtp]"]
}
2017-08-05 11:17:36,155 INFO [org.jboss.as.controller] (Controller Boot Thread) WFLYCTL0183: Service status report
WFLYCTL0184: New missing/unsatisfied dependencies:
service jboss.outbound-socket-binding.mail-smtp (missing) dependents: [service jboss.mail-session.smtpSession]
------------------ 2017年8月7日编辑-------------------
根据Ladicek的建议,我尝试了这个:
swarm:
socket-binding-groups:
standard-sockets:
mail-socket:
outbound-socket-bindings:
mail-smtp:
remote-host: smtp.someprovider.com
remote-port: 587
和
swarm:
socket-binding-groups:
standard-sockets:
outbound-socket-bindings:
mail-smtp:
remote-host: smtp.someprovider.com
remote-port: 587
和
swarm:
socket-binding-groups:
standard-socket:
outbound-socket-bindings:
mail-smtp:
remote-host: smtp.someprovider.com
remote-port: 587
然而两者都没有工作,仍然有同样的错误。
有人可以帮忙吗?
----------------------已解决------------------------ ----
需要升级到2017.8.1并使用以下配置
network:
socket-binding-groups:
standard-sockets:
outbound-socket-bindings:
mail-smtp:
remote-host: smtp.someprovider.com
remote-port: 587
谢谢。
答案 0 :(得分:0)
从我的头脑中,我相信你缺少一个YAML结构级别:你需要选择添加套接字绑定的套接字绑定组。这是WildFly的托管域的工件,这是一个不适用于Swarm的概念,但有时你遇到它。在独立的WildFly中只有一个套接字绑定组,因此在Swarm中只有standard-sockets
。
所以YAML看起来像:
swarm:
socket-binding-groups:
standard-sockets:
mail-socket:
...
对于有关Swarm YAML结构的任何问题,请咨询https://reference.wildfly-swarm.io
答案 1 :(得分:0)
终于解决了:
需要升级到2017.8.1并使用以下配置
network:
socket-binding-groups:
standard-sockets:
outbound-socket-bindings:
mail-smtp:
remote-host: smtp.someprovider.com
remote-port: 587
谢谢。
答案 2 :(得分:0)
estomefuncionóami :) espero les sirva
yml文件:
swarm:
mail:
mail-sessions:
mail-socket:
jndi-name: java:/mail/NGSoftMail
smtp-server:
username: sigafco@xxxmail.com.co
password: *****
outbound-socket-binding-ref: mail-smtp
debug: true
from: sigafco@xxxmail.com.co
network:
socket-binding-groups:
standard-sockets:
outbound-socket-bindings:
mail-smtp:
remote-host: xxxmail.com.co
remote-port: 25
java文件:
@ApplicationScoped
@Path("mailsender")
public class MailSender {
@Resource(mappedName = "java:/mail/NGSoftMail")
private Session session;
@GET
@Path("mail")
public String sendGet() throws Exception {
Message message = new MimeMessage(session);
message.setFrom();
message.setRecipients(Message.RecipientType.TO, InternetAddress.parse("david.vasquez@xxx.com.co", false));
message.setSubject("asunto!!!");
message.setSentDate(new Date());
message.setContent("contenido!!!", "text/html; charset=UTF-8");
Transport.send(message);
return String.format("{\"your_mail\": \"%s\"}", "OK");
}
}
pom文件:
<dependency>
<groupId>org.wildfly.swarm</groupId>
<artifactId>mail</artifactId>
</dependency>