[英]How to setup configuration (JDBC Realm or a Java Mail Session) in Glassfish with Maven Cargo?
I use Maven Cargo (1.2.1) to configure and start an Glassfish 3.1.2 for Integration Tests. 我使用Maven Cargo (1.2.1)配置和启动用于集成测试的Glassfish 3.1.2。 I am able to configure the datasource and start the server. 我能够配置数据源并启动服务器。 But I also need to configure a JDBC Security Realm as well as a Java Mail Session. 但是我还需要配置JDBC安全领域以及Java邮件会话。
But I have no clue how to configure a Security Realm and Java Mail Session with maven cargo, does anybody has an idea ? 但是我不知道如何使用maven来配置Security Realm和Java Mail Session,有人有想法吗?
One way maybe is to use asadmin
but I don't know how to use it from cargo. 一种方法可能是使用asadmin
但我不知道如何从货物中使用它。
What I have so far: 到目前为止,我有:
<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>
<type>ear</type>
</deployable>
</deployables>
</configuration>
</configuration>
</plugin>
The workaround I use at the moment it so have a hand written domain.xml
file that already contains all the configuration (JDBC, Realm and JavaMail Session). 我目前使用的解决方法是,拥有一个手写的domain.xml
文件,该文件已经包含所有配置(JDBC,Realm和JavaMail Session)。
Then I instructed cargo to use that domain.xml
instead of doing own configuration: 然后,我指示货运使用该domain.xml
而不是自己进行配置:
<configuration>
<home>${project.build.directory}/cargo/configurations/glassfish</home>
<configfiles>
<configfile>
<file>${project.build.directory}/filtered-serverresources/domain.xml</file>
<todir>cargo-domain/config</todir>
</configfile>
</configfiles>
<deployables>
<deployable>
<groupId>de.tecis.tecisplus</groupId>
<artifactId>tecisplus-ear</artifactId>
<type>ear</type>
</deployable>
</deployables>
</configuration>
the ${project.build.directory}/filtered-serverresources/domain.xml
is a small trick to configure the file (cargo can also replace some properties, but I was not able to replace the properties that cargo not knows.) So I use the maven-resource-plugin
${project.build.directory}/filtered-serverresources/domain.xml
是配置文件的一个小技巧(货物也可以替换某些属性,但是我无法替换货物不知道的属性。)所以我使用maven-resource-plugin
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<!-- because maven test-resource does not support filter! -->
<version>2.5</version>
<configuration>
<encoding>UTF-8</encoding>
</configuration>
<executions>
<execution>
<id>filter-glassfish-configuration-domain-file</id>
<!-- <phase>pre-integration-test</phase> -->
<phase>process-test-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/filtered-serverresources</outputDirectory>
<resources>
<resource>
<directory>src/test/serverresources</directory>
<filtering>true</filtering>
<includes>
<include>**/*.xml</include>
</includes>
</resource>
</resources>
<delimiters>
<delimiter>~{*}</delimiter>
</delimiters>
</configuration>
</execution>
</executions>
</plugin>
The modified delimiter ~{
... }
are nesseary because the domain.xml
contains a lot of sequences that looks like the default delimiter ${...}
修改后的定界符~{
... }
是必需的,因为domain.xml
包含许多看起来像默认定界符${...}
的序列${...}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.