Hive 0.14 UDF Maven Project Missing Dependencies - maven

I was trying to set up a Maven project that will contain user defined functions (UDFs) that I'd like to use in my Hive queries. I started with a Maven project containing no source files, and the following POM:
<?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>exp</groupId>
<artifactId>HiveUdfTestProject</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.hive</groupId>
<artifactId>hive-exec</artifactId>
<version>0.14.0</version>
</dependency>
</dependencies>
</project>
When I tried to build the project, I get the following error:
Failed to execute goal on project HiveUdfTestProject: Could not
resolve dependencies for project
exp:HiveUdfTestProject:jar:1.0-SNAPSHOT: The following artifacts could
not be resolved:
org.apache.calcite:calcite-core:jar:0.9.2-incubating-SNAPSHOT,
org.apache.calcite:calcite-avatica:jar:0.9.2-incubating-SNAPSHOT:
Could not find artifact
org.apache.calcite:calcite-core:jar:0.9.2-incubating-SNAPSHOT -> [Help
1]

I found the calcite-core-incubating jar in the maven central repository (but not the incubating-snapshot version) required by the hive-exec 0.14.0 dependency.
Adding the calcite-core from maven central got rid of the original error, and introduced a new missing dependency "pentaho-aggdesigner-algorithm" which I found on ConJars.
Adding the conjars repo and the pentaho dependency made a new missing dependency appear "org.apache.calcite:calcite-avatica:jar:0.9.2-incubating-SNAPSHOT" whose incubating (but not snapshot) dependency was available in the maven central repo.
Adding the calcite-avatica dependency to the POM made the empty project build successfully at last.
Here is the final POM needed to make a project intended for Hive UDFs build:
<?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>exp</groupId>
<artifactId>HiveUdfTestProject</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
<repositories>
<repository>
<id>conjars.org</id>
<url>http://conjars.org/repo</url>
</repository>
</repositories>
<dependencies>
<!-- From Maven Central -->
<dependency>
<groupId>org.apache.hive</groupId>
<artifactId>hive-exec</artifactId>
<version>0.14.0</version>
</dependency>
<dependency>
<groupId>org.apache.calcite</groupId>
<artifactId>calcite-core</artifactId>
<version>0.9.2-incubating</version>
</dependency>
<dependency>
<groupId>org.apache.calcite</groupId>
<artifactId>calcite-avatica</artifactId>
<version>0.9.2-incubating</version>
</dependency>
<!-- From conjars -->
<dependency>
<groupId>org.pentaho</groupId>
<artifactId>pentaho-aggdesigner-algorithm</artifactId>
<version>5.1.3-jhyde</version>
</dependency>
</dependencies>
</project>
Once the empty project built, I tried integrating the POM settings into a larger existing Maven project and saw errors about calcite-core specifically looking for the snapshot version. To get past this, I changed the hive-exec dependency to look like this:
<dependency>
<groupId>org.apache.hive</groupId>
<artifactId>hive-exec</artifactId>
<version>0.14.0</version>
<exclusions>
<exclusion>
<groupId>org.apache.calcite</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>

I explicitly included the calcite-core and calcite-avatica projects as dependencies, and my project (which also includes the Hive 14 dependencies), no longer failed with the 'artifacts could not be resolved error'
<dependency>
<groupId>org.apache.calcite</groupId>
<artifactId>calcite-core</artifactId>
<version>1.0.0-incubating</version>
</dependency>
<dependency>
<groupId>org.apache.calcite</groupId>
<artifactId>calcite-avatica</artifactId>
<version>1.0.0-incubating</version>
</dependency>
From what I can tell, this is an open issue with Hive 14. See https://issues.apache.org/jira/browse/HIVE-8906 for more info.

I've resolved the same issue by adding below dependencies to /ql/pom.xml
org.pentaho
pentaho-aggdesigner-algorithm
5.1.3-jhyde
<dependency>
<groupId>eigenbase</groupId>
<artifactId>eigenbase-properties</artifactId>
<version>1.1.4</version>
</dependency>
<dependency>
<groupId>net.hydromatic</groupId>
<artifactId>linq4j</artifactId>
<version>0.4</version>
</dependency>
and below repository to /pom.xml under positories
<repository>
<id>conjars</id>
<name>Concurrent Conjars repository</name>
<url>http://conjars.org/repo</url>
<layout>default</layout>
</repository>

Related

Compilation Failure : cannot access LoggingEventAware [ERROR] class file for org.slf4j.spi.LoggingEventAware not found on mvn clean install -U

I have upgraded the spring boot version from 2.3.5 to 2.7.5 , resolved most of the dependency versions. But when i do the maven clean install , i received the compilation failure error : cannot access LoggingEventAware
[ERROR] class file for org.slf4j.spi.LoggingEventAware not found
But i do not see any error in the java file - LoggingConfiguration.java.
When i just do reload of project to resolve all the dependencies - it gives error for maven plugin : Cannot resolve plugin org.apache.maven.plugins:maven-release-plugin:3.1.1
I am not sure what is the issue. I have tried to restart IntelliJ after invalidate cache and also cleared the .m2 repository .Nothing helps. Please suggest your inputs how to resolve the same.
Here is the sample 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>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.5</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>11</java.version>
<maven-compiler-plugin.version>3.10.1</maven-compiler-plugin.version>
<maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version>
<maven-release-plugin.version>3.1.1</maven-release-plugin.version>
<maven-scm-provider-gitexe.version>1.9.5</maven-scm-provider-gitexe.version>
<junit.platform.version>4.13.0</junit.platform.version>
<logback-json-classic>0.1.5</logback-json-classic>
<logback-jackson.version>0.1.5</logback-jackson.version>
</properties>
</project> ```
While updating a project to Spring Boot 3.0.1, I came across the same issue.
Here is what worked for me:
Exclude logback-classic sub-dependency of spring-boot-starter-web.
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</exclusion>
</exclusions>
</dependency>
Add an earlier dependency of logback with version 1.2.11
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.11</version>
</dependency>

Maven deploy -> error org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy fails, but no mention of plugin in pom?

I have a simple POM (see below). When I execute mvn deploy I get this error:
[ERROR] Failed to execute goal
org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy
(default-deploy) on project piccolotest: Deployment failed: repository
element was not specified in the POM inside distributionManagement
element or in -DaltDeploymentRepository=id::layout::url parameter ->
[Help 1]
There is no direct mention of the maven plugin in the pox, so I guess it's grabbed from somewhere else. What am I missing?
Pom file...
<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>dk.anderssewerin</groupId>
<artifactId>piccolotest</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>piccolotest</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.piccolo2d</groupId>
<artifactId>piccolo2d-core</artifactId>
<version>1.3.1</version>
</dependency>
<dependency>
<groupId>org.piccolo2d</groupId>
<artifactId>piccolo2d-examples</artifactId>
<version>1.3.1</version>
</dependency>
<dependency>
<groupId>org.piccolo2d</groupId>
<artifactId>piccolo2d-extras</artifactId>
<version>1.3.1</version>
</dependency>
</dependencies>
</project>
per packaging-type, in your case jar, is a predefined set of plugins bound to several phases. Since these can change for every new version of Maven it is best practice to lock the versions for these plugins. If you really want to know the location, it's https://git-wip-us.apache.org/repos/asf?p=maven.git;a=blob;f=maven-core/src/main/resources/META-INF/plexus/default-bindings.xml;h=09ecba441e61d4a997b01af0171815c558548537;hb=HEAD

Estructuration of multi module project. how to packaging modules?

i'm creating the estructure of a multi modul project with maven.
The parent's pom:
<?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>cat.base.gpt</groupId>
<artifactId>gpt</artifactId>
<version>0.0.1</version> <!-- application version -->
<packaging>pom</packaging>
<name>gpt</name>
<parent>
<groupId>cat.base.baseframe</groupId>
<artifactId>projecte-pare-baseframe</artifactId>
<version>0.0.11.a</version>
</parent>
<modules>
<module>gpt.domini</module>
<module>gpt.ui</module>
<module>gpt.logica</module>
<module>gpt.ejb</module>
<module>gpt.ear</module>
</modules>
<dependencies>
<!-- dependencies pel testeig TDD -->
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.7</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>1.9.5-rc1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.kubek2k</groupId>
<artifactId>springockito</artifactId>
<version>1.0.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.4</version>
<scope>provided</scope>
</dependency>
<!-- A més, en el cas de provatures UI, s'ha d'afegir la següent dependència:-->
<dependency>
<groupId>cat.base.baseframe</groupId>
<artifactId>baseframe-test-swf</artifactId>
<version>1.0.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Ok, first question, i put all the dependencies at paren's pom is this really correct?
and the most interesting part, i don't know hos to compile the grafic interfade project,(i call ui), it's better create a war or create and ear with all the necessary (ui+logica+domini+ejb) i 'm a litlle bit confused about that, i uset o work with projects already estructure created. I hope you to unsderstand my question, i put the rest of pom to keep an eye. ty.
pom's gpt.domini.
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>gpt</artifactId>
<groupId>cat.base.gpt</groupId>
<version>0.0.1</version>
</parent>
<groupId>cat.base.gpt.domini</groupId>
<artifactId>gpt.domini</artifactId>
<packaging>jar</packaging>
<name>gpt.domini</name>
<description>Definició del model de dades i de la façana del servei</description>
</project>
pom's gpt.ear
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>gpt</artifactId>
<groupId>cat.base.gpt</groupId>
<version>0.0.1</version>
</parent>
<groupId>cat.base.gtp.ear</groupId>
<artifactId>gpt.ear</artifactId>
<name>gpt.ear</name>
<packaging>ear</packaging>
<description>Paquet de l'aplicació J2EE</description>
<dependencies>
<dependency>
<groupId>${project.parent.groupId}</groupId>
<artifactId>${project.parent.artifactId}.domini</artifactId>
<version>${project.parent.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>${project.parent.groupId}</groupId>
<artifactId>${project.parent.artifactId}.ejb</artifactId>
<version>${project.parent.version}</version>
<type>ejb</type>
</dependency>
<dependency>
<groupId>${project.parent.groupId}</groupId>
<artifactId>${project.parent.artifactId}.logica</artifactId>
<version>${project.parent.version}</version>
<type>jar</type>
</dependency>
</dependencies>
</project>
pom's gpt.logica
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>gpt</artifactId>
<groupId>cat.base.gpt</groupId>
<version>0.0.1</version>
</parent>
<groupId>cat.base.gtp.logica</groupId>
<artifactId>gpt.logica</artifactId>
<name>climbing.logica</name>
<packaging>jar</packaging>
<description>Implementació del servei</description>
<dependencies>
<!-- de moment nomes el domini -->
<dependency>
<groupId>${project.parent.groupId}</groupId>
<artifactId>${project.parent.artifactId}.domini</artifactId>
<version>${project.parent.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
pom's gpt.ejb
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>gpt</artifactId>
<groupId>cat.base.gpt</groupId>
<version>0.0.1</version>
</parent>
<groupId>cat.base.gtp.ejb</groupId>
<artifactId>gpt.ejb</artifactId>
<name>gpt.ejb</name>
<packaging>ejb</packaging>
<description>Publicació d'un servei en forma EJB</description>
<dependencies>
<dependency>
<groupId>${project.parent.groupId}</groupId>
<artifactId>${project.parent.artifactId}.domini</artifactId>
<version>${project.parent.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>${project.parent.groupId}</groupId>
<artifactId>${project.parent.artifactId}.logica</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>${project.parent.groupId}</groupId>
<artifactId>${project.parent.artifactId}.logica</artifactId>
<version>${project.parent.version}</version>
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.ejb</groupId>
<artifactId>ejb-api</artifactId>
<version>3.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>jboss</groupId>
<artifactId>jboss-annotations-ejb3</artifactId>
<version>4.2.2.GA</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>2.5.6</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.client</groupId>
<artifactId>jbossall-client</artifactId>
<version>4.2.3.GA</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
pom's gpt.logica
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>gpt</artifactId>
<groupId>cat.base.gpt</groupId>
<version>0.0.1</version>
</parent>
<groupId>cat.base.gtp.logica</groupId>
<artifactId>gpt.logica</artifactId>
<name>climbing.logica</name>
<packaging>jar</packaging>
<description>Implementació del servei</description>
<dependencies>
<!-- de moment nomes el domini -->
<dependency>
<groupId>${project.parent.groupId}</groupId>
<artifactId>${project.parent.artifactId}.domini</artifactId>
<version>${project.parent.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
pom's gpt.ui
here all the dependencies of spring-rich.faces..or better at parent's pom?
packaging like a war?? or inside de module ear?? ty.
Although there is already an accepted answer, I believe it worth to give more information to you as it seems to me that, both the questioner and the accepted answer got messed up with different concepts in Maven.
1) Aggregation vs Parent POM
There are two concepts in Maven often got mixed up. Aggregation (aka Multi-module) POM and Parent POM are something irrelevant, although it is fine to use one POM to serve for both purpose.
Multi-module project aims to describe the aggregation relationship between projects, so that we can build multiple related project as a whole, and all sub-projects are built in the same reactor. Parent project aims to provide shared project settings. It can even exists out of the project structure (e.g. I may have a company-wise parent POM)
Personally I recommend to have a multi-module POM only to declare the aggregation (hierarchy) of projects, and having a separate parent POM to be used to declare shared settings.
i.e.
my-proj // aggregation only
+ my-proj-parent // parent POM
+ my-proj-main
+ my-proj-web
+ my-proj-ear
2) Shared Dependency for POM vs in EAR
Again, these are two separate concepts.
It is fine to put dependencies in parent POM. When you put it there, it means the inherited project is going to have such dependency. There is no right or wrong on this, as long as you know what you are doing (personally I am using different way, will be described later).
However, whether to put shared JARs in EAR and keep skinny WAR, or have a plain EAR with a "full" WAR has nothing to do with your dependency. It is more about the packaging strategy of EAR. Therefore, changing scope of Maven dependency just because you are going to package the project as skinny war, such approach is simply messing up the whole concept of maven dependency. Even more horrible is, when creating your EAR, you need to find out all the dependencies of its included WARs and add it one by one to the EAR POM, that's doubtless not an optimal solution
A pity that current Maven EAR plugin still has no way to declare a skinny war packaging strategy. However there are some workarounds which allow you to do so, without messing around the Maven dependency scope. http://maven.apache.org/plugins/maven-ear-plugin/examples/skinny-wars.html http://maven.apache.org/plugins/maven-war-plugin/examples/skinny-wars.html
(Update: The skinny war receipe seems updated and one of the workaround seems gone. http://docs.codehaus.org/display/MAVENUSER/Solving+the+Skinny+Wars+problem?focusedCommentId=212631587#comment-212631587 This is to include WAR type POM as POM type, so that we do no need to declare the dependencies again in EAR)
3) Use of shared dependencies in parent POM
As I mentioned before, there is no right or wrong to put dependencies in parent. However you should know that, such way actually means all inherited project is going to have such dependency, which is mostly incorrect.
for example, I have a foo-a and foo-b projects under foo, which both inherits foo-parent. Assume foo-a is using spring-core while whole logic of foo-b has nothing to do with it, if you put spring-core as dependency in foo-parent, when you look at foo-b, it is unncessarily having unrelated dependencies spring-core.
The proper way to do is only include dependencies (and other settings) in parent POM that should be shared across all inherited projects. For example, unit testing related dependencies may be a good choice. Dependencies for integration testing may be another example.
However, it doesn't mean we should declare dependencies in each project individually. One of the biggest problem is such approach is going to be hard to maintain same version of dependencies across the whole project.
In order to solve such issue, my recommendation is to make use of dependencyManagement in parent POM, which declares the version (and maybe other settings like scope, excludes). Declaring dependencyManagement is not introducing actual dependencies in inherited POM. It simply declare: "If you declare such dependency, this will be the settings to use". In each inherited POM, simply declare the dependencies' group and artifact (and maybe some project specific settings), so that you can follow the version declared in parent POM.
Maybe a bit hard to understand, here is an example:
foo-parent
<project>
<dependencyManagement> // dependency management doesn't bring actual dependency
<dependencies>
<dependency>
<groupId>org.springframework<groupId>
<artifactId>spring-core<artifactId>
<version>3.1.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.hibernate<groupId>
<artifactId>hibernate-core<artifactId>
<version>3.6</version>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies> // actual shared dependency
<dependency>
<groupId>junit<groupId>
<artifactId>junit<artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>
.....
<project>
foo-a
<project>
<dependencies>
<dependency> // note: no version declared
<groupId>org.springframework<groupId>
<artifactId>spring-core<artifactId>
</dependency>
// junit dependency is inherited
<dependencies>
<project>
Ok, first question, i put all the dependencies at paren's pom is this
really correct?
No, your shared dependencies should be put in the ear pom. In the other poms you have to reference the shared dependencies using <scope>provided</scope>.
For example in your ear pom add a dipendency:
<dependency>
<groupId>somegroup</groupId>
<artifactId>someartifact</artifactId>
<version>1.0</version>
</dependency>
In the logica and ui module pom, for example, add these lines:
<dependency>
<groupId>somegroup</groupId>
<artifactId>someartifact</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
In this way the dependency artifact is added only once in the ear package.
and the most interesting part, i don't know hos to compile the grafic
interfade project,(i call ui), it's better create a war or create and
ear with all the necessary (ui+logica+domini+ejb) i 'm a litlle bit
confused about that, i uset o work with projects already estructure
created. I hoper unsderstand my question, i put the rest of pom to
keep an eye. ty.
I don't know if I understand it right. EAR is better suited for project that can have multiple war and/or ejb modules. In your case you can get rid of modularization at all and use a single war package.
finally this is my ear's pom.
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>gpt</artifactId>
<groupId>cat.base.gpt</groupId>
<version>0.0.1</version>
</parent>
<groupId>cat.base.gpt.ear</groupId>
<artifactId>gpt.ear</artifactId>
<name>gpt.ear</name>
<packaging>ear</packaging>
<description>Paquet de l'aplicació J2EE</description>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>gpt.domini</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>gpt.ejb</artifactId>
<version>${project.version}</version>
<type>ejb</type>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>gpt.logica</artifactId>
<version>${project.version}</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>gpt.ui</artifactId>
<version>${project.version}</version>
<type>war</type>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<configuration>
<description>GPT</description>
<displayName>Gestió posicions tributarias</displayName>
<encoding>${project.build.sourceEncoding}</encoding>
<version>1.4</version>
<generateApplicationXml>true</generateApplicationXml>
<modules>
<ejbModule>
<groupId>${project.groupId}</groupId>
<artifactId>${project.parent.artifactId}.ejb</artifactId>
<bundleFileName>${project.parent.artifactId}-ejb.jar</bundleFileName>
</ejbModule>
<jarModule>
<groupId>${project.groupId}</groupId>
<artifactId>gpt.logica</artifactId>
<includeInApplicationXml>true</includeInApplicationXml>
</jarModule>
<webModule>
<groupId>${project.groupId}</groupId>
<artifactId>gpt.ui</artifactId>
<contextRoot>/gpt</contextRoot>
</webModule>
</modules>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<configuration>
<excludeScope>runtime</excludeScope>
</configuration>
</plugin>
</plugins>
</build>
</project>

Exercise - Maven by Example book

I'm trying to study Maven, and so I created a simple web application as provided on the book "Maven by Example", and in that applicaton I have the simple-weather having simple-model as a dependency, inside the simple-parent maven project.
I just copied the pom.xml (making just adjustments to the hibernate artifact version), and when I run "mvn install" on the "simple-model", it builds ok, but when I run "mvn install" on the "simple-weather" it doesn't build ok because it says it doesn't find the packages related to the simple-model dependency.
NOTE: If I create two eclipse projects and relate simple-model" it compiles ok, so there is no issue related to the projects compilation.
See both pom.xml. I suppose the issue is on the pom.xml, but I have no idea of what to do. I already tried to fix in many ways, but got no success at all.
I already copied even the group and artifact id from the simple-model to the simple-weather to guarantee it was not a typing issue. :-(
//simple-model -> 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>
<parent>
<groupId>org.sonatype.mavenbook.multispring</groupId>
<artifactId>simple-parent</artifactId>
<version>1.0</version>
</parent>
<artifactId>simple-model</artifactId>
<packaging>jar</packaging>
<name>Simple Object Model</name>
<dependencies>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-annotations</artifactId>
<version>3.5.6-Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-commons-annotations</artifactId>
<version>3.2.0.Final</version>
</dependency>
</dependencies>
</project>
//simple-weather -> 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>
<parent>
<groupId>org.sonatype.mavenbook.multispring</groupId>
<artifactId>simple-parent</artifactId>
<version>1.0</version>
</parent>
<artifactId>simple-weather</artifactId>
<packaging>jar</packaging>
<name>Simple Weather API</name>
<dependencies>
<dependency>
<groupId>org.sonatype.mavenbook.multispring</groupId>
<artifactId>simple-model</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.14</version>
</dependency>
<dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>1.6.1</version>
</dependency>
<dependency>
<groupId>jaxen</groupId>
<artifactId>jaxen</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-io</artifactId>
<version>1.3.2</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
See the error message:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.
3.2:testCompile (default-testCompile) on project simple-weather: Compilation fai
lure: Compilation failure:
[ERROR] \mavenTest\ch-multi-spring\simple-parent\simple-weather\src\test\java\or
g\sonatype\mavenbook\weather\yahoo\YahooParserTest.java:[8,43] error: package or
g.sonatype.mavenbook.weather.model does not exist
Any assistance would be appreciated. Thank you in advance.
Is the source in simple-model actually correct?
Please note that Maven is not complaining for unresolved dependency. Dependencies seems correct and it is compilation error that it cannot find the package org.sonatype.mavenbook.weather.model. It is mostly because such package is available neither in the simple-web project itself, nor in its dependencies (i.e. simple-model).
Check the JAR created in simple-model to see if it contains correct content.

Maven 3 regression: Profile dependencies lost?

I observed a change behavior between Maven 2 and Maven 3. Is this a bug or a feature? I couldn't find anything in the Maven 3.x Compatibility Notes
I use two different profiles to add dependencies for different environment in a multi-module project.
parent-pom:
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>group</groupId>
<artifactId>main</artifactId>
<packaging>pom</packaging>
<version>1.0.0-SNAPSHOT</version>
<modules>
<module>common</module>
<module>portal</module>
</modules>
</project>
The common-pom has the profile in it:
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>group</groupId>
<artifactId>common</artifactId>
<packaging>jar</packaging>
<version>1.0.0-SNAPSHOT</version>
<parent>
<groupId>group</groupId>
<artifactId>main</artifactId>
<version>1.0.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<profiles>
<profile>
<id>development</id>
<dependencies>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.14</version>
</dependency>
</dependencies>
</profile>
<profile>
<id>production</id>
<dependencies>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
</dependency>
</dependencies>
</profile>
</profiles>
</project>
The portal-pom has only the common dependency and should include the transitive dependency from the common module:
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>group</groupId>
<artifactId>portal</artifactId>
<packaging>war</packaging>
<version>1.0.0-SNAPSHOT</version>
<parent>
<groupId>group</groupId>
<artifactId>main</artifactId>
<version>1.0.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<dependencies>
<dependency>
<groupId>group</groupId>
<artifactId>common</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
Building this project (from the parent) via Maven2 mvn -P production package results in a WAR which includes the transitive dependency. (I used those simple dependencies for easy reproduction)
Executing via Maven3, I get only the common.jar in the WAR, but not the transitive dependency.
Is this a desired behavior?
To make things even "interesting": If one of the profiles is activated by default (explicit in the common-pom as the activation is not derived from the parent to the child modules) these transitive dependencies are always add to the portal.
But filtering or property-setting via profiles works as expected.
This comment solves it the one way:
the situation described above does work when profile activation using properties is used
With property activation (and not via -P) it works in Maven2 and 3
But the real solution was "caused" by the release plugin:
The profile must be submitted to release-plugin via
-Darguments=-Pproduction
Not a solution, but your use case looks similar to this open maven bug. Interestingly, according to the bug details, it happens on earlier maven versions as well.

Resources