3

我目前正在尝试使用 cargo 通过 atlassian 的竹子在远程 glassfish 3.1.2 上部署应用程序。这是一个开发环境,因此具有不同版本号的相同应用程序每次都将部署在相同的上下文根上。

但是每次我以 Maven 目标执行工作时:

org.codehaus.cargo:cargo-maven2-plugin:redeploy

我不断收到错误:

11-Jun-2013 15:13:48    Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default-cli of goal org.codehaus.cargo:cargo-maven2-plugin:1.4.2:redeploy failed: Deployment has failed: Action failed Deploying application to target server failed; Error occurred during deployment: Application with name myapp-1.4.8 is already registered. Either specify that redeployment must be forced, or redeploy the application. Or if this is a new deployment, pick a different name. Please see server.log for more details.
11-Jun-2013 15:13:48    
11-Jun-2013 15:13:48            at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:110)
11-Jun-2013 15:13:48            at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
11-Jun-2013 15:13:48            ... 19 more
11-Jun-2013 15:13:48    Caused by: org.codehaus.cargo.util.CargoException: Deployment has failed: Action failed Deploying application to target server failed; Error occurred during deployment: Application with name myapp-1.4.8 is already registered. Either specify that redeployment must be forced, or redeploy the application. Or if this is a new deployment, pick a different name. Please see server.log for more details.
11-Jun-2013 15:13:48    
11-Jun-2013 15:13:48            at org.codehaus.cargo.container.spi.deployer.AbstractJsr88Deployer.waitForProgressObject(AbstractJsr88Deployer.java:285)
11-Jun-2013 15:13:48            at org.codehaus.cargo.container.spi.deployer.AbstractJsr88Deployer.deploy(AbstractJsr88Deployer.java:123)
11-Jun-2013 15:13:48            at org.codehaus.cargo.container.spi.deployer.AbstractJsr88Deployer.redeploy(AbstractJsr88Deployer.java:207)
11-Jun-2013 15:13:48            at org.codehaus.cargo.maven2.DeployerRedeployMojo.performDeployerActionOnSingleDeployable(DeployerRedeployMojo.java:50)
11-Jun-2013 15:13:48            at org.codehaus.cargo.maven2.AbstractDeployerMojo.performDeployerActionOnAllDeployables(AbstractDeployerMojo.java:180)
11-Jun-2013 15:13:48            at org.codehaus.cargo.maven2.AbstractDeployerMojo.doExecute(AbstractDeployerMojo.java:97)
11-Jun-2013 15:13:48            at org.codehaus.cargo.maven2.AbstractCargoMojo.execute(AbstractCargoMojo.java:432)
11-Jun-2013 15:13:48            at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
11-Jun-2013 15:13:48            ... 20 more
11-Jun-2013 15:13:48    [ERROR] 
11-Jun-2013 15:13:48    [ERROR] 
11-Jun-2013 15:13:48    [ERROR] For more information about the errors and possible solutions, please read the following articles:
11-Jun-2013 15:13:48    [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException
11-Jun-2013 15:13:48    [ERROR] 
11-Jun-2013 15:13:48    [ERROR] After correcting the problems, you can resume the build with the command

我需要的是货物插件强制重新部署,而不管该上下文根已经存在应用程序(旧版本)。

如果我手动运行 asadmin 命令,我可以轻松添加 --force 参数并且它会起作用。

我有一个额外的限制,我不能在托管竹实例的服务器上安装本地版本的 glassfish,所以我不能使用像 maven sh 插件这样的东西来手动构建 asadmin 命令。

下面是相关的 pom.xml 片段:

<build>
        <finalName>myapp-${project.version}</finalName>
        <plugins>
            <plugin>
                <groupId>org.codehaus.cargo</groupId>
                <artifactId>cargo-maven2-plugin</artifactId>
                <version>1.4.2</version>
                <configuration>
                    <container>
                        <containerId>glassfish3x</containerId>
                        <type>remote</type>
                    </container>
                    <configuration>
                        <type>runtime</type>
                        <properties>
                            <cargo.remote.username>${cargo.remote.username}</cargo.remote.username>
                            <cargo.remote.password>${cargo.remote.password}</cargo.remote.password>
                            <cargo.glassfish.admin.port>${cargo.glassfish.admin.port}</cargo.glassfish.admin.port>
                            <cargo.hostname>${cargo.hostname}</cargo.hostname>
                        </properties>
                    </configuration>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>org.glassfish.deployment</groupId>
                        <artifactId>deployment-client</artifactId>
                        <version>3.1.1</version>

                    </dependency>
                </dependencies>
            </plugin>

有任何想法吗?

4

4 回答 4

4

有同样的问题。使用 Marlon 的建议通过添加运行时参数来解决它,如下所示:

          ...
          <configuration>
            <type>runtime</type>
            <properties>
              <cargo.runtime.args>force=true</cargo.runtime.args>
              <cargo.hostname>${hostname}</cargo.hostname>
              <cargo.remote.username>${username}</cargo.remote.username>
              <cargo.remote.password>${password}</cargo.remote.password>
            </properties>
          </configuration>
          ...

显然,货物进行部署,而不是重新部署。

于 2013-10-25T16:14:05.997 回答
3

我终于发现了如何通过稍微修改部署和版本控制应用程序的方式以及使用 glassfish 的应用程序版本控制系统来实现这一点。以下是我写的一篇小博客文章的链接,以展示如何完成此操作:

博客文章 - 使用 cargo 插件部署到远程 glassfish

于 2013-07-04T20:39:43.560 回答
1

其他对我有用的方法是使用maven-glassfish-plugin,我正确配置了插件,我将 pom 作为重新部署执行

    <execution>
            <id>gf-deploy</id>
            <phase>package</phase>
            <goals>
                <goal>redeploy</goal>
            </goals>
        </execution>

然后我修改了 asadmin.bat 文件,在脚本调用 appserver-cli.jar 文件的行之后,我添加了一些行,注意 redeploy 调用了一个 undeploy 和一个 deploy 命令,所以这里的 maven glassfish 插件的技巧是 print undeploy 命令运行时的某些东西(Tihs 会混淆 maven 插件,就好像 undeploy 命令总是成功一样),但是,当 asadmin 命令部署时,流程将正常运行。

:run
if NOT %1 == undeploy goto :end
%JAVA% -jar "%~dp0..\lib\client\appserver-cli.jar" %*
ECHO "TEST"
:end

if %1 == undeploy goto :end1
%JAVA% -jar "%~dp0..\lib\client\appserver-cli.jar" %*
:end1

完成此修改后,relay 总是工作得很好!

于 2015-01-18T03:04:21.733 回答
0

您可能需要在管理领域设置一个新的 glassfish 服务器管理员用户。查看以下http://beforeuquit.blogspot.com/

于 2013-12-23T13:20:47.870 回答