Trouble with ehcache dependencies from Maven Central - java

I'm trying to build a project on a new laptop with an empty .m2/repository directory. I get the following error:
BUILD FAILED
/home/awills/Dropbox/Jasig/portal/uPortal/build.xml:635: The following error occurred while executing this line:
/home/awills/Dropbox/Jasig/portal/uPortal/build.xml:1437: The following error occurred while executing this line:
/home/awills/Dropbox/Jasig/portal/uPortal/build.xml:1372: The following error occurred while executing this line:
/home/awills/Dropbox/Jasig/portal/uPortal/build.xml:1315: The following error occurred while executing this line:
/home/awills/Dropbox/Jasig/portal/uPortal/build.xml:1318: The following error occurred while executing this line:
/home/awills/Dropbox/Jasig/portal/uPortal/build.xml:1375: The following error occurred while executing this line:
/home/awills/Dropbox/Jasig/portal/uPortal/build.xml:1227: Unable to resolve artifact: Unable to get dependency information: Unable to read the metadata file for artifact 'net.sf.ehcache:ehcache-web:jar': Cannot find parent: net.sf.ehcache:ehcache-web-parent for project: null:ehcache-web:jar:null for project null:ehcache-web:jar:null
net.sf.ehcache:ehcache-web:jar:2.0.4
from the specified remote repositories:
central (http://repo1.maven.org/maven2),
sonatype-nexus-snapshots (https://oss.sonatype.org/content/repositories/snapshots),
apache-snapshots (http://repository.apache.org/snapshots)
Path to dependency:
1) org.jasig.portal:uportal-war:war:4.1.0-SNAPSHOT
2) org.jasig.resourceserver:resource-server-utils:jar:1.0.38
The project is mature and this dependency has not changed recently. The build was working recently.
I don't understand the bit about for project: null:ehcache-web:jar:null -- where is it getting the nulls?
The net.sf.ehcache:ehcache-web:2.0.4 pom begins 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>
<parent>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache-web-parent</artifactId>
<version>2.0.4</version>
</parent>
<name>Ehcache Web Filters</name>
<artifactId>ehcache-web</artifactId>
<packaging>jar</packaging>
<description><![CDATA[Web caching filters.]]> </description>
<licenses>
<license>
<name>The Apache Software License, Version 2.0</name>
<url>http://ehcache.org/license.html</url>
</license>
</licenses>
And the net.sf.ehcache:ehcache-web-parent:2.0.4 pom begins 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">
<properties>
<forgeTags>Integration Module</forgeTags>
<Bundle-RequiredExecutionEnvironment>J2SE-1.5</Bundle-RequiredExecutionEnvironment>
</properties>
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache-parent</artifactId>
<version>2.3</version>
</parent>
<name>Ehcache Web Filters Parent</name>
<artifactId>ehcache-web-parent</artifactId>
<packaging>pom</packaging>
<version>2.0.4</version>
<description>parent pom for web module</description>

It seems that when there is a parent pom, and there are repositories defined in the child pom (ehcache-web in this case), maven tries to find the parent dependency from only the repositories defined in the child pom, and does not look in maven central at all.
In ehcache-web pom you have this:
<repositories>
<repository>
<id>sourceforge-snapshots</id>
<name>Sourceforge Snapshot Repository</name>
<url>http://oss.sonatype.org/content/repositories/sourceforge-snapshots</url>
</repository>
</repositories>
But since the parent is no longer a snapshot and has been moved to the maven central it isn't found. I worked around this by simply deleting the repositories element from my local pom file (~/.m2/repository/net/sf/ehcache/ehcache-web/2.0.4/ehcache-web-2.0.4.pom).
I also had to delete the stored ehcache-web-parent pom file, which was simply a redirect.
I found surprisingly little information about this online, but maybe these are of help:
https://issues.sonatype.org/browse/MVNCENTRAL-468
http://jira.codehaus.org/browse/MANTTASKS-246

Related

Probleme with Spring application, maven multi module and intelliJ Comunity

I'm working on a project with a parent maven module that contains no sources and 4 child modules.
It's supposed to be a Spring Application, the class having SpringApplication.run(XXX.class, args); is in a child module.
As I work with intelliJ community I don't have the spring plugin that could help me launch easely the application.
If I clean install the project everything builds correctly.
To start the application i try to right click on the class booting Spring and then click on run.
As intelliJ tries to build the app i get the following message :
Failed to execute goal on project XXX : Could not resolve dependencies
for project XXX:XXX:jar:0.0.28: Failed to collect dependencies at
XXX:XXX:jar:0.0.28: Failed to read artifact descriptor for
XXX:jar:0.0.28: Could not transfer artifact XXX:YYY:pom:${ZZZ_version_module} from/to
releases (http://nexus...): Authorization failed for
http://nexus.../.../.../$%257BZZZ_version_module%257D/...-$%257BZZZ_version_module%257D.pom
403 Forbidden
From what i understand the problem is that when building, intelliJ only build the child module, so it cannot turn the variablized version in my pom.xml ${ZZZ_version_module} into the right version using properties from the parent pom.
Because of my work, I cannot use any plugin in intelliJ or any other dependency in my pom that could help me.
Do any one have any solution to run the SpringApplication ?
Parent 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 https://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.4.3</version>
</parent>
<groupId>ABC</groupId>
<artifactId>XYZ</artifactId>
<version>${ZZZ_version_module}</version>
<packaging>pom</packaging>
<name>...</name>
<description>...</description>
<properties>
<ZZZ_version_module>0.0.28</ZZZ_version_module>
...
</properties>
</project>
Child 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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>ABC</groupId>
<artifactId>XYZ</artifactId>
<version>${ZZZ_version_module}</version>
</parent>
<artifactId>...</artifactId>
<name>...</name>
<description>...</description>
</project>
(Sorry for the broken english)

Plugin org.codehaus.mojo:exec-maven-plugin:1.5.0 or one of its dependencies could not be resolved

I am trying to run my first project "Calculator" on netbeans-11 july version and it gives this error -
Plugin org.codehaus.mojo:exec-maven-plugin:1.5.0 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.codehaus.mojo:exec-maven-plugin:jar:1.5.0: Could not transfer artifact org.codehaus.mojo:exec-maven-plugin:pom:1.5.0 from/to central (https://repo.maven.apache.org/maven2): Connect to repo.maven.apache.org:443 [repo.maven.apache.org/151.101.196.215] failed**: Connection timed out: connect -> [Help 1]
my pom.xml file -
<?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.mycompany</groupId>
<artifactId>Calculator</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>12</maven.compiler.source>
<maven.compiler.target>12</maven.compiler.target>
</properties>
</project>
how to resolve this ?
I had the same issue, make sure your editor have finished downloading all Maven requirementents, also try to update your project under de Maven menu. Finally, make sure you are not behind a proxy, if that is the case, configure your settings.xml like in this answer.

Maven issue to build one module using revision property

Recently we tried to deploy files using jenkins providing ${revision} property for the build ( Maven 3.3.9 ).
It worked OK on json creating 0.0.1-SNAPSHOT for dev builds and 0.0.1-RC for releases, but we have an issue using maven on developer machines.
We have multi-module maven project with version defined in parent and some modules uses others as dependencies. Both build it from jenkins and use maven locally, to integrate with IDEs and run tests before pushing it into repository.
When we try to build a single module, maven does not recognize ${revision}, although it works fine when we mention all modules e.g. mvn clean install -pl appserver, we see
Failed to execute goal on project appserver: Could not resolve dependencies for project com.org:appserver:war:0.0.1-local: Failed to collect dependencies at com.org:my-kinesis-events:jar:0.0.1-local: Failed to read artifact descriptor for com.org:my-kinesis-events:jar:0.0.1-local: Could not transfer artifact com.org:my-parent:pom:${revision} from/to central: Failed to transfer .../repository/maven-central/com/org/my-parent/${revision}/my-parent-${revision}.pom. Error code 500, Server Error -> [Help 1]
We tried to use:
-Drevision=0.0.1-local
<profile>
<id>default-version</id>
<activation>
<property>
<name>!revision</name>
</property>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<revision>0.0.1-local</revision>
<project.version>0.0.1-local</project.version>
</properties>
</profile>
but the only thing that works is a build for parent that that builds the module and all modules it depends on:
mvn clean install -pl appserver,my-kinesis-events,module1,module2,...
Although the above works it requires from the team to define custom run configuration in IDE, each time they need something.
Did somebody also experienced this issue and found the solution?
Parent pom snippet:
<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.org</groupId>
<artifactId>my-parent</artifactId>
<version>${revision}</version>
<packaging>pom</packaging>
<name>My Parent module</name>
<modules>
<module>../my-tools</module>
<module>my-kinesis-events</module>
....
</modules>
.....
</project>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>my.org</groupId>
<artifactId>my-kinesis-events<</artifactId>
<version>${project.version}</version>
<dependency>
<dependencies>
</dependencyManagement>
Module pom snippet:
<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>
<artifactId>appServer</artifactId>
<parent>
<groupId>com.org</groupId>
<artifactId>my-dsp</artifactId>
<version>${revision}</version>
<relativePath>..</relativePath>
</parent>
<packaging>war</packaging>
<name>AppServerAPI</name>
<description>Application Server</description>
<dependencies>
<dependency>
<groupId>com.org</groupId>
<artifactId>my-openrtb</artifactId>
</dependency>
.....
</dependencies>
....
</project>
These issues have been fixed since Maven 3.5, you need however to use the maven flatten plugin to ensure that all variables are removed from your POM before publishing. Otherwise you end up having POM containing ${revision} has version.
This is neatly explained in the official maven documentation:
https://maven.apache.org/maven-ci-friendly.html#install-deploy

Gradle search dependency in repository from maven pom.xml

I have an Android library dependency which I pull in from my own Maven repository (Artifactory based):
compile "com.jmolsmobile.mylibrary:mylibrary:1.0.4"
This dependency depends on another library, which is located in another Maven repository with a custom URL:
repositories {
maven { url 'https://mint.splunk.com/gradle/' }
}
What I want to do is to include my Android library in another project, without having to add the repository URL explicitly to my Gradle files, but rather have my project inherit the repository URL via the Maven pom.xml.
But Gradle does not search in the custom repository URL:
> Could not resolve all dependencies for configuration ':app:_debugCompile'.
> Could not find com.splunk.mint:mint:4.2.1.
Searched in the following locations:
https://jcenter.bintray.com/com/splunk/mint/mint/4.2.1/mint-4.2.1.pom
https://jcenter.bintray.com/com/splunk/mint/mint/4.2.1/mint-4.2.1.jar
http://10.0.190.250:8081/artifactory/android-snapshot-local/com/splunk/mint/mint/4.2.1/mint-4.2.1.pom
http://10.0.190.250:8081/artifactory/android-snapshot-local/com/splunk/mint/mint/4.2.1/mint-4.2.1.jar
file:/Applications/Android-SDK/extras/android/m2repository/com/splunk/mint/mint/4.2.1/mint-4.2.1.pom
file:/Applications/Android-SDK/extras/android/m2repository/com/splunk/mint/mint/4.2.1/mint-4.2.1.jar
file:/Applications/Android-SDK/extras/google/m2repository/com/splunk/mint/mint/4.2.1/mint-4.2.1.pom
file:/Applications/Android-SDK/extras/google/m2repository/com/splunk/mint/mint/4.2.1/mint-4.2.1.jar
Even though the repository is explicitly defined in 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>com.jmolsmobile.mylibrary</groupId>
<artifactId>mylibrary</artifactId>
<version>1.0.4</version>
<packaging>aar</packaging>
<repositories>
<repository>
<id>splunk</id>
<url>https://mint.splunk.com/gradle/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.splunk.mint</groupId>
<artifactId>mint</artifactId>
<version>4.2.1</version>
</dependency>
</dependencies>
</project>
Any ideas why this is going wrong?

MavenError: Failed to execute goal on project: Could not resolve dependencies In Maven Multimodule project

I am trying to create a maven multi-module project. the project is created successfully but when I am trying to use one module as a dependency of another module, it throws an exception. When I create a module using eclipse, I was selecting packaging as a jar, but when the module is created, the packaging tag was not mention in child pom.xml and I manually insert the packaging tag as a jar.
following is my parent 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>com.netsol</groupId>
<artifactId>empirecl</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
-------------------------
<modules>
<module>empirecl-web</module>
<module>empirecl-dao</module>
<module>empirecl-service</module>
<module>empirecl-api</module>
</modules>
Dao Child Module:
<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>com.netsol</groupId>
<artifactId>empirecl</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>empirecl-dao</artifactId>
<packaging>jar</packaging>
<name>empirecl-dao</name>
------------------------
Service Child Module:
<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>com.netsol</groupId>
<artifactId>empirecl</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>empirecl-service</artifactId>
<packaging>jar</packaging>
<name>empirecl-service</name>
<dependencies>
<dependency>
<groupId>com.netsol</groupId>
<artifactId>empirecl-dao</artifactId>
<version>0.0.1-SNAPSHOT</version>
<type>jar</type>
</dependency>
------------------------------------------
The Dao module maven clean and install successfully, but when i trying to use service module, it will generate an following exception:
[ERROR] Failed to execute goal on project empirecl-service: Could not resolve dependencies for project com.netsol:empirecl-service:jar:0.0.1-SNAPSHOT: Failed to collect dependencies at com.netsol:empirecl-dao:jar:0.0.1-SNAPSHOT: Failed to read artifact descriptor for com.netsol:empirecl-dao:jar:0.0.1-SNAPSHOT: Could not find artifact com.netsol:empirecl:pom:0.0.1-SNAPSHOT -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal on project empirecl-service: Could not resolve dependencies for project com.netsol:empirecl-service:jar:0.0.1-SNAPSHOT: Failed to collect dependencies at com.netsol:empirecl-dao:jar:0.0.1-SNAPSHOT
I am trying the find to solution from web, but still the solution is not found. In eclipse when i open the Dependency Hierarchy of service module, it shown the DAO module as a folder not jar. below is the screen shot of Dependency Hierarchy of service module.
In case anybody comes back to this, I think the problem here was failing to install the parent pom first, which all these submodules depend on, so the Maven Reactor can't collect the necessary dependencies to build the submodule.
So from the root directory (here D:\luna_workspace\empire_club\empirecl) it probably just needs a:
mvn clean install
(Aside: <relativePath>../pom.xml</relativePath> is not really necessary as it's the default value).
In my case I forgot it was packaging conflict jar vs pom. I forgot to write
<packaging>pom</packaging>
In every child pom.xml file
My solution was to insert <packaging>pom</packaging> between artifactId and version
<groupId>com.onlinechat</groupId>
<artifactId>chat-online</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<modules>
<module>server</module>
<module>client</module>
<module>network</module>
</modules>
This what worked for me -
Go to Java build path --> Order and Export(check JRE system libraries and maven dependencies) in my case these 2 were unchecked.
My solution:
remove all projects in current workspace
import all again
maven update project (Alt + F5) -> Select All and check Force Update of Snapshots/Releases
maven build (Ctrl + B) until there is nothing to build
It worked for me after the second try.
For me, adding the following block of code under <dependency management><dependencies> solved the problem.
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.el</artifactId>
<version>3.0.1-b06</version>
</dependency>
Check with your VPN connection, if you are working in home.
Delete or close all other projects, and restart netbeans IDE, and try again.

Categories