GlassFish v3 cargo-maven2-plugin - maven-2

I see that supports GlassFish v3, but the online examples is sparse. I continue to get the same error back from cargo:
Cannot find the GlassFish admin CLI JAR: admin-cli.jar
Here is my pom
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.0.3</version>
<configuration>
<container>
<containerId>glassfish3x</containerId>
<type>installed</type>
</container>
<configuration>
<type>standalone</type>
<home>C:\glassfishv3</home>
<properties>
<cargo.hostname>localhost</cargo.hostname>
<cargo.servlet.port>8082</cargo.servlet.port>
<cargo.remote.username></cargo.remote.username>
<cargo.remote.password></cargo.remote.password>
</properties>
</configuration>
<deployer>
<type>installed</type>
<deployables>
<deployable>
<groupId>${groupId}</groupId>
<artifactId>${artifactId}</artifactId>
<type>war</type>
</deployable>
</deployables>
</deployer>
</configuration>
</plugin>
corrected Pom:
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.0.3</version>
<configuration>
<container>
<containerId>glassfish3x</containerId>
<type>installed</type>
<home>C:\glassfishv3</home>
</container>
<configuration>
<type>standalone</type>
<properties>
<cargo.hostname>localhost</cargo.hostname>
<cargo.servlet.port>8082</cargo.servlet.port>
<!-- if no username/password don't use these, it will fail
<cargo.remote.username></cargo.remote.username>
<cargo.remote.password></cargo.remote.password> -->
</properties>
</configuration>
<deployer>
<type>installed</type>
<deployables>
<deployable>
<groupId>${groupId}</groupId>
<artifactId>${artifactId}</artifactId>
<type>war</type>
</deployable>
</deployables>
</deployer>
</configuration>
</plugin>

In your Glassfish installation, do you have the admin-cli.jar file present in modules directory?
For more information about this module, check this link.
Edit
It seems that you have a problem in your configuration. As you can see here, there are several <home> nodes that can be used in the <configuration> of the Cargo plugin.
If you define the <home> inside the <configuration> tag, like you do in your pom.xml, this tag is used for:
For standalone configuration this is the location where Cargo will create the configuration and for existing configuration this is where it is located
However, in your case, you must move the <home> in the <container> tag. As described in the link above, this <home> is used for:
Location where the container is installed.

Related

maven tomcat7:run configure datasource

I have a multimodule maven project, and I want to use it with tomcat7 maven plugin and start it with:
mvn tomcat7:run
But I can't figure out how to configure a jndi datasource.
I've tried to put in my pom.xml:
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.0</version>
<configuration>
<contextFile>tomcat/context.xml</contextFile>
</configuration>
</plugin>
and in the context.xml:
<?xml version="1.0" encoding="UTF-8"?>
<Context>
<Resource name="jdbc/AppealDS" url="jdbc:hsqldb:file:database/appeal"
driverClassName="org.hsqldb.jdbcDriver" username="appeal"
password="appeal" auth="Container" type="javax.sql.DataSource"
maxActive="3" maxIdle="2" maxWait="10000" />
</Context>
But it doesn't work...How can I register the jndi datasource?
What is the error message?
Use:
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<contextFile>tomcat/context.xml</contextFile>
</configuration>
</plugin>
Maybe your jdbc driver is not available in the classpath?
Try adding him in the plugin dependency
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<contextFile>tomcat/context.xml</contextFile>
</configuration>
<dependencies>
<dependency>
here your hsql version
</dependency>
</dependencies>
</plugin>

Where is Cargo generating context XML for Jetty 6.x?

