I get this error during generation of JAR with Maven:
Failed to execute goal on project TaskManagerTrue: Could not resolve dependencies for project groupId:TaskManagerTrue:jar:1.0: Could not find artifact groupId:TaskManagerTrue:jar:1.0 in central (https://repo.maven.apache.org/maven2) -> [Help 1]
My 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>groupId</groupId>
<artifactId>TaskManagerTrue</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<dependencies>
<dependency>
<groupId>groupId</groupId>
<artifactId>TaskManagerTrue</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
</dependencies>
<build>
<finalName>test</finalName>
<defaultGoal>package</defaultGoal>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<goal>jar:inplace</goal>
<archive>
<manifestFile>META-INF/MANIFEST.MF</manifestFile>
</archive>
<outputDirectory>artifacts</outputDirectory>
</configuration>
</plugin>
</plugins>
</build>
</project>
How can I fix this problem?
Removing this declaration fixed the problem:
<dependency>
<groupId>groupId</groupId>
<artifactId>TaskManagerTrue</artifactId>
<version>1.0</version>
</dependency>
Related
I have a web-application(TestWeb) and multiple java dependency projects(TestCommon,TestModule).
I was able to build all 3 projects using maven.It has created war file and jar file out of it.
I need to create .ear file using maven. How can I create ear and build them?
TestWeb/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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>TestWeb</groupId>
<artifactId>TestWeb</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>TestCommon</groupId>
<artifactId>TestCommon</artifactId>
<version>0.0.1-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>TestModule</groupId>
<artifactId>TestModule</artifactId>
<version>0.0.1-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
Use <packaging>ear</packaging> instead of <packaging>war</packaging>.
I'm trying to deploy an Eclipse jee dynamic web app to heroku. I need to modify the pom file but I'm not sure how.
Here's what I need to add but I'm not sure where to place:
<configuration>
<appName>gentle-shore-6874</appName>
</configuration>
here's the file from eclipse:
<?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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<version>1.0-SNAPSHOT</version>
<artifactId>helloworld</artifactId>
<packaging>war</packaging>
<dependencies>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlet</artifactId>
<version>9.4.7.v20170914</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>com.heroku.sdk</groupId>
<artifactId>heroku-maven-plugin</artifactId>
<version>2.0.7</version>
<configuration>
<buildpacks>
<buildpack>heroku/exec</buildpack>
<buildpack>heroku/metrics</buildpack>
<buildpack>heroku/jvm</buildpack>
</buildpacks>
</configuration>
</plugin>
</plugins>
</build>
</project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<version>1.0-SNAPSHOT</version>
<artifactId>helloworld</artifactId>
<packaging>war</packaging>
<dependencies>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlet</artifactId>
<version>9.4.7.v20170914</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>com.heroku.sdk</groupId>
<artifactId>heroku-maven-plugin</artifactId>
<version>2.0.7</version>
<configuration>
<appName>gentle-shore-6874</appName>
<buildpacks>
<buildpack>heroku/exec</buildpack>
<buildpack>heroku/metrics</buildpack>
<buildpack>heroku/jvm</buildpack>
</buildpacks>
</configuration>
</plugin>
</plugins>
</build>
</project>
I have the tree
pom.xml
.presentation(ear)
..business(war)
..integration(jar)
when i try to build the ear (presentation) i get this error i don't understand why the artifact presentation should be a dependency and a dependency of what exactly ? :
Failed to execute goal org.apache.maven.plugins:maven-ear-plugin:2.6:generate-application-xml (default-generate-application-xml) on project presentation: Artifact[war:presentaion:presentation] is not a dependency of the project. ->Help
ear: 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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>presentation</groupId>
<artifactId>presentation</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>ear</packaging>
<parent>
<groupId>MyProject</groupId>
<artifactId>MyProject</artifactId>
<version>0.0.1</version>
</parent>
<build>
<plugins>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.4</version>
<configuration>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>2.6</version>
<configuration>
<modules>
<webModule>
<groupId>presentaion</groupId>
<artifactId>presentation</artifactId>
<bundleFileName>presentation.war</bundleFileName>
<contextRoot>/presentation</contextRoot>
</webModule>
<jarModule>
<groupId>integration</groupId>
<artifactId>integration</artifactId>
<bundleFileName>integration.jar</bundleFileName>
</jarModule>
</modules>
<displayName>My Project</displayName>
</configuration>
</plugin>
</plugins>
<finalName>presentation</finalName>
</build>
<dependencies>
<dependency>
<groupId>business</groupId>
<artifactId>business</artifactId>
<version>0.0.1-SNAPSHOT</version>
<type>war</type>
</dependency>
<dependency>
<groupId>integration</groupId>
<artifactId>integration</artifactId>
<version>0.0.1-SNAPSHOT</version>
<type>jar</type>
</dependency>
</dependencies>
</project>
In the current .pom you are building an ear and you are giving the same ear as a warModule.
You should give a .war artefact for webmodule in the ear-plugin
My Maven EAR project packs my EAR with two copies of each of my libraries. One copy is always appended with the version (In my case 1.0-SNAPSHOT). Is there something screwed up in my POMs?
I keep getting these type of errors when i try and deploy to server:
Servlet [blah...] and Servlet [blah..] have the same url pattern: [/RegistrationService_V10].
My EAR project POM looks like this :
<?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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>AlmexOffice</artifactId>
<groupId>com.huwag</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<groupId>com.huwag</groupId>
<artifactId>AlmexOffice-ear</artifactId>
<packaging>ear</packaging>
<version>1.0-SNAPSHOT</version>
<name>AlmexOFfice-ear JavaEE6 Assembly</name>
<url>http://maven.apache.org</url>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>2.4</version>
<configuration>
<version>6</version>
</configuration>
</plugin>
</plugins>
<finalName>AlmexOffice-ear</finalName>
</build>
<dependencies>
<dependency>
<groupId>com.huwag</groupId>
<artifactId>AlmexOffice-ejb</artifactId>
<version>1.0-SNAPSHOT</version>
<type>ejb</type>
</dependency>
<dependency>
<groupId>com.huwag</groupId>
<artifactId>AlmexOffice-web</artifactId>
<version>1.0-SNAPSHOT</version>
<type>war</type>
</dependency>
</dependencies>
</project>
In the maven-ear-plugin, you have to specify your ejbmodule and webmodule
<plugin>
<artifactId>maven-ear-plugin</artifactId>
<version>2.8</version>
<configuration>
<modules>
<ejbModule>
<groupId>com.huwag</groupId>
<artifactId>AlmexOffice-ejb</artifactId>
</ejbModule>
<webModule>
<groupId>com.huwag</groupId>
<artifactId>AlmexOffice-web</artifactId>
<contextRoot>/custom-context-root</contextRoot>
</webModule>
</modules>
</configuration>
</plugin>
Could you give us the feedback if it works better?
I have the following POM structure:
./foobar-common/pom.xml
./abc-window/pom.xml
./abc-datasource/pom.xml
Both abc-window pom.xml is 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>hu.abc.ringcore</groupId>
<artifactId>abc-window</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>abc-window</name>
<parent>
<relativePath>../foobar-common/pom.xml</relativePath>
<groupId>hu.abc.ringcore</groupId>
<artifactId>foobar-common</artifactId>
<version>1.0</version>
</parent>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>hu.abc.ringcore</groupId>
<artifactId>abc-datasource</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version>
<executions>
<execution>
<goals>
<goal>jar</goal>
</goals>
<phase>package</phase>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.9</version>
<configuration>
<downloadSources>true</downloadSources>
<downloadJavadocs>true</downloadJavadocs>
</configuration>
</plugin>
</plugins>
</build>
</project>
abc-datasource pom.xml is 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>hu.abc.ringcore</groupId>
<artifactId>abc-datasource</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>abc-datasource</name>
<parent>
<relativePath>../foobar-common/pom.xml</relativePath>
<groupId>hu.abc.ringcore</groupId>
<artifactId>foobar-common</artifactId>
<version>1.0</version>
</parent>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>${commons-lang3.version}</version>
</dependency>
<dependency>
<groupId>hu.abc.ringcore</groupId>
<artifactId>abc-base</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>hu.abc.ringcore</groupId>
<artifactId>abc-event</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>hu.abc.ringcore</groupId>
<artifactId>abc-variable</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>hu.abc.ringcore</groupId>
<artifactId>abc-variableintf</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>hu.foobar.ring</groupId>
<artifactId>RateSorszamIntf</artifactId>
<version>${ringcore-services.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version>
<executions>
<execution>
<goals>
<goal>jar</goal>
</goals>
<phase>package</phase>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.9</version>
<configuration>
<downloadSources>true</downloadSources>
<downloadJavadocs>true</downloadJavadocs>
</configuration>
</plugin>
</plugins>
</build>
The foobar-common pom.xml is as follows:
<project>
<modelVersion>4.0.0</modelVersion>
<name>Maven Default Project</name>
<groupId>hu.foobar.ringcore</groupId>
<artifactId>foobar-common</artifactId>
<version>1.0</version>
<packaging>pom</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<junit.version>4.10</junit.version>
<spring.version>3.1.2.RELEASE</spring.version>
<spring-security.version>2.0.6.RELEASE</spring-security.version>
<commons-logging.version>1.1.1</commons-logging.version>
<dom4j.version>1.6.1</dom4j.version>
<javaee-api.version>6.0</javaee-api.version>
<mycila-event.version>3.0</mycila-event.version>
<ringcore-services.version>1.3.4-SNAPSHOT</ringcore-services.version>
<commons-lang3.version>3.1</commons-lang3.version>
</properties>
</project>
My problem is that if I do an mvn install in abc-datasource the dependency versions are pulled from the parent pom properties as expected. However if I do mvn install from abc-window that references abc-datasource then the versions are not resolved, I get:
[ERROR] Failed to execute goal on project abc-window: Could not resolve dependencies for project hu.abc.ringcore:abc-window:jar:1.0-SNAPSHOT: Failed to collect dependencies for [junit:junit:jar:4.10 (test), hu.abc.ringcore:abc-datasource:jar:1.0-SNAPSHOT (compile)]: Failed to read artifact descriptor for org.apache.commons:commons-lang3:jar:${commons-lang3.version}: Could not transfer artifact org.apache.commons:commons-lang3:pom:${commons-lang3.version} from/to central (http://repo.maven.apache.org/maven2): IllegalArgumentException: Illegal character in path at index 70: http://repo.maven.apache.org/maven2/org/apache/commons/commons-lang3/${commons-lang3.version}/commons-lang3-${commons-lang3.version}.pom
Both project have the same parent pom, so why doesn't it work..?
Use dependencyManagment in parent pom
<dependencyManagement>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>${commons-lang3.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
add all versions in parent pom, and use dependencies without version in children
EDIT
/pom.xml <-parent pom
/abc-window/pom.xml <-child module
/abc-datasource/pom.xml <-child module
and parent pom should contains
<project
...
<properties>
...
</properties>
<modules>
<module>abc-datasource</module>
<module>abc-window</module>
</modules>
<build>
<pluginManagment>
...
</pluginManagment>
</build>
<dependencyManagment>
...
</dependencyManagment>
</project>
The parent in abc-window is listed as:
<parent>
<relativePath>../foobar-common/pom.xml</relativePath>
<groupId>hu.abc.ringcore</groupId>
<artifactId>foobar-common</artifactId>
<version>1.0</version>
</parent>
The parent in abc-datasource is listed as:
<parent>
<relativePath>../foobar-common/pom.xml</relativePath>
<groupId>hu.ratesoft.ringcore</groupId>
<artifactId>foobar-common</artifactId>
<version>1.0</version>
</parent>
So, they do not have the same groupId.