我试图在我的Maven项目中使用Cargo插件,以便从针对Jonas服务器的战争热部署中受益。
官方文档不清楚支持什么和不支持什么(例如,您可以找到以下内容:http : //cargo.codehaus.org/Hot+Deployment以及此http://cargo.codehaus.org/JOnAS + 4.x)。
无论如何,对于战争的POM,我具有以下含义:
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.0</version>
<configuration>
<container>
<containerId>jonas4x</containerId>
<home>C:\JOnAS-4.8.4\nt\bin</home>
</container>
<configuration>
<type>existing</type>
<home>C:\JOnAS-4.8.4</home>
</configuration>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
当我跑步时
mvn cargo:deploy
Run Code Online (Sandbox Code Playgroud)
在我的项目中,战争已复制到Jonas webapps文件夹,但没有热部署。仅复制文件,但不调用hot deploy Jonas命令,因此无法立即使用我的修改。
编辑:我也尝试按照答案中的建议添加部署程序配置,但行为是相同的(即:复制了war,但未调用Jonas hot deploy命令,以便不会在Jonas中重新加载war)。
我是否缺少某些信息?或者我说的是Cargo Maven插件不支持Jonas Hot Deployement吗?
提前致谢!
我想让我的集成测试在http://localhost:8080/messaging 上命中货物的 tomcat,但货物 (cargo-maven2-plugin:1.0.5) 更喜欢将我的消息传递项目部署为 /messaging-0.0.7-SNAPSHOT,如在 tomcat 管理控制台和 target\tomcat6x\webapps 目录中看到。
所以我尝试将这些行添加到货物配置中,认为它会选择默认工件:
<deployer>
<deployables>
<deployable>
<properties>
<context>/messaging</context>
</properties>
</deployable>
</deployables>
</deployer>
Run Code Online (Sandbox Code Playgroud)
但事实并非如此。它甚至没有尝试,因为我在 target\tomcat6x\webapps 目录中没有看到消息或消息 0.0.7-SNAPSHOT。
当我像这样设置它时会发生同样的事情:
<configuration>
<type>standalone</type>
<wait>false</wait>
<properties>
<cargo.servlet.port>8080</cargo.servlet.port>
<cargo.logging>high</cargo.logging>
</properties>
<deployer>
<deployables>
<deployable>
<groupId>com.company.platform</groupId>
<artifactId>messaging</artifactId>
<type>war</type>
<properties>
<context>/messaging</context>
</properties>
</deployable>
</deployables>
</deployer>
</configuration>
Run Code Online (Sandbox Code Playgroud)
这是完整的插件配置:
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<executions>
<execution>
<id>start</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start</goal>
</goals>
</execution>
<execution>
<id>stop</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
<configuration>
<type>standalone</type>
<wait>false</wait>
<properties>
<cargo.servlet.port>8080</cargo.servlet.port>
<cargo.logging>high</cargo.logging>
</properties>
<deployer>
<deployables>
<deployable>
<properties>
<context>/messaging</context>
</properties> …Run Code Online (Sandbox Code Playgroud) 我使用Maven Cargo (1.2.1) 配置并启动 Glassfish 3.1.2 进行集成测试。我能够配置数据源并启动服务器。但我还需要配置 JDBC 安全领域以及 Java 邮件会话。
但我不知道如何使用 Maven Cargo 配置安全领域和 Java 邮件会话,有人知道吗?
一种方法可能是使用asadmin,但我不知道如何从货物中使用它。
到目前为止我所拥有的:
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.2.1</version>
<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>
<configuration>
<container>
<type>installed</type>
<containerId>glassfish3x</containerId>
<artifactInstaller>
<groupId>org.glassfish.main.distributions</groupId>
<artifactId>glassfish</artifactId>
<version>3.1.2</version>
<type>zip</type>
</artifactInstaller>
<output>${project.build.directory}/glassfish/container.log</output>
<log>${project.build.directory}/glassfish/cargo.log</log>
<append>false</append>
<dependencies>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc</artifactId>
</dependency>
</dependencies>
</container>
<configuration>
<home>${project.build.directory}/cargo/configurations/glassfish</home>
<properties>
<cargo.servlet.port>8082</cargo.servlet.port>
<cargo.datasource.datasource>
cargo.datasource.jndi=jdbc/tecisplus|
cargo.datasource.type=javax.sql.DataSource|
cargo.datasource.driver=oracle.jdbc.OracleDriver|
cargo.datasource.url=${it-database.url}|
cargo.datasource.username=$[it-database.username}|
cargo.datasource.password=${it-database.password}
</cargo.datasource.datasource>
</properties>
<deployables>
<deployable>
<groupId>de.test</groupId>
<artifactId>test-ear</artifactId> …Run Code Online (Sandbox Code Playgroud) 这是我的persistence.xml样子
<?xml version="1.0" encoding="UTF-8"?>
<persistence
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/persistence"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version="2.0">
<persistence-unit name="earth">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<jta-data-source>java:/jdbc/EarthDS</jta-data-source>
<properties>
<property name="hibernate.archive.autodetection" value="class"/>
<property name="hibernate.id.new_generator_mappings" value="true"/>
<property name="javax.persistence.lock.timeout" value="5000"/>
</properties>
</persistence-unit>
</persistence>
Run Code Online (Sandbox Code Playgroud)
我正在war使用 部署该文件maven-cargo-plugin。根据他们的文档,他们将数据源设置JNDI为
<configuration>
<properties>
<cargo.datasource.datasource.derby>
cargo.datasource.driver=org.apache.derby.jdbc.EmbeddedDriver|
cargo.datasource.url=jdbc:derby:derbyDB;create=true|
cargo.datasource.jndi=jdbc/CargoDS|
cargo.datasource.username=APP|
cargo.datasource.password=nonemptypassword
</cargo.datasource.datasource.derby>
</properties>
</configuration>
Run Code Online (Sandbox Code Playgroud)
由于我使用的是H2数据库,所以我将其设置为
<properties>
<cargo.servlet.port>9090</cargo.servlet.port>
<properties>
<cargo.datasource.datasource>
cargo.datasource.driver=org.h2.Driver|
cargo.datasource.url=jdbc:h2:~/earth;create=true|
cargo.datasource.jndi=jdbc/EarthDS|
cargo.datasource.username=sa|
cargo.datasource.password=
</cargo.datasource.datasource>
</properties>
</properties>
</configuration>
Run Code Online (Sandbox Code Playgroud)
当我运行该项目时,我在日志中看到错误:
[INFO] [talledLocalContainer] 09:43:01,335 INFO [org.jboss.as.server.deployment] (MSC service thread 1-12) JBAS015876: Starting deployment of …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用货物部署应用程序,这是它的配置:
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.4.9</version>
<configuration>
<wait>true</wait>
<container>
<containerId>glassfish4x</containerId>
<type>remote</type>
</container>
<configuration>
<type>runtime</type>
<properties>
<cargo.hostname>remote-IP-address</cargo.hostname>
<cargo.remote.username>admin</cargo.remote.username>
<cargo.remote.password>######</cargo.remote.password>
<cargo.glassfish.admin.port>4848</cargo.glassfish.admin.port>
<cargo.glassfish.domain.name>domain1</cargo.glassfish.domain.name>
</properties>
</configuration>
<deployables>
<deployable>
<groupId>${project.groupId}</groupId>
<artifactId>${project.artifactId}</artifactId>
<type>war</type>
<properties>
<context>/app</context>
</properties>
</deployable>
</deployables>
</configuration>
<dependencies>
<dependency>
<groupId>org.glassfish.deployment</groupId>
<artifactId>deployment-client</artifactId>
<version>3.2-b06</version>
</dependency>
</dependencies>
</plugin>
Run Code Online (Sandbox Code Playgroud)
不幸的是,服务器在大约30秒后抛出此异常:
[2014-09-25T11:39:47.598+0200] [glassfish 4.1] [SEVERE] [NCLS-CORE-00003] [javax.enterprise.system.core] [tid: _ThreadID=339 _ThreadName=admin-listener(44)] [timeMillis: 1411637987598] [levelValue: 1000] [[
Exception while running a command
java.io.IOException: java.util.concurrent.TimeoutException
at org.glassfish.admin.payload.PayloadFilesManager.extractFile(PayloadFilesManager.java:584)
at org.glassfish.admin.payload.PayloadFilesManager.access$600(PayloadFilesManager.java:93)
at org.glassfish.admin.payload.PayloadFilesManager$DataRequestType$1.processPart(PayloadFilesManager.java:749)
at org.glassfish.admin.payload.PayloadFilesManager.processPartsExtended(PayloadFilesManager.java:618)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$UploadedFilesManager.extractFiles(CommandRunnerImpl.java:2074)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$UploadedFilesManager.<init>(CommandRunnerImpl.java:2046)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$UploadedFilesManager.<init>(CommandRunnerImpl.java:2025)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1155)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1300(CommandRunnerImpl.java:109) …Run Code Online (Sandbox Code Playgroud) 我们在构建服务器上将Cargo与Maven结合使用,以将WAR文件从构建服务器远程部署到内部质量检查服务器以进行测试。
我们当前用于该项目的POM如下所示,并且可以在热部署中正常工作。
问题在于,我们希望让Cargo插件停止Tomcat实例,部署新的WAR,然后启动Tomcat ,而不是热部署。有没有办法更改POM来管理这种情况?
我们的Maven构建定义为:
mvn clean deploy ... cargo:redeploy
Run Code Online (Sandbox Code Playgroud)
以及POM中的cargo插件设置:
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<configuration>
<container>
<containerId>tomcat7x</containerId>
<type>remote</type>
<systemProperties>
<cargo.jvmargs>-XX:MaxPermSize=256M -Xmx1024m</cargo.jvmargs>
</systemProperties>
</container>
<configuration>
<type>runtime</type>
<properties>
<cargo.hostname>qa-server</cargo.hostname>
<cargo.servlet.port>8080</cargo.servlet.port>
<cargo.tomcat.manager.url>http://qa-server:8080/manager</cargo.tomcat.manager.url>
<cargo.remote.username>username</cargo.remote.username>
<cargo.remote.password>pass</cargo.remote.password>
</properties>
</configuration>
<deployer>
<type>remote</type>
<deployables>
<deployable>
<groupId>com.ourcompany</groupId>
<artifactId>myapp-artifactId</artifactId>
<type>war</type>
<properties>
<context>latest</context>
</properties>
</deployable>
</deployables>
</deployer>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud) 我正在尝试按照本教程设置Grails / Cargo:https : //github.com/bmuschko/gradle-cargo-plugin 我希望使用此插件将Wars部署到本地tomcat实例并启动和停止它们。
这是我的build.gradle
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'cargo'
sourceCompatibility = 1.5
version = '1.0'
jar {
manifest {
attributes 'Implementation-Title': 'Gradle Quickstart', 'Implementation-Version': version
}
}
repositories {
mavenCentral()
}
dependencies {
compile group: 'commons-collections', name: 'commons-collections', version: '3.2'
testCompile group: 'junit', name: 'junit', version: '4.+'
classpath 'org.gradle.api.plugins:gradle-cargo-plugin:0.6.1'
def cargoVersion = '1.3.3'
cargo "org.codehaus.cargo:cargo-core-uberjar:$cargoVersion",
"org.codehaus.cargo:cargo-ant:$cargoVersion"
}
cargo {
containerId = 'tomcat6x'
port = 9090
deployable {
file = file('/Users/me/Documents/gradlemucks/grails_2/hello-world/target/hello-world-0.1.war')
context = …Run Code Online (Sandbox Code Playgroud) 有人成功地将EAR远程部署到JBoss 5.1.0.GA吗?我的pom.xml配置如下:
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.0.1-SNAPSHOT</version>
<configuration>
<container>
<containerId>jboss51x</containerId>
<type>remote</type>
<timeout>600000</timeout>
</container>
<configuration>
<type>runtime</type>
<properties>
<cargo.remote.username>username</cargo.remote.username>
<cargo.remote.password>password</cargo.remote.password>
<cargo.hostname>myserver</cargo.hostname>
<cargo.servlet.port>8888</cargo.servlet.port>
</properties>
</configuration>
<deployer>
<type>remote</type>
<deployables>
<deployable>
</deployable>
</deployables>
</deployer>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
这会导致以下错误消息:
java.io.IOException: Server returned HTTP response code: 500 for URL:
http://myserver:8888/jmx-console/HtmlAdaptor?action=invokeOpByName&name=jboss.system:service%3DMainDeployer&methodName=deploy&argType=java.net.URL&arg0=file:d%3A%5Cear%5Cmy-ear-1.0-SNAPSHOT.ear
Run Code Online (Sandbox Code Playgroud) 我正在尝试在 Maven 3 中运行嵌入式 Tomcat 9 以进行集成测试。我是cargo-maven2-plugin由其他 SO 答案引导的。
因此,尝试按照此处找到的说明进行操作:
https://codehaus-cargo.github.io/cargo/Static+deployment+of+WAR.html
我在一个简单的 POM 中有这个片段:
<build>
<plugins>
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.7.6</version>
<configuration>
<container>
<containerId>tomcat9x</containerId>
<type>embedded</type>
</container>
<deployables>
<deployable>
<type>war</type>
<properties>
<file>path/to/myapp.war</file>
</properties>
</deployable>
</deployables>
</configuration>
</plugin>
</plugins>
</build>
Run Code Online (Sandbox Code Playgroud)
我尝试执行 mvn org.codehaus.cargo:cargo-maven2-plugin:run
它失败并出现错误:
[INFO] [en2.ContainerRunMojo] 已解决容器构件 org.codehaus.cargo:cargo-core-container-tomcat:jar:1.7.6 for container tomcat9x [警告] 定义的可部署与项目的主要构件具有相同的 groupId 和 artifactId但类型不同。您已经定义了一个 [war] 类型,其中项目的包装是 [pom]。这可能是一个错误,因此插件将尝试在项目的依赖项中找到这个可部署的。
我怎样才能使这项工作?我只想在 Maven 中的嵌入式 tomcat9 中启动给定的 WAR。
我安装了cargo构建环境。我cargo install exa用来安装exa(命令的替代品ls)。可执行文件放在$HOME/.cargo/bin. 我使用fishshell set -gx PATH $PATH $HOME/.cargo/bin,然后我可以exa在当前会话中使用命令。
但是当我打开一个新会话时,exa除非set -gx ...再次执行,否则我无法执行。
我查看选项gx:
--global -g (Make variable scope global)
--export -x (Export variable to subprocess)
Run Code Online (Sandbox Code Playgroud)
全局不是意味着每个会话吗?有人可以帮我吗?