I am trying to implement the solution mentioned in How to specify jetty-env.xml file for Maven Cargo plugin for Jetty?
However I am facing something even more fundamental: My Cargo is simply not generating any context xml.
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.2.1</version>
<configuration>
<!-- Container configuration -->
<container>
<containerId>jetty6x</containerId>
<type>embedded</type>
</container>
<!-- Configuration to use with the container or the deployer -->
<configuration>
<properties>
<cargo.servlet.port>${itest.webapp.port}</cargo.servlet.port>
<cargo.jetty.createContextXml>true</cargo.jetty.createContextXml>
</properties>
<deployables>
<deployable>
<groupId>${project.groupId}</groupId>
<artifactId>myApp-web</artifactId>
<type>war</type>
<properties>
<context>/myApp</context>
</properties>
</deployable>
</deployables>
<!--
<configfiles>
<configfile>
<file>${project.build.outputDirectory}/jetty-env.xml</file>
<todir>contexts</todir>
<tofile>${jetty6.context}.xml</tofile>
</configfile>
</configfiles>
-->
</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>
The basic idea is, we are providing the a custom context.xml to replace the one generated. However, when I am trying out, I cannot find any context XML generated by Cargo (Please note that I have remarked the custom config files, and with cargo.jetty.createContextXml being true)
I am not sure if it is my problem in setting causing the context not generated, or the context is generated somewhere I overlooked. I have checked under target/cargo/ and the temp directory that cargo expanded my WAR, neither place contains the context xml.
(I am using Maven 2.2.1, Cargo 1.2.1, JDK 6)
I am not 100% sure what your problem is, but here is what cargo does on my system for Jetty6.
The directory where the Jetty installation is NOT where the runtime context and webapp files are. In my case, they are stored in the Java temp directory (i.e. java.io.tmpdir). On my Ubuntu system this is /tmp. Under this directory, there is a cargo/conf directory. Under /tmp/cargo/conf I have a contexts directory where the context.xml file is stored -- although the actual name of the file is never context.xml it is always named after the web app context.
In my case, this file is given the same name as the context I configured cargo with. Herein may lie your problem because I noticed that you did not supply a context as I do:
<deployables>
<deployable>
<properties>
<!-- Web root context URL -->
<context>${build.appserver.context}</context>
</properties>
</deployable>
</deployables>
Secondly, I also noticed you have commented out the section that places the context.xml file in the right place. Unless you uncomment that, this isn't going to work.
Thirdly, did you set the value of the ${jetty6.context} Maven property?
Fourthly - I think for this to work you need to use a standalone configuration of Jetty. This shouldn't be a problem as Cargo will automatically download and install it for you. See my config here:
<container>
<containerId>jetty6x</containerId>
<!-- Using Jetty for build portability so type != "remote". For Jetty
would prefer type = "embedded" but we must go with "installed" because jetty-env.xml
file would be ignored. See http://jira.codehaus.org/browse/CARGO-861 -->
<type>installed</type>
<zipUrlInstaller>
<url>http://dist.codehaus.org/jetty/jetty-6.1.26/jetty-6.1.26RC0.zip</url>
<installDir>${build.working}</installDir>
</zipUrlInstaller>
<dependencies>
<!-- The following dependencies are added to the servlet container's
classpath as if they were installed by a system admin. In order to be included
here, they need to be listed as dependencies in this pom.xml. -->
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
</dependency>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc5</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
<groupId>net.sourceforge.jtds</groupId>
<artifactId>jtds</artifactId>
</dependency>
</dependencies>
</container>
<!-- Do not hang and wait for a client, just do it -->
<wait>false</wait>
<configuration> <!-- Deployer configuration -->
<!-- Running Jetty container with type=installed (e.g. local) so
type != "runtime", and we are installing it during this execution for the
sake of portability so type != "existing" -->
<type>standalone</type>
<properties>
<!-- Use the port number from settings.xml -->
<cargo.servlet.port>${build.appserver.port}</cargo.servlet.port>
</properties>
<deployables>
<deployable>
<properties>
<!-- Web root context URL -->
<context>${build.appserver.context}</context>
</properties>
</deployable>
</deployables>
<configfiles>
<configfile>
<file>${basedir}/target/jetty-context.xml</file>
<todir>contexts</todir>
<tofile>${build.appserver.context}.xml</tofile>
</configfile>
</configfiles>
</configuration>

maven ear plugin not picking up application.xml

