【问题标题】:Creating security domain using wildfly-maven-plugin has no effect使用 wildfly-maven-plugin 创建安全域无效
【发布时间】:2015-06-30 18:45:44
【问题描述】:

我发现this 在它的命令中使用了/subsystem,所以我用不同的子系统命令(我使用一个创建安全域)尝试了它,它构建成功,但在standalone.xml 中没有效果。

        <plugin>
            <groupId>org.wildfly.plugins</groupId>
            <artifactId>wildfly-maven-plugin</artifactId>
            <version>1.1.0.Alpha1</version>
            <configuration>
                <execute-commands>
                    <commands>
                        <command>/subsystem=security/security-domain=secureD:add(cache-type=default)</command>
                        <command>reload</command>
                        <command>/subsystem=security/security-domain=secureD/authentication=classic:add(login-modules=[{"code"=>"Database","flag"=>"required","module-options"=>[("dsJndiName"=>"java:jboss/datasources/MyDB"),("principalsQuery"=>"select password from Users where username=?"),("rolesQuery"=>"select role, 'Roles' from Users where username=?"),("hashAlgorithm"=>"SHA-256"),("hashEncoding"=>"hex"),("hashCharset"=>"UTF-8")]}])</command>
                        <command>reload</command>
                    </commands>
                </execute-commands>
            </configuration>
        </plugin>

当我在$ ./jboss-cli.sh --connect 中手动执行命令时,它可以工作并创建域。

我将 eclipse 与以下 运行配置一起使用:“目标:清理包 wildfly:deploy”“配置文件:本地”

<project ...
    ...
    <build>
        <plugins>
            <plugin>
                tried pasting code from above once here
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>local</id>
            <properties>
                ...
            </properties>
            <build>
                <plugins>
                    <plugin>
                            and once here 
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>

构建时出现以下错误:

...
[INFO] 
[INFO] --- wildfly-maven-plugin:1.0.1.Final:undeploy (undeploy) @ Project ---
Jul 03, 2015 3:50:36 PM org.xnio.Xnio <clinit>
INFO: XNIO version 3.2.0.Final
Jul 03, 2015 3:50:36 PM org.xnio.nio.NioXnio <clinit>
INFO: XNIO NIO Implementation Version 3.2.0.Final
Jul 03, 2015 3:50:36 PM org.jboss.remoting3.EndpointImpl <clinit>
INFO: JBoss Remoting version 4.0.0.Final
WARN: can't find jboss-cli.xml. Using default configuration values.
Jul 03, 2015 3:50:36 PM org.jboss.as.cli.impl.CommandContextImpl printLine
INFO: {"outcome" => "success"}
{"outcome" => "success"}
Jul 03, 2015 3:50:36 PM org.jboss.as.cli.impl.CommandContextImpl printLine
INFO: {
    "outcome" => "success",
    "response-headers" => {
        "operation-requires-reload" => true,
        "process-state" => "reload-required"
    }
}
{
    "outcome" => "success",
    "response-headers" => {
        "operation-requires-reload" => true,
        "process-state" => "reload-required"
    }
}
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.316 s
[INFO] Finished at: 2015-07-03T15:50:36+01:00
[INFO] Final Memory: 12M/165M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.wildfly.plugins:wildfly-maven-plugin:1.0.1.Final:undeploy (undeploy) on project Project: Could not execute goal undeploy on /home/username/workspace/Project/target/Project-0.0.1-SNAPSHOT.war. Reason: Command execution failed for command 'reload'. Unsupported ModelControllerClient implementation org.wildfly.plugin.cli.Commands$NonClosingModelControllerClient -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

如果我删除 reload 命令,我会得到:

...
WARN: can't find jboss-cli.xml. Using default configuration values.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.825 s
[INFO] Finished at: 2015-07-03T15:45:23+01:00
[INFO] Final Memory: 22M/214M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.wildfly.plugins:wildfly-maven-plugin:1.0.1.Final:deploy-artifact (deploy_jdbc_driver) on project Project: Could not execute goal deploy-artifact on /home/username/.m2/repository/mysql/mysql-connector-java/5.1.35/mysql-connector-java-5.1.35.jar. Reason: Command execution failed for command '/subsystem=security/security-domain=secureD:add(cache-type=default)'. {
[ERROR] "outcome" => "failed",
[ERROR] "failure-description" => "JBAS014803: Duplicate resource [
[ERROR] (\"subsystem\" => \"security\"),
[ERROR] (\"security-domain\" => \"secureD\")
[ERROR] ]",
[ERROR] "rolled-back" => true,
[ERROR] "response-headers" => {"process-state" => "reload-required"}
[ERROR] }
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

【问题讨论】:

  • 你在用mvn wildfly:execute-commands吗?
  • 我正在使用带有以下运行配置的 Eclipse:“目标:清理包 wildfly:deploy”“配置文件:本地”。编辑了我的第一篇文章。

标签: maven jboss pom.xml wildfly wildfly-8


【解决方案1】:

您需要添加wildfly:execute-commands 目标或更改您的配置以使用&lt;before-deployment/&gt;。后者可能是更好的解决方案,因为您必须使用执行来确保在部署之前执行命令。最后我也只会使用reload

<configuration>
    <before-deployment>
        <commands>
            <command>/subsystem=security/security-domain=secureD:add(cache-type=default)</command>
            <command>/subsystem=security/security-domain=secureD/authentication=classic:add(login-modules=[{"code"=>"Database","flag"=>"required","module-options"=>[("dsJndiName"=>"java:jboss/datasources/MyDB"),("principalsQuery"=>"select password from Users where username=?"),("rolesQuery"=>"select role, 'Roles' from Users where username=?"),("hashAlgorithm"=>"SHA-256"),("hashEncoding"=>"hex"),("hashCharset"=>"UTF-8")]}])</command>
            <command>reload</command>
        </commands>
    </before-deployment>
</configuration>

【讨论】:

  • 到目前为止,它的工作原理是,当我尝试使用 Maven 构建时,会创建一个域,但在构建过程中会出现这些错误:请参阅已编辑的第一篇文章。
  • 错误提示您已经添加了一个名为secureD 的安全域。这就像您只想运行一次或放置在 try/catch/finally 块或 if/else 块中的命令。见developer.jboss.org/docs/DOC-18731developer.jboss.org/wiki/If-elseControlFlow
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-08-28
  • 1970-01-01
相关资源
最近更新 更多