如果战争不存在,则取消部署jboss cli会失败

时间:2018-03-01 16:11:54

标签: maven deployment jboss command-line-interface

我正在尝试取消部署并使用jboss-as-maven-plugin将war文件部署到jboss EAP 6,并在我的项目pom.xm中提到了以下行。如果WAR尚未部署并且在jboss中可用,则Undeploy cli步骤将失败。如果WAR不存在,我希望跳过此步骤,并在后续步骤中继续进行新部署。有什么想法解决这个问题吗?

`[ERROR] Failed to execute goal org.jboss.as.plugins:jboss-as-maven-plugin:7.9.Final:execute-commands (unassign-war) on project chexreseller: Execution unassign-war of goal org.jboss.as.plugins:jboss-as-maven-plugin:7.9.Final:execute-commands failed: Operation failed: {"domain-failure-description" => {"JBAS014653: Composite operation failed and was rolled back. Steps that failed:" => {"Operation step-1" => {"JBAS014653: Composite operation failed and was rolled back. Steps that failed:" => {"Operation step-1" => "JBAS014807: Management resource '[
[ERROR]     (\"server-group\" => \"web-server-group\"),
[ERROR]     (\"deployment\" => \"xxx.war\")
[ERROR] ]' not found"}}}}}
[ERROR] -> [Help 1]`

<plugin>
		<groupId>org.jboss.as.plugins</groupId>
        <artifactId>jboss-as-maven-plugin</artifactId>
        <version>7.9.Final</version>
        <configuration>
			<timeout>60000</timeout>
			<username>${uname}</username>
            <password>${password}</password>
            <hostname>${hostname}</hostname> 
        </configuration>
        <executions>
				<execution>                      
					<id>upload-war</id>
					<phase>deploy</phase>
					<goals>
						<goal>deploy</goal>
                    </goals> 
                <configuration>
                    <deployEnabled>false</deployEnabled>
                    <force>true</force>
                        <domain>
                            <server-groups>
								<server-group>myservergrp</server-group>
                            </server-groups>
                        </domain>
                </configuration>
				</execution>	
				<execution>
					<id>unassign-war</id>
					<phase>deploy</phase>
					<goals>
						<goal>execute-commands</goal>
					</goals>
					<configuration>
						<executeCommands>
							<batch>true</batch>
								<commands>
									<command>undeploy xxx.war --server-groups=myservergrp</command>
									<command>undeploy yyy.war --server-groups=myservergrp</command> 
								</commands>
						</executeCommands>
					</configuration>
				</execution>
				<execution>
					<id>enable-this-war</id>
					<phase>deploy</phase>
					<goals>
						<goal>execute-commands</goal>
					</goals>
					<configuration>
						<executeCommands>
							<batch>true</batch>
								<commands>
									<command>deploy --name=xxx.war --server-groups=myservergrp</command>
									<command>deploy --name=yyy.war --server-groups=myservergrp</command>
								</commands>
						</executeCommands>
					</configuration>
				</execution>
            </executions>
        </plugin>

2 个答案:

答案 0 :(得分:0)

我自己没有尝试过,但是通过查看https://docs.jboss.org/jbossas/7/plugins/maven/latest/examples/complex-example.html中的maven插件文档,我认为你只是缺少一个额外的配置子元素,即:

<configuration>
    <ignoreMissingDeployment>true</ignoreMissingDeployment>
</configuration>

答案 1 :(得分:0)

我能够通过在我的pom.xml中仅添加以下行来解决这个问题,这些行将替换已部署的组件并在不存在的情况下部署新组件

            <executions>
            <execution>                      
                <id>upload-war</id>
                <phase>deploy</phase>
                <goals>
                    <goal>deploy</goal>
                </goals> 
            <configuration>
                <filename>xxx.war</filename>
                <deployEnabled>false</deployEnabled>
                <ignoreMissingDeployment>true</ignoreMissingDeployment>
                <force>true</force>
                    <domain>
                        <server-groups>
                            <server-group>web-server-group</server-group>
                        </server-groups>
                    </domain>
            </configuration>
            </execution>    
        </executions>

注意:如果您没有提及文件名标签,那么将采用默认项目名称进行部署