I am using jbosscc-seam-archtype 1.2 and I am putting the application.xml in EAR project, under /src/main/application/META-INF/ but the maven-ear-plugin is not picking it up. any suggestion?
Here is the snippet of my maven EAR plugin:
<plugins>
<plugin>
<artifactId>maven-ear-plugin</artifactId>
<configuration>
<version>5</version>
<modules>
<webModule>
<groupId>com.***</groupId>
<artifactId>***-war</artifactId>
<contextRoot>***</contextRoot>
<unpack>${exploded.war.file}</unpack>
</webModule>
<jarModule>
<groupId>com.***</groupId>
<artifactId>***-datamodel</artifactId>
<includeInApplicationXml>true</includeInApplicationXml>
</jarModule>
<ejbModule>
<groupId>com.***</groupId>
<artifactId>***-bootstrap</artifactId>
<excluded>${exclude.bootstrap}</excluded>
</ejbModule>
<ejbModule>
<groupId>org.jboss.seam</groupId>
<artifactId>jboss-seam</artifactId>
</ejbModule>
<jarModule>
<groupId>org.jboss.el</groupId>
<artifactId>jboss-el</artifactId>
<bundleDir>lib</bundleDir>
</jarModule>
</modules>
<jboss>
<version>${version.jboss.app}</version>
<loader-repository>***:app=ejb3</loader-repository>
</jboss>
</configuration>
</plugin>
What am I doing wrong?
By default, your application.xml will not be picked even if you include it in src/main/application/META-INF/application.xml in your maven ear project that's because it will be autogenerated by the configuration specified at <configuration> of the maven-ear-plugin. If you want yours to be included you need to change generateApplicationXml to false (defaults to true).
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>2.4.2</version>
<configuration>
<version>6</version>
<displayName>MyEAR</displayName>
<defaultLibBundleDir>lib</defaultLibBundleDir>
<modules>
<webModule>
<groupId>com.test</groupId>
<artifactId>my-web</artifactId>
<bundleFileName>my-web.war</bundleFileName>
<contextRoot>/MyWeb</contextRoot>
</webModule>
</modules>
<generateApplicationXml>false</generateApplicationXml>
</configuration>
</plugin>
You can use <applicationXml>/your/location/</applicationXml> in <configuration> element to specify location of your custom application.xml file.
Please check if you really need custom application.xml file, otherwise use <generateApplicationXml>true</generateApplicationXml>.

Maven: Only want to run profile if doing a build on the parent pom

I'm using Maven 3.0.3. I have a project that inherits from a parent …
<modelVersion>4.0.0</modelVersion>
<groupId>com.myco.util.ant</groupId>
<artifactId>selenium-framework</artifactId>
<packaging>jar</packaging>
<name>Myco Selenium Utils</name>
<parent>
<groupId>com.nna</groupId>
<artifactId>parent</artifactId>
<version>1.2-SNAPSHOT</version>
<relativePath>../parent</relativePath>
</parent>
In my parent pom I have the below profile. However, I only want this profile to be active if someone is doing a build on the parent pom, as opposed to one of its children. Does anyone know how I can adjust the below so that it won't be activated if someone is doing a build of a child project?
<profile>
<id>deploy-snapshot</id>
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<phase>deploy</phase>
<configuration>
<target>
<condition property="is-release">
<not>
<contains string="${project.version}" substring="SNAPSHOT" />
</not>
</condition>
<fail if="is-release" message="You can only deploy snapshot versions of this project." />
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
Thanks, - Dave
You could try activating it by the presence/absence of a file or directory. You can find an example in the Sonatype Maven book. Note that there's a difference between "current working directory" and "${project.basedir}", and the differences are slightly different between Maven 2 and Maven 3, if that matters to you.
I had a similar situation, I wanted to run a profile in a subproject by default but not when build from the top level, and at the same time give the option to run it from the top project as well.
I used the user.dir property for that in combination of Ryan's reference.
in integration project's pom:
<profile>
<id>continuous-integration</id>
<!-- Two ways of activating this profile -->
<activation>
<!-- Run the build from the top with param -DfullTest -->
<property>
<name>fullTest</name>
</property>
<!-- Run the build from the integration directory -->
<file>
<missing>${user.dir}/integration</missing>
</file>
</activation>
...
<profile>
If needs to be disabled just change the <missing/> for a <exists/>.

Tomcat 7 - Maven Plugin?

