java - org.codehaus.cargo.container.ContainerException : Cannot create deployable

标签 java eclipse maven cargo-maven2-plugin

在maven pom文件中,我的项目打包类型是“jar”,如下所示。

<packaging>jar</packaging>

来自遗留代码的 pom.xml 文件中的 Cargo-maven2-plugin 配置。我尝试在 Eclipse Kelpler 上运行它,但由于插件配置没有提及 Cargo-maven2-plugin 版本(我不知道此配置的实际版本),Eclipse 尝试获取最新的版本,即 1.4.8。根据配置,Tomcat 版本看起来像 6.0.14,但容器 id 是 5x。整个配置似乎不正确,我尝试让它工作。有什么建议么?包类型必须是 jar 并且我无法更改它。

                <plugin>
                    <groupId>org.codehaus.cargo</groupId>
                    <artifactId>cargo-maven2-plugin</artifactId>
                    <configuration>
                        <wait>${cargo.wait}</wait>
                        <container>
                            <containerId>tomcat5x</containerId>
                            <zipUrlInstaller>
                                <url>
                                    http://archive.apache.org/dist/tomcat/tomcat-6/v${tomcat.version}/bin/apache-tomcat-${tomcat.version}.zip
                                </url>
                                <installDir>${installDir}</installDir>
                            </zipUrlInstaller>
                        </container>
                        <configuration>
                            <home>${project.build.directory}/tomcat5x/container</home>
                            <properties>
                                <cargo.hostname>${cargo.host}</cargo.hostname>
                                <cargo.servlet.port>${cargo.port}</cargo.servlet.port>
                            </properties>
                            <deployables>
                                <deployable>
                                    <properties>
                                        <context>ROOT</context>
                                    </properties>
                                </deployable>
                            </deployables>
                        </configuration>
                    </configuration>
                    <executions>
                        <execution>
                            <id>start-container</id>
                            <phase>pre-integration-test</phase>
                            <goals>
                                <goal>start</goal>
                            </goals>
                        </execution>
                        <execution>
                            <id>stop-container</id>
                            <phase>post-integration-test</phase>
                            <goals>
                                <goal>stop</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>  

            </plugins>
        </build>
    </profile>
</profiles>
<properties>
    <cargo.host>localhost</cargo.host>
    <cargo.port>25888</cargo.port>
    <cargo.wait>false</cargo.wait>
    <tomcat.version>6.0.14</tomcat.version>
</properties>

我将 type 设置为“jar”以匹配项目。但是当我在 Eclipse Kelper 中运行 maven build 时,我收到以下错误消息。正如您所看到的,没有列出允许的类型“jar”。有人可以帮忙吗?

org.codehaus.cargo.container.ContainerException: Cannot create deployable. There's no registered deployable for the parameters (container [id = [default]], deployable type [jar]). Valid types for this deployable are: 
  - ear
  - war
  - rar
  - bundle
  - file
  - sar
  - ejb

最佳答案

根据Cargo's Tomcat 5.x doc只有war文件可以部署到tomcat,这就是它失败的原因。为什么不使用 war 来创建 web 应用程序?我不知道你的要求,但通常如果你部署在 Tomcat 上,你的 war 文件中有一个 web 应用程序。你需要做什么?您的项目中有 servlet 或 jsp 文件吗?您需要它来将其用作其他网络应用程序的库吗?

您可以创建一个 Web 应用程序并将该项目生成的 jar 作为依赖项包含在内。使用 org.apache.marmotta:marmotta-archetype-webapp Maven archetype 创建项目并将遗留项目依赖项添加到 pom 中,如下所示:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven v4_0_0.xsd">

  <modelVersion>4.0.0</modelVersion>
  <groupId>test.war</groupId>
  <artifactId>test-war</artifactId>
  <packaging>war</packaging>
  <version>1.0-SNAPSHOT</version>
  <name>test-war Maven Webapp</name>
  <url>http://maven.apache.org</url>
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
  <build>
    <finalName>test-war</finalName>
  </build>
  <dependencies>
      <dependency>
          <groupId>legacyProjectGroupId</groupId>
          <artifactId>legacyProjectArtifactId</artifactId>
          <version>legacyProjectVersion</version>
      </dependency>
  </dependencies>
</project>

关于java - org.codehaus.cargo.container.ContainerException : Cannot create deployable,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23642618/

相关文章:

java - surefire插件中的maven多个测试服

java - 为什么 Spring 将实例初始化为单例?有哪些原因影响了他们决定以这种方式处理初始化?

android - Eclipse JUNO 无法启动

java - Eclipse IDE 如何解析文件/资源​​位置?

javascript - 如何使用sendkeys生成增量版本号

java - 未知生命周期阶段 “java”

java - Spring无法创建可执行jar

java - SAP JCo SAML 身份验证

java - JSF 中的 "Target Unreachable, identifier ' UserBean ' resolved to null"

java - 如何在 Torcs 赛车游戏中安装世界锦标赛的机器人?