From the forums that I followed I tried some ways to find a way to deploy mutliple wars using tomcat plugin in maven but I could not succeed.
I created a third project and used three projects in order to deploy them but I have not done it. Could you please tell me way to do it ?
Best Regards
Alper Kopuz
Here is the pom.xml that I used :
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>
tr.com.provus.pays
</groupId>
<artifactId>PAYSGroupProject</artifactId>
<version>1.0</version>
<packaging>pom</packaging>
<modules>
<module>../PAYSWeb</module>
<module>../PAYSDashboard</module>
<module>../PAYSStaticWeb</module>
</modules>
<name>PAYSGroupProject</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<executions>
<execution>
<id>deploy</id>
<phase>pre-integration-test</phase>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
</configuration>
</plugin>
</plugins>
</build>
</project>
I guess you cannot use the tomcat plugin on a pom type project, try instead to configure the plugin into one of the war projects and include the others as webapp dependencies with something like that :
<configuration>
<webapps>
<webapp>
<contextPath>/PAYSWeb</contextPath>
<groupId>tr.com.provus.pays</groupId>
<artifactId>PAYSWeb</artifactId>
<version>${project.version}</version>
<type>war</type>
<asWebapp>true</asWebapp>
</webapp>
<webapp>...</webapp>
</webapps>
</configuration>
Look also at this post (but unanswered)
Each webapp will need a different context root which is supplied to the tomcat7 maven plugin with the "path" value.
You will deploy each web app from its own POM independently. But since you have a pom type project that causes the others to build, you should be able to redeploy all three at once.
Note that there are two ways to deploy using this plugin:
You can deploy without the war. It just compiles the java files and deploys them directly to tomcat.
You can deploy the war. Maven will have to build the war and then it gets deployed to Tomcat. This is more like a production deployment and helps you verify the war will deploy correctly.
So. Move your plugin XML to each of the three "modules" pom files. They will have type 'war'. Then add this under configuration:
<path>paysWeb</path>
under the <configuration> tag for the first 'module'. Of course, you use the different names for the <path> for each of the 'module's.
There is more info here: http://tomcat.apache.org/maven-plugin-2.0/tomcat7-maven-plugin/usage.html
Related
I am developing an eclipse plugin which needs an com.lmax.disruptor.It imports sun.misc. I have this in my p2 repository but when I maven build my plugin I am getting this error "unable to satisfy dependency from com.lmax.disruptor 3.2.0 to package sun.misc 0.0.0."
I have gone through the sites Resolve a dependency on package sun.misc with Tycho they are saying to create a plugin fragment but when I tried to create it and added export page as sun.misc, It is throwing an error like "package sun.misc doesnot exsist in the plugin".
How can solve this issue please help me with this.? Instead of creating new plugin fragment,is there is any possible way i can add in my plugin itself ?
Thanks,
As mentioned in oberlies' answer in the question you link to, you need to build a system bundle fragment, which exposes, i.e., exports, the sun.misc package. I don't know of any other way. However, this is easier than could be expected.
You do this by creating an OSGi MANIFEST.MF that exports sun.misc, and then bundle it into a fragment. This is done via Maven as follows.
<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>your.group</groupId>
<version>1.0.0</version>
<artifactId>your.group.fragment.sun.misc</artifactId>
<packaging>jar</packaging>
<name>System Bundle Fragment exporting sun.misc</name>
<description>This bundle extends the System Bundle export list with the sun.misc package such that OSGi bundles may refer to Sun's misc implementation without the OSGi framework itself to provide it in a non-portable way.</description>
<build>
<plugins>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<forceCreation>true</forceCreation>
<archive>
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
<manifestEntries>
<Export-Package>sun.misc</Export-Package>
</manifestEntries>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.5.4</version>
<executions>
<execution>
<id>bundle-manifest</id>
<phase>process-classes</phase>
<goals>
<goal>manifest</goal>
</goals>
</execution>
</executions>
<configuration>
<instructions>
<Bundle-Category>your.group</Bundle-Category>
<Fragment-Host>system.bundle; extension:=framework</Fragment-Host>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
</project>
Run mvn clean install on this POM. Now you need to make the fragment consumable for Tycho, i.e., you need to make it available via a p2 Software Site.
Thankfully there is a great Maven plugin which can help with that: reficio's p2-maven-plugin. You can use it to basically wrap any mavenized JAR into an OSGi bundle and then provide it via a p2 site.
Set up the respective POM as follows.
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>sun-misc-p2</groupId>
<artifactId>site</artifactId>
<version>1.0.0</version>
<packaging>pom</packaging>
<build>
<plugins>
<plugin>
<groupId>org.reficio</groupId>
<artifactId>p2-maven-plugin</artifactId>
<version>1.1.1</version>
<executions>
<execution>
<id>default-cli</id>
<configuration>
<artifacts>
<!-- specify your depencies here -->
<!-- groupId:artifactId:version -->
<artifact><id>com.lmax:disruptor:3.3.2</id></artifact>
<artifact><id>your.group:your.group.fragment.sun.misc:1.0.0</id></artifact>
</artifacts>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>8.1.5.v20120716</version>
<configuration>
<scanIntervalSeconds>10</scanIntervalSeconds>
<webAppSourceDirectory>${basedir}/target/repository/</webAppSourceDirectory>
<webApp>
<contextPath>/site</contextPath>
</webApp>
</configuration>
</plugin>
</plugins>
</build>
<pluginRepositories>
<pluginRepository>
<id>reficio</id>
<url>http://repo.reficio.org/maven/</url>
</pluginRepository>
</pluginRepositories>
</project>
Note that I use this plugin to provide the LMAX Disruptor (version 3.3.2, the latest one at the time of writing, is thankfully available from Maven Central).
Run mvn p2:site on the POM. This will create a p2 site containing the sun.misc fragment at {project-folder}/target/repository.
This p2 repository - and with it the sun.misc fragment - can now be added to your target platform, and hence used in your Tycho build.
This should fix it, and - to answer your question if "there is any possible way [you] can add in [your] plugin itself" - this is the only possible way to do it (I know of).
The sources are also available at https://github.com/newcodeontheblock/eclipse-rcp-with-async-logging. The whole procedure is also described in more detail in this - my - blog post about using async Log4j 2 loggers in an Eclipse RCP.
I have 5 bundles in my Maven project. But i want only 4 of them to be deployed on karaf and moduleE to be compiled and generate its jar file only at another place.
Module E do not have any Activator class it just has one properties file (xml).
My POM file contains:
<modules>
<module>moduleA</module>
<module>moduleB</module>
<module>moduleC</module>
<module>moduleD</module>
<module>moduleE</module>
</modules>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven-compiler-plugin.version>3.1</maven-compiler-plugin.version>
<karaf.deploy.build.folder>${env.KARAF_BASE}/deploy</karaf.deploy.build.folder>
</properties>
More information would be needed to answer comprehensively but, based on what you've posted, somewhere else in your pom or parent pom will be some plugin configuration which uses karaf.deploy.build.folder.
You would need to override that in Module E.
Something like:
<plugin>
<groupId>whatever.plugin.has.karaf.deploy.build.folder.mentioned.in.it</groupId>
<artifactId>some.artifact</artifactId>
<executions>
<execution>
<phase>none</phase>
</execution>
</executions>
</plugin>
In maven pom file, my project packaging type is "jar" like bellow.
<packaging>jar</packaging>
My cargo-maven2-plugin configuration in pom.xml file from the legacy code. I try to run it Eclipse Kelpler, but since the plugin configuration didn't mention cargo-maven2-plugin version(I don't know actual version for this configuration), Eclipse try to get the most recent one which is 1.4.8. Based on the configuration, the Tomcat version looks like 6.0.14, but container id is 5x. Whole configuration seems doesn't right and I try to make it work. Any suggestions? The package type must jar and I can't change it.
<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>
I set type for to "jar" to match project. But when I run maven build in Eclipse Kelper, I am getting following error message. As you can see there is no allowed type "jar" is listed. Could any one help?
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
According to Cargo's Tomcat 5.x doc only war files can be deployed to tomcat, that's why it is failing. Why don't you use war to create a webapp? I don't know your requirements, but usually if you deploy on Tomcat you have a webapp in a war file. What do you need to do? Do you have a servlet or jsp file in your project? Do you need it to use it as a library for an other webapp?
You could create a web app and include the jar generated by that project as a dependency. Use org.apache.marmotta:marmotta-archetype-webapp Maven archetype to create your project and add your legacy project dependency to the pom, it would be something like this:
<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>
I'm wondering exactly how I would set this up. I have a normal java/tomcat/mysql app, and I want to deploy to EC2. I'd like to use pallet to provision the box, configure it, and deploy my war there. I'm hoping I can do this via a maven plugin?
I guess my other option is to create a lein project and deploy the war using a relative path, but I'm hoping for the maven plugin...
I can't speak to the AWS and Pallet part of your question, but assuming you have a running tomcat instance you can use the Apache Cargo project directly from maven to deploy your app:
Here is a sanitized version of our cargo configuration:
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.2.1</version>
<configuration>
<container>
<containerId>tomcat6x</containerId>
<type>remote</type>
</container>
<configuration>
<type>runtime</type>
<properties>
<cargo.hostname>${tomcat.hostname}</cargo.hostname>
<cargo.servlet.port>8080</cargo.servlet.port>
<cargo.remote.username>$[tomcat.username}</cargo.remote.username>
<cargo.remote.password>${tomcat.password}</cargo.remote.password>
</properties>
</configuration>
<deployer>
<type>remote</type>
<deployables>
<deployable>
<groupId>com.mycompany</groupId>
<artifactId>MyWebApp</artifactId>
<type>war</type>
<pingURL>http://my.company.com/url</pingURL>
<pingTimeout>80000</pingTimeout>
<properties>
<context>ROOT</context>
</properties>
</deployable>
</deployables>
</deployer>
</configuration>
</plugin>
You can then get this run with this command (set the relevant properties of course):
mvn -DskipTests package cargo:deploy
More information on Using Apache Cargo with Maven is here: http://cargo.codehaus.org/Maven2+Plugin+Getting+Started
Is it possible to avoid deploying the artifact that is built according to the project packaging during 'deploy:deploy' processing?
I mean the following:
suppose we have a 'pom.xml' for web application and define packaging type as 'war';
we want to assemble either '*.war' artifact or '*.zip' that contains our application as well as a servlet container;
we want to deploy only that '*.zip' artifact during 'deploy:deploy' processing;
I.e. I want to be able to run 'mvn deploy' and has the following results:
'myapp.war' is constructed;
'myapp-standalone.zip' is constructed;
'myapp-standalone.zip' is deployed to the target remote repository (note that I don't bother if 'myapp.war' is installed to the local repository here);
I checked 'war:war documentation' and found 'primaryArtifact' parameter. However, it mentions only local repository.
I tried the following POM but it still deploys either '*.war' or '*.zip' to remote repository:
<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>com.mygroup</groupId>
<artifactId>myapp</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>myapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<!-- dependencies go here -->
</dependencies>
<build>
<plugins>
<! -- plugins like 'compiler' etc -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<primaryArtifact>false</primaryArtifact>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>myapp-standalone</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptors>
<descriptor>src/main/assembly/standalone.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<distributionManagement>
<repository>
<-- target repository information -->
</repository>
<snapshotRepository>
<-- target repository information -->
</snapshotRepository>
</distributionManagement>
</project>
It seems that I can get desired behavior via declaring project packaging as 'pom' and manually configuring all mojos implied by 'war' packaging ('resources:resources', 'compiler:compile', 'resources:testResources', 'compiler:testCompile', 'surefire:test', 'war:war', 'install:install', 'deploy:deploy'). However, that would make the POM rather verbose and I'd like to avoid that.
As far as I understand, Maven way is to always have an artifact implied by project packaging type as a one of project artifacts. But it's not clear what Maven user is expected to do if he or she wants to get an artifact that is not matched to any default packing types (e.g. single '*.zip' archive).
Any thoughts?
Regards, Denis
According to the Maven Deploy Plugin documentation:
deploy:deploy is used to automatically install the artifact, its pom and the attached artifacts produced by a particular project. [...]
So I don't think it's possible to prevent your war from being deployed "as is".
However, to obtain the desired effect, you could add a specific module to your build that would be in charge of producing the assembly (the assembly would depend on the war module) and configure the deploy plugin in the war module to skip deployment as follows:
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>X.Y</version>
<configuration>
<skip>true</skip>
</configuration>
</plugin>