I just wanted to double-check, has anyone found or is working on a Tomcat 7 plugin? If not, is anyone interested in helping me get it up and running?
I want another quick alternative to Glassfish, JBoss AS 6.0 is a bit heavy still for quick mockups.
Walter
It work for me as the following.
My setting.xml
<server>
<id>local_tomcat</id>
<username>ray</username>
<password>password</password>
</server>
My plugin configuration
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<configuration>
<server>local_tomcat</server>
<url>http://localhost:8080/manager/text</url>
</configuration>
</plugin>
My tomcat-users.xml
<role rolename="manager-gui"/>
<role rolename="manager-script"/>
<user password="password" roles="manager-gui, manager-script" username="ray"/>
i use the official Tomcat7 Maven Plugin from Apache as follows:
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.0</version>
<configuration>
<path>/${project.artifactId}</path>
<port>8080</port>
</configuration>
</plugin>
and to run it: mvn tomcat7:run
There is t7mp - a Tomcat 7 Maven Plugin - on Google code.
Cargo (and its Cargo Maven2 Plugin) also has support for Tomcat 7 (this was CARGO-790).
Apache Tomcat Maven Plugin 2.0-beta-1 supports Tomcat 7.
Using maven cargo your can coufigure your project that way :
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.0.6</version>
<configuration>
<container>
<containerId>tomcat7x</containerId>
<type>installed</type>
<home>${catalina.home}</home>
</container>
<configuration>
<type>existing</type>
<home>${catalina.home}</home>
</configuration>
<deployer>
<type>installed</type>
<deployables>
<deployable>
<groupId>${project.groupId}</groupId>
<artifactId>${project.artifactId}</artifactId>
<type>war</type>
</deployable>
</deployables>
</deployer>
</configuration>
</plugin>
don't forget to configure your catalina.home property
The you can deploy it using:
mvn cargo:deploy
There is the Tomcat Maven Plugin 7 plugin developed by the Apache Tomcat team.
Currently you have to checkout the sources and install it to your local repository.
After that you can use it in the plugin section of your pom:
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.0-SNAPSHOT</version>
<executions>
<execution>
<id>start-tomcat</id>
<phase>compile</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<path>/</path>
<serverXml>src/main/tomcatconf/server.xml</serverXml>
</configuration>
</execution>
</executions>
</plugin>
After I had this error for three days in a row, here's my solution:
The user you are using to connect needs at least the role manager-script.
In your /conf/tomcat-users.xml
<role rolename="manager-script"/>
<user username="test" password="test" roles="manager-script"/>
In your pom.xml, include the following plugin
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.0</version>
<configuration>
<url>http://server.url:8080/manager/text</url>
<path>/YourApp</path>
<username>test</username>
<password>test</password>
</configuration>
</plugin>
Contrary to what I found in the internet you DON'T need to edit your maven setting.xml. The tomcat7-maven-plugin can be configured directly in the configuration-tag
A word to the url-tag: I tested the suffix
/manager
/manager/html
/manager/text
of which only /manager/text worked
My versions:
Tomcat: 7.0.33
Maven: 3.0.4
tomcat7-maven-plugin: 2.0
Java: 1.7.0_07
I'm using tomcat7-maven-plugin for my embedded tomcat instance. Here is how I have configured it. Since my app requires jaas authentication I can also provide that in the setting itself.
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<configuration>
<!-- http port -->
<port>8080</port>
<path>/gcs-explorers</path>
<contextFile>${basedir}/src/main/webapp/META-INF/context.xml</contextFile>
<addWarDependenciesInClassloader>true</addWarDependenciesInClassloader>
<systemProperties>
<java.security.auth.login.config>${basedir}/conf/jaas.config</java.security.auth.login.config>
</systemProperties>
<url>http://127.0.0.1:8080/manager/html</url>
<username>admin</username>
<password>admin</password>
<addContextWarDependencies>true</addContextWarDependencies>
<addWarDependenciesInClassloader>true</addWarDependenciesInClassloader>
<configurationDir>${basedir}</configurationDir>
</configuration>
<dependencies>
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
<version>2.2.0</version>
<type>jar</type>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.company.package.jaas</groupId>
<artifactId>gcs-jaas</artifactId>
<version>0.0.1-SNAPSHOT</version>
<type>jar</type>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.company.gcs</groupId>
<artifactId>package-file-share</artifactId>
<version>0.0.1-SNAPSHOT</version>
<type>war</type>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>11.2.0.3</version>
<scope>runtime</scope>
</dependency>
</dependencies>
</plugin>
Actually, the standard plugin works for me . I just had to create the role manager-script in tomcat users and change the url parameter to http://localhost:8080/manager/html in order to make it work :
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<configuration>
<url>http://localhost:8080/manager/html</url>
<server>local</server>
<path>/${project.artifactId}</path>
<update>true</update>
</configuration>
</plugin>
For Tomcat 7,
Step 1:
Modules tab of server add
Document base: <PATH>\Apache-Tomcat-7.0.0\webapps\manager
Path: /manager
Step 2:
Update POM to:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<configuration>
<url>http://localhost:8080/manager/text</url>
<update>true</update>
<warFile>target/${project.artifactId}-${project.version}.war</warFile>
<path>/${project.artifactId}</path>
<username>tomcat_user</username>
<password>tomcat_password</password>
</configuration>
</plugin>