我试图找到一种方法将邮件会话资源添加到我的jboss-as-maven-plugin但是我并没有真正取得很大进展..任何人都有一些教程或其他东西?我找不到任何......
这是完整的插件:
<plugin>
<groupId>org.jboss.as.plugins</groupId>
<artifactId>jboss-as-maven-plugin</artifactId>
<version>7.6.Final</version>
<executions>
<execution>
<id>start-server</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start</goal>
</goals>
</execution>
<execution>
<id>add-datasource</id>
<phase>pre-integration-test</phase>
<goals>
<goal>add-resource</goal>
</goals>
<configuration>
<address>subsystem=datasources,data-source=java:jboss/datasources/eCadWSDS</address>
<resource>
<enable-resource>true</enable-resource>
<properties>
<jndi-name>java:jboss/datasources/eCadWSDS</jndi-name>
<enabled>true</enabled>
<connection-url>jdbc:h2:mem:test;DB_CLOSE_DELAY=-1</connection-url>
<driver-class>org.h2.Driver</driver-class>
<driver-name>h2</driver-name>
</properties>
</resource>
</configuration>
</execution>
<execution>
<id>add-mail-session</id>
<phase>pre-integration-test</phase>
<goals>
<goal>add-resource</goal>
</goals>
<configuration>
<address>subsystem=mail-session, mail-session=java:jboss/mail/eCad</address>
<resource>
<enable-resource>true</enable-resource>
<properties>
<jndi-name>java:jboss/mail/eCad</jndi-name>
<enabled>true</enabled>
<socket-binding>mail-smtp</socket-binding>
</properties>
</resource>
</configuration>
</execution>
<execution>
<id>deploy-to-server</id>
<phase>pre-integration-test</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
</plugin>
这是我想在此插件中配置的内容:
<subsystem xmlns="urn:jboss:domain:mail:1.0">
<mail-session jndi-name="java:jboss/mail/eCad">
<smtp-server outbound-socket-binding-ref="mail-smtp"/>
</mail-session>
</subsystem>
<outbound-socket-binding name="mail-smtp">
<remote-destination host="filenetsupport" port="25"/>
</outbound-socket-binding>
我得到了例外:
[ERROR] Failed to execute goal org.jboss.as.plugins:jboss-as-maven-plugin:7.6.Final:add-resource (add-mail-session) on project ecad-application-ws-ear: Could not execute goal add-resource. Reason: Operation failed: "JBAS014739: No handler for read-resource at address [(\"subsystem\" => \"mail-session\")]" -> [Help 1]
所以我必须添加&#34; outbound-socket-binding&#34;并链接到邮件会话..但我不知道如何做到这一点。
我尝试使用CLI命令添加邮件会话,因为我知道如何做到这一点。但我开始尝试先添加数据源。所以我添加了以下执行:
<execution>
<id>execute-commands</id>
<phase>pre-integration-test</phase>
<goals>
<goal>execute-commands</goal>
</goals>
<configuration>
<execute-commands>
<commands>
<command>/subsystem=datasources/data-source="java:jboss/datasources/eCadWSDS":add(jndi-name="java:jboss/datasources/eCadWSDS", driver-name="h2", connection-url="jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1")</command>
</commands>
</execute-commands>
</configuration>
</execution>
我已经删除了数据源的add-resource执行,仅用于测试目的。但似乎从未添加数据源。虽然如果我在命令中写错了,我会得到异常......所以它被执行了。
答案 0 :(得分:1)
您的配置略有偏差。子系统名称为mail
而不是mail-session
,地址中不需要空格。
此外,没有enable
属性。请尝试以下方法:
<configuration>
<address>subsystem=mail,mail-session=java:jboss/mail/eCad</address>
<resource>
<properties>
<jndi-name>java:jboss/mail/eCad</jndi-name>
<socket-binding>mail-smtp</socket-binding>
</properties>
</resource>
</configuration>