1

我坚持将战争部署到远程 Jetty 9。

在应用服务器端,我部署了 cargo-jetty-7-and-onwards-deployer(版本 1.4.9)。该组件似乎运行正确并响应(如 get 请求所预期的那样):

HTTP 错误 400

访问 /cargo-jetty-deployer/ 时出现问题。原因:命令/未知 Powered by Jetty://

为了部署,我使用了 cargo-maven2-plugin(版本 1.4.9)和这个配置:

<plugin>
    <groupId>org.codehaus.cargo</groupId>
    <artifactId>cargo-maven2-plugin</artifactId>
    <version>${cargo.plugin.version}</version>
    <configuration>

            <container>
                <containerId>jetty9x</containerId>
                <type>remote</type>
            </container>

            <configuration>
                <type>runtime</type>
                <properties>
                    <cargo.servlet.port>80</cargo.servlet.port>
                    <cargo.hostname>ipgoeshere</cargo.hostname>
                    <cargo.protocol>http</cargo.protocol>
                </properties>
            </configuration>

            <deployables>
                <deployable>
                    <groupId>se.dn.nav</groupId>
                    <artifactId>nav-api</artifactId>
                    <type>war</type>
                    <properties>
                        <context>/api</context>
                    </properties>
                </deployable>
            </deployables>

    </configuration>
</plugin>

运行时:mvn cargo:deploy

这会导致以下错误消息:

[ERROR] Failed to execute goal org.codehaus.cargo:cargo-maven2-plugin:1.4.9:deploy (default-cli) on project nav-api: Execution default-cli of goal org.codehaus.cargo:cargo-maven2-plugin:1.4.9:deploy failed: Failed to deploy [/var/lib/jenkins/jobs/Deploy-Stage/workspace/target/nav-api-1.2.war]: Response when calling http://ip:80/cargo-jetty-deployer/deploy?path=/api was: Error - Unexpected error when trying to start the webapp -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.cargo:cargo-maven2-plugin:1.4.9:deploy (default-cli) on project nav-api: Execution default-cli of goal org.codehaus.cargo:cargo-maven2-plugin:1.4.9:deploy failed: Failed to deploy [/var/lib/jenkins/jobs/Deploy-Stage/workspace/target/nav-api-1.2.war]
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:224)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:108)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:76)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:116)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:361)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:155)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:584)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:213)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:157)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default-cli of goal org.codehaus.cargo:cargo-maven2-plugin:1.4.9:deploy failed: Failed to deploy [/var/lib/jenkins/jobs/Deploy-Stage/workspace/target/nav-api-1.2.war]
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:144)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
    ... 19 more
Caused by: org.codehaus.cargo.container.ContainerException: Failed to deploy [/var/lib/jenkins/jobs/Deploy-Stage/workspace/target/nav-api-1.2.war]
    at org.codehaus.cargo.container.jetty.JettyRemoteDeployer.deploy(JettyRemoteDeployer.java:126)
    at org.codehaus.cargo.maven2.DeployerDeployMojo.performDeployerActionOnSingleDeployable(DeployerDeployMojo.java:56)
    at org.codehaus.cargo.maven2.AbstractDeployerMojo.performDeployerActionOnAllDeployables(AbstractDeployerMojo.java:166)
    at org.codehaus.cargo.maven2.AbstractDeployerMojo.doExecute(AbstractDeployerMojo.java:97)
    at org.codehaus.cargo.maven2.AbstractCargoMojo.execute(AbstractCargoMojo.java:432)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:133)
    ... 20 more
Caused by: org.codehaus.cargo.container.ContainerException: Response when calling http://ip:80/cargo-jetty-deployer/deploy?path=/api was: Error - Unexpected error when trying to start the webapp

    at org.codehaus.cargo.container.jetty.JettyRemoteDeployer.deploy(JettyRemoteDeployer.java:119)
    ... 25 more
[ERROR] 
[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/PluginExecutionException

在此之后,构建和部署失败。

我检查了 Jetty 上的日志,我还将日志记录级别提高到了 DEBUG,但没有迹象表明服务器端出了什么问题。

有谁知道我做错了什么?有什么方法可以让我获得更好的错误消息来指示出了什么问题?

任何帮助将不胜感激!:)

Ps 我已经删除了日志中的 ip。

Pss 我正在部署的战争之前已经过测试并且在 Jetty 上运行良好。

4

2 回答 2

0

对我有用的是将系统属性设置为 Jetty 目录config.home的父目录。webapps

部署者会将上传的war复制到webapps目录中,让Jetty自动部署。

如果config.home设置了,那么部署器将使用${config.home}/webapps,如果没有设置,那么它将${jetty.home}/webapps用作 war 文件的目标目录。对我来说, webapps 目录配置为${jetty.base}/webapps${jetty.home}/webapps. 设置${config.home}等于${jetty.base}解决了这个问题。

于 2015-04-15T15:35:19.610 回答
0

似乎cargo-jetty-7-and-onwards-deployer与 Jetty 9+ 不兼容(Jetty 9 中存在一些货物可能不知道的生命周期变化)

这样做(找出答案)...

  1. 使用以下额外命令行启动码头

    java -jar /opt/jetty/start.jar -Dorg.LEVEL=DEBUG -Djetty.dump.start=true

  2. 检查日志,应该有更多信息,包括服务器状态转储。如果cargo-jetty-deployer不存在或未标记为已启动,则部署程序 webapp 本身无法启动。

如果您愿意,请使用转储和/或相关的 webapp 启动错误日志事件更新您的问题(不是整个日志,因为这太吵了)

于 2014-08-26T14:36:42.540 回答