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>
Related
When I import the maven project into my ecliplse-luna I faced an error in the pom.xml
Plugin execution not covered by lifecycle configuration: org.apache.portals.pluto:maven-pluto-plugin:2.1.0-M3:assemble (execution: default, phase:
generate-resources)
so I have included <Pluginmanagement> tag in the pom.xml and it resolved the error. When I run mvn clean package/install, build was failed due to the below error (relative path \pluto-resources\web.xml is created by maven-pluto-plugin)
on project MyFirstPortlet: The specified web.xml file 'D:\PORTLET-SAMPLES\MyFirstPortlet\target\pluto-resources\web.xml' does not exist
I removed <Pluginmanagement> tag from the pom.xml and run the maven build now the maven build is successful.
The issue is, if <Pluginmanagement> tag present in the pom.xml eclipse project import doesnot throw any error but maven build is failed. if <Pluginmanagement> is not present then maven build is successful but eclipse project import is failed.
my pom.xml
<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.helloworld</groupId>
<artifactId>MyFirstPortlet</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>MyFirstPortlet Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>org.apache.portals</groupId>
<artifactId>portlet-api_2.0_spec</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<!-- bind 'pluto2:assemble' goal to 'process-resources' lifecycle -->
<!-- This plugin will read your portlet.xml and web.xml and injects required
lines -->
<plugin>
<groupId>org.apache.portals.pluto</groupId>
<artifactId>maven-pluto-plugin</artifactId>
<version>2.1.0-M3</version>
<executions>
<execution>
<phase>generate-resources</phase>
<goals>
<goal>assemble</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- configure maven-war-plugin to use updated web.xml -->
<!-- This plugin will make sure your WAR will contain the updated web.xml -->
<plugin>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<webXml>${project.build.directory}/pluto-resources/web.xml</webXml>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<finalName>MyFirstPortlet</finalName>
</build>
</project>
Can any one advise me why adding pluginmanagement causes build failure and how to resolve plugin execution not covered by lifecycle error in eclipse with out the pluginmanagement tag.
Pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<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>com.edi.proiecte</groupId>
<artifactId>Livada</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>Livada</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.4.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/com.github.eirslett/frontend-maven-plugin -->
<dependency>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>1.4</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.codehaus.mojo/exec-maven-plugin -->
<dependency>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-dependency-plugin -->
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.10</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.webjars.npm/bower -->
<!-- https://mvnrepository.com/artifact/org.webjars.npm/bower -->
</dependencies>
<build>
<plugins>
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>1.4</version>
<!-- optional -->
<configuration>
<workingDirectory>client</workingDirectory>
</configuration>
</plugin>
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>1.4</version>
<extensions>true</extensions>
<executions>
<execution>
<id>bower install</id>
<goals>
<goal>bower</goal>
</goals>
<configuration>
<!-- optional: The default argument is actually
"install", so unless you need to run some other bower command,
you can remove this whole <configuration> section.
-->
<arguments>install</arguments>
</configuration>
</execution>
<execution>
<id>grunt build</id>
<goals>
<goal>grunt</goal>
</goals>
<!-- optional: the default phase is "generate-resources" -->
<phase>generate-resources</phase>
<configuration>
<!-- optional: if not specified, it will run Grunt's default
task (and you can remove this whole <configuration> section.) -->
<arguments>build</arguments>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>1.4</version>
<!-- optional -->
<configuration>
<installDirectory>C:\Program Files\nodejs</installDirectory>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<attachClasses>true</attachClasses>
<webResources>
<resource>
<directory>${project.build.directory}/client</directory>
</resource>
</webResources>
</configuration>
</plugin>
</plugins>
</build>
This is my pom.xml. I am trying to deploy a template to a Tomcat server, and then make a basic CRUD example for the client with angular for the frontend, hibernate for persisting objects in the database. I have created my project using the spring initializr that they provide online at https://start.spring.io/ Basically what i have to do is demonstrate a simple proof of concept to the client. My problem is the config file for maven. I am trying to use the frontend-maven-plugin to run grunt and bower and build my project into a WAR file that I can deploy on a Tomcat server. I have been fiddling around with the config file for 2 days trying to get it to work, and I have to get the thing going for today at 02:00 PM when the client will come in to see what we have done. I have made some progress, but I still get an error when bower is supposed to install:
Failed to execute goal com.github.eirslett:frontend-maven-plugin:1.4:bower (bower install) on project Livada: Failed to run task: 'bower install' failed. java.io.IOException: Cannot run program "C:\Program Files\nodejs\node\node.exe" (in directory "E:\IntelliJ_IDEA\projects\LIVADA\client"): CreateProcess error=2, The system cannot find the file specified -> [Help 1]
Been resolving a lot of cryptic errors like this, but from what I can see, I did just like the Github page of the creator showed me to configure the frontend maven plugin: https://github.com/eirslett/frontend-maven-plugin
Sometimes IntelliJ even sabotaged me and would not want to run some goals, so I had to Invalidate Caches and restart the IDE.
I made another post 2 days ago, and I tried to follow the instructions that have been given in the response as close as I could, but to no avail.
Spring + Hibernate + Angular + Maven + Tomcat Project folder structure issues
My project structure is as follows:
LIVADA - E:\IntelliJ_IDEA\projects\LIVADA
.idea
libraries
.name
compiler.xml
encodings.xml
misc.xml
modules.xml
workspace.xml
.mvn
wrapper
maven-wrapper.jar
maven-wrapper.properties
client
.idea
misc.xml
modules.xml
sb-admin-angular-master.iml
workspace.xml
app
js
sb-admin-2.js
scripts
controllers
chartController.js
form.js
main.js
directives
chat
chat.html
chat.js
dashboard
stats
stats.html
stats.js
header
header-notification
header-notofication.html
header-notification.js
header.html
header.js
notifications
notifications.html
notifications.js
sidebar
sidebar-search
sidebar-search.html
sidebar-search.js
sidebar.html
sidebar.js
timeline
timeline.html
timeline.js
app.js
styles
main.css
sb-admin-2.css
timeline.css
views
dashboard
home.html
main.html
pages
blank.html
login.html
ui-elements
buttons.html
grid.html
icons.html
notifications.html
panels-wells.html
typography.html
chart.html
form.html
table.html
.buildignore
.htacess
404.html
favicon.ico
index.html
robots.txt
test
spec
controllers
about.js
main.js
.jshintrc
karma.conf.js
.gitignore
bower.json
Gruntfile.js
LICENSE
package.json
README.md
src
main
java
com.edi.proiecte.Livada
LivadaApplication.java
resources
application.properties
test
java
com.edi.proiecte.livada
LivadaApplicationTests.java
.gitignore
Livada.iml
mvnw
mvnw.cmd
pom.xml
Maybe I screwed up the folder structure, but i can't see how, as I configured the WAR plugin to copy files from the client folder and put them in the WAR file. Any help is greatly ppreciated. Thanks.
UPDATE
Solved that, for some reason the pom.xml reads C:\nodejs\node\node.exe, so i made a shortcut there. but I still get the error: Failed to execute goal com.github.eirslett:frontend-maven-plugin:1.4:bower (bower install) on project Livada: Failed to run task: 'bower install' failed. org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1) -> [Help 1]
This question's answers are a community effort. Edit existing answers to improve this post. It is not currently accepting new answers or interactions.
SpringSource.org changed their site to http://spring.io
Does someone know how to get the latest build without Maven/github? from http://spring.io/projects
Please edit to keep this list of mirrors current
I found this maven repo where you could download from directly a zip file containing all the jars you need.
https://maven.springframework.org/release/org/springframework/spring/
https://repo.spring.io/release/org/springframework/spring/
Alternate solution: Maven
The solution I prefer is using Maven, it is easy and you don't have to download each jar alone. You can do it with the following steps:
Create an empty folder anywhere with any name you prefer, for example spring-source
Create a new file named pom.xml
Copy the xml below into this file
Open the spring-source folder in your console
Run mvn install
After download finished, you'll find spring jars in /spring-source/target/dependencies
<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>spring-source-download</groupId>
<artifactId>SpringDependencies</artifactId>
<version>1.0</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>3.2.4.RELEASE</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.8</version>
<executions>
<execution>
<id>download-dependencies</id>
<phase>generate-resources</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/dependencies</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Also, if you need to download any other spring project, just copy the dependency configuration from its corresponding web page.
For example, if you want to download Spring Web Flow jars, go to its web page, and add its dependency configuration to the pom.xml dependencies, then run mvn install again.
<dependency>
<groupId>org.springframework.webflow</groupId>
<artifactId>spring-webflow</artifactId>
<version>2.3.2.RELEASE</version>
</dependency>
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
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>