【问题标题】:jboss-as-maven-plugin - add mail session resourcejboss-as-maven-plugin - 添加邮件会话资源
【发布时间】:2015-03-19 15:15:28
【问题描述】:

我正在尝试找到一种将邮件会话资源添加到我的 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]

所以我仍然必须添加“出站套接字绑定”并将该绑定链接到邮件会话。但我不知道如何做到这一点。

我已经尝试使用 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>

为了测试目的,我已经删除了数据源的添加资源执行。但似乎从未添加数据源。虽然如果我在命令中写错了我会得到一个异常......所以它被执行了。

【问题讨论】:

    标签: java maven jboss


    【解决方案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>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-04-26
      • 2012-03-03
      • 2012-10-09
      • 2016-05-11
      • 2012-11-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多