The POM for project is missing, no dependency information available - java

Background
Trying to add a Java library to the local Maven repository using a clean install of Apache Maven 3.1.0, with Java 1.7. Here is how the Java archive file was added:
mvn install:install-file \
-DgroupId=net.sourceforge.ant4x \
-DartifactId=ant4x \
-Dversion=0.3.0 \
-Dfile=ant4x-0.3.0.jar \
-Dpackaging=jar
This created the following directory structure:
$HOME/.m2/repository/net/sourceforge/ant4x/
├── 0.3.0
│ ├── ant4x-0.3.0.jar.lastUpdated
│ └── ant4x-0.3.0.pom.lastUpdated
└── ant4x
├── 0.3.0
│ ├── ant4x-0.3.0.jar
│ ├── ant4x-0.3.0.pom
│ └── _remote.repositories
└── maven-metadata-local.xml
The project's pom.xml file references the dependent project (the tree above) as follows:
<properties>
<java-version>1.5</java-version>
<net.sourceforge.ant4x-version>0.3.0</net.sourceforge.ant4x-version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
...
<dependency>
<groupId>net.sourceforge</groupId>
<artifactId>ant4x</artifactId>
<version>${net.sourceforge.ant4x-version}</version>
<scope>provided</scope>
</dependency>
Problem
After running mvn compile, the following error was returned (full log on Pastebin):
[ERROR] Failed to execute goal on project ant4docbook: Could not resolve dependencies for project net.sourceforge:ant4docbook:jar:0.6-SNAPSHOT: Failure to find net.sourceforge:ant4x:jar:0.3.0 in http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced -> [Help 1]
The documentation notes a number of issues that could be present, however none of these appear to apply.
Ideas
I tried the following, as per the documentation:
Copy default settings to user's home directory for Maven:
cp /opt/apache-maven-3.1.0/conf/settings.xml $HOME/.m2/.
Edit the user's settings.xml file.
Update the value for the local repository:
${user.home}/.m2/repository
Save the file.
I also tried the following commands:
mvn -U
mvn clear -U
I tried using Maven 3.0.5, but that failed, too.
Question
How do you force Maven to use the local version of the library, rather than trying to seek out a library that is not yet available to download?
Related
Related questions and information that did not resolve the issue:
The POM for org.springframework.security:org.springframework.security.web:jar:3.0.5.RELEASE is missing, no dependency information available
How can I locate the POM which requests a missing POM?
Maven: Including jar not found in public repository
http://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html
http://giallone.blogspot.ca/2012/12/maven-install-missing-offline.html

Change:
<!-- ANT4X -->
<dependency>
<groupId>net.sourceforge</groupId>
<artifactId>ant4x</artifactId>
<version>${net.sourceforge.ant4x-version}</version>
<scope>provided</scope>
</dependency>
To:
<!-- ANT4X -->
<dependency>
<groupId>net.sourceforge.ant4x</groupId>
<artifactId>ant4x</artifactId>
<version>${net.sourceforge.ant4x-version}</version>
<scope>provided</scope>
</dependency>
The groupId of net.sourceforge was incorrect. The correct value is net.sourceforge.ant4x.

The scope <scope>provided</scope> gives you an opportunity to tell that the jar would be available at runtime, so do not bundle it. It does not mean that you do not need it at compile time, hence maven would try to download that.
Now I think, the below maven artifact do not exist at all. I tries searching google, but not able to find. Hence you are getting this issue.
Change groupId to <groupId>net.sourceforge.ant4x</groupId> to get the latest jar.
<dependency>
<groupId>net.sourceforge.ant4x</groupId>
<artifactId>ant4x</artifactId>
<version>${net.sourceforge.ant4x-version}</version>
<scope>provided</scope>
</dependency>
Another solution for this problem is:
Run your own maven repo.
download the jar
Install the jar into the repository.
Add a code in your pom.xml something like:
Where http://localhost/repo is your local repo URL:
<repositories>
<repository>
<id>wmc-central</id>
<url>http://localhost/repo</url>
</repository>
<-- Other repository config ... -->
</repositories>

Related

Maven dependency version

When doing a mvn clean install -U I am getting:
[ERROR] Failed to execute goal on project xxx-security: Could not resolve dependencies for project xxx:xxx-security:jar:50-SNAPSHOT: Failed to collect dependencies at
xxx:xxx-persistence:jar:50-SNAPSHOT -> org.mybatis:mybatis:jar:${mybatis.version}: Failed to read artifact descriptor for org.mybatis:mybatis:jar:${mybatis.version}: Could not
transfer artifact org.mybatis:mybatis:pom:${mybatis.version} from/to nexus (http://example.net/repository/Standard/): Failed to transfer file: http://example.net/repository/Stan
dard/org/mybatis/mybatis/$%7Bmybatis.version%7D/mybatis-$%7Bmybatis.version%7D.pom. Return code is: 400 , ReasonPhrase:Invalid repository path. -> [Help 1]
What I don't get is why maven is using mybatis.version in the url to get the dependency rather than a version number. I have searched the code and cannot find mybatis.version in there. I did find:
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.0.4</version>
</dependency>
So why is maven using mybatis.version rather than 3.0.4?
It looks like your xxx:xxx-persistence:jar:50-SNAPSHOT jar has internal dependency with org.mybatis:mybatis:jar:${mybatis.version}. Provided that you define mybatis.version in your properties.
You can do following:
Execute mvn dependency:tree to check which specific jar has this dependency.
Also define <mybatis.version>3.0.4</mybatis.version> under <properties> section of pom.xml. You can optionally remove <version>3.0.4</version> from your <dependency> section where you defined mybatis dependency.

Checksum validation failed in maven due to PART files with Java 11

Background
I am using Java 11.0.3, Maven 3.6.2 and com.github.seahen.maven-s3-wagon 1.3.1.
I am using an s3 bucket as a maven repository. I have an internal jar artifact called dbclasses. I deploy dbclasses to the s3 maven repository using mvn source:jar deploy.
I have a different maven project called secapps which uses the dbclasses artifact. Here is the relevant configuration related to the s3 bucket and the artifact in the secapps pom file
<repositories>
<repository>
<id>maven.nuvalence.repo.release</id>
<url>s3://ec-appdev-mvn-repo/release</url>
</repository>
<repository>
<id>maven.nuvalence.repo.snapshot</id>
<url>s3://ec-appdev-mvn-repo/snapshot</url>
</repository>
</repositories>
<build>
<extensions>
<extension>
<groupId>com.github.seahen</groupId>
<artifactId>maven-s3-wagon</artifactId>
<version>1.3.1</version>
</extension>
</extensions>
</build>
<dependencies>
<dependency>
<groupId>edu.excelsior</groupId>
<artifactId>dbclasses</artifactId>
<version>0.0.1</version>
</dependency>
</dependencies>
Issue
Whenever I run a mvn clean package on secapps it throws the following warning
[INFO] Downloading from maven.nuvalence.repo.release: s3://ec-appdev-mvn-repo/release/edu/excelsior/dbclasses/0.0.1/dbclasses-0.0.1.pom
[INFO] Logged in - ec-appdev-mvn-repo
[INFO] Downloading: s3://ec-appdev-mvn-repo/release/edu/excelsior/dbclasses/0.0.1/dbclasses-0.0.1.pom
[INFO] Downloading: s3://ec-appdev-mvn-repo/release/edu/excelsior/dbclasses/0.0.1/dbclasses-0.0.1.pom.sha1
[WARNING] Checksum validation failed, expected but is 38790b95f185a41908a1767ae2ad2b5bfe436773 from maven.nuvalence.repo.release for s3://ec-appdev-mvn-repo/release/edu/excelsior/dbclasses/0.0.1/dbclasses-0.0.1.pom
[INFO] Downloading: s3://ec-appdev-mvn-repo/release/edu/excelsior/dbclasses/0.0.1/dbclasses-0.0.1.pom
[INFO] Downloading: s3://ec-appdev-mvn-repo/release/edu/excelsior/dbclasses/0.0.1/dbclasses-0.0.1.pom.sha1
[WARNING] Could not validate integrity of download from s3://ec-appdev-mvn-repo/release/edu/excelsior/dbclasses/0.0.1/dbclasses-0.0.1.pom: Checksum validation failed, expected but is 38790b95f185a41908a1767ae2ad2b5bfe436773
[WARNING] Checksum validation failed, expected but is 38790b95f185a41908a1767ae2ad2b5bfe436773 from maven.nuvalence.repo.release for s3://ec-appdev-mvn-repo/release/edu/excelsior/dbclasses/0.0.1/dbclasses-0.0.1.pom
[INFO] Downloaded from maven.nuvalence.repo.release: s3://ec-appdev-mvn-repo/release/edu/excelsior/dbclasses/0.0.1/dbclasses-0.0.1.pom (4.7 kB at 2.8 kB/s)
[INFO] Logged off - ec-appdev-mvn-repo
You'll notice that it says Checksum validation failed, expected but is 38790b95f185a41908a1767ae2ad2b5bfe436773
In other words, the expected checksum is 38790b95f185a41908a1767ae2ad2b5bfe436773, but you've given me blank.
So I looked at the local repository and I see the following
You'll notice the following two things for each file
For the pom and jar files there is an associated .part file
the .part file contains all the data, but the non the actual files are empty
If the .part files are renamed to remove the .partXXXX everything works fine. But for some reason every time I try to build it keeps the .part files and leaves the normal files at 0K
Question
What are these .part files and why are my normal files 0K? How do I resolve this?
Attempts
I have tried many things including
Manually deleting the dependency from my local repository
Redeploying the dependency to s3
Setting checksumPolicy to warning
Setting updatePolicy to always
However, none of these seem to work. Does anyone have a solution for this? All the other dependencies from Maven central pull down fine. None of the dependencies form s3 work
Answer
It looks like maven-s3-wagon doesn't play well with Java 11. I swapped out the maven-s3-wagon wagon for the aws-maven wagon and it resolved my issue
Prior wagon
<extension>
<groupId>com.github.seahen</groupId>
<artifactId>maven-s3-wagon</artifactId>
<version>1.3.1</version>
</extension>
New Wagon
<extension>
<groupId>com.github.platform-team</groupId>
<artifactId>aws-maven</artifactId>
<version>6.0.0</version>
</extension>
You can use the latest version of seahen s3 wagon 1.3.3 because the previous versions of seahen wagon doesn't work properly with newest java versions. And also you need to add the suitable dependency to work that wagon properly.
Add following wagon and dependency to pom.xml, delete all the previous builds in m2 as well as github file in m2 and try to reload project. That will resolve issue.
Wagon
<extension>
<groupId>com.github.seahen</groupId>
<artifactId>maven-s3-wagon</artifactId>
<version>1.3.3</version>
</extension>
Dependency
<dependency>
<groupId>com.github.seahen</groupId>
<artifactId>maven-s3-wagon</artifactId>
<version>1.3.3</version>
</dependency>
For further reference follow these links
https://github.com/seahen/maven-s3-wagonhttps://mvnrepository.com/artifact/com.github.seahen/maven-s3-wagon/1.3.3

Could not find artifact (snapshot) in Nexus repository

I installed the Nexus repository in my notebook, then upload a snapshot project in it. This is how it looks:
Now, I'm trying to build a Docker image, with another project that has the previous project as a dependency. This is my Dockerfile:
FROM maven:3.5.2-jdk-8-alpine AS MAVEN_BUILD
COPY settings.xml /usr/share/maven/ref/
COPY pom.xml /build/
RUN echo $(route -n | awk '/UG[ \t]/{print $2}')
RUN sed -i "s/localhost/$(route -n | awk '/UG[ \t]/{print $2}')/g" /build/pom.xml
COPY src /build/src/
WORKDIR /build/
RUN mvn package -DskipTests=true
# Other stuff that doesn't matter...
I've added this lines to pom.xml to resolve dependencies from Nexus (locahost is replaced (see Dockerfile) with docker gateway IP):
<repositories>
<repository>
<id>maven-group</id>
<url>http://localhost:8081/repository/maven-group/</url>
</repository>
</repositories>
It works as expected until maven needs to dowload my own library dependecy, the one uploaded to Nexus, failing with the message:
[ERROR] Failed to execute goal on project springboot-servicio-producto: Could not resolve dependencies for project com.abarazal.springboot.app.producto:springboot-servicio-producto:jar:0.0.1-SNAPSHOT: Could not find artifact com.abarazal.springboot.app.commons:springboot-servicio-commons:jar:0.0.1-SNAPSHOT in maven-group (http://172.17.0.1:8081/repository/maven-group/) -> [Help 1]
In pom.xml the dependency is declared as:
<dependency>
<groupId>com.abarazal.springboot.app.commons</groupId>
<artifactId>springboot-servicio-commons</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
What am I missing to make it work?
Check if you have more than 10% free disk space.
This may be an issue caused by elastic search.

Dependency error in eclipse project making use of Maven

I am using Eclipse Mars to run my Java project. I am making use of Maven in it. But while trying to compile my package I am getting the following error.
Failed to execute goal on project apex-check: Could not resolve dependencies for project org.fundacionjala.enforce.sonarqube:apex-check:jar:1.0: Failed to collect dependencies at org.fundacionjala.enforce.sonarqube:apex-squid:jar:1.0: Failed to read artifact descriptor for org.fundacionjala.enforce.sonarqube:apex-squid:jar:1.0: Could not transfer artifact org.fundacionjala.enforce.sonarqube:apex-squid:pom:1.0 from/to central (https://repo.maven.apache.org/maven2): Failed to authenticate with proxy -> [Help 1].
I am able to find that my pom.xml has a bug in its dependency. But don't know how to resolve it. I have given below my pom.xml file
<?xml version="1.0" encoding="UTF-8"?>
<!-- ~ Copyright (c) Fundacion Jala. All rights reserved. ~ Licensed under the MIT license. See LICENSE file in the project root for full license information. -->
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.fundacionjala.enforce.sonarqube</groupId>
<artifactId>apex</artifactId>
<version>1.0b${build.number}</version>
</parent>
<artifactId>apex-check</artifactId>
<name>Apex :: Checks</name>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>apex-squid</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>
I have written 'apex-check' and 'apex-squid' as two separate projects.
Can anyone explain how to correct my pom.xml?
You need to have:
org.fundacionjala.enforce.sonarqube:apex-check:jar:1.0
org.fundacionjala.enforce.sonarqube:apex-squid:jar:1.0
jar files available in your local .m2/repository folder. If they are not present maven will try to download from central repository and as an expected result it will fail on firewall or it will not find the artifact. i.e. if:
apex-check requires apex-squid project as dependency first you need to install squid project files by using mvn install on squid project folder.
But it seems more like you want to create a multi module maven project, take a look at this question. Create a parent project similar to this project, add check and squid as module and run mvn clean install on parent.
**edit: I just see you already have parent, so make sure parent has your projects as modules, which helps reactive build order and eclipse imports

NoClassDefFoundError when importing Tika 1.13 in Eclipse

I've done the following steps per the tika guide:
Add the tika-core and tika-parser dependencies to the pom.xml of the maven project
Run maven install from eclipse to produce tika-core jar and tika-parser jar
Add tika-core jar and tika-parser jar to my eclipse project build path
And I get this runtime exception when trying to run tika:
Exception in thread "main" java.lang.NoClassDefFoundError: org.apache.pdfbox.pdmodel.encryption.InvalidPasswordException
at com.ibm.hrl.ace.pdftotext.TikaExtracter.parse(TikaExtracter.java:33)
at com.ibm.hrl.ace.pdftotext.Main.AllPdfsToText(Main.java:116)
at com.ibm.hrl.ace.pdftotext.Main.main(Main.java:34)
Caused by: java.lang.ClassNotFoundException: org.apache.pdfbox.pdmodel.encryption.InvalidPasswordException
at java.net.URLClassLoader.findClass(URLClassLoader.java:600)
at java.lang.ClassLoader.loadClassHelper(ClassLoader.java:786)
at java.lang.ClassLoader.loadClass(ClassLoader.java:760)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:326)
at java.lang.ClassLoader.loadClass(ClassLoader.java:741)
... 3 more
As far as I can see, when I build the jars using maven, it does add pdfbox properly... from the build log:
[INFO] Including org.apache.pdfbox:pdfbox:jar:2.0.1 in the shaded jar.
[INFO] Including org.apache.pdfbox:fontbox:jar:2.0.1 in the shaded jar.
[INFO] Including org.apache.pdfbox:pdfbox-tools:jar:2.0.1 in the shaded jar.
[INFO] Including org.apache.pdfbox:pdfbox-debugger:jar:2.0.1 in the shaded jar.
[INFO] Including org.apache.pdfbox:jempbox:jar:1.8.12 in the shaded jar.
And here are my maven dependencies:
<dependencies>
<!-- https://mvnrepository.com/artifact/org.apache.tika/tika-core -->
<dependency>
<groupId>org.apache.tika</groupId>
<artifactId>tika-core</artifactId>
<version>1.13</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.tika/tika-parsers -->
<dependency>
<groupId>org.apache.tika</groupId>
<artifactId>tika-parsers</artifactId>
<version>1.13</version>
</dependency>
</dependencies>
The problem is that if you manually add tika-core and tika-parsers jars in your build path you will not have the transitive dependencies that are listed in their own POM.
So I would suggest to:
Remove the tika-core and tika-parsers version that you have built yourself. Instead you should rely on the versions that are available on central. This will ensure that another one building your project will get the same jar (and not a locally built one)
You have two options
(Option A, use Maven) Do not add manually into Eclipse build path the jars. Rely either or built-in Maven plugin for Eclipse (m2e for instance) or use Eclipse plugin for maven (call mvn eclipse:eclipse to update .classpath and .project).
(Option B, without Maven) If you cannot use Maven for your project, you will have to add not only tika-parsers and tika-core jars, but all (most of) the transitive dependencies needed by these project (including for instance specific library per format [POI for Office, pdfbox for PDF...). You can get a list of the dependencies by typing mvn dependency:list in the folder containing the pom of tika-parsers.

Categories