Maven: Failed to read artifact descriptor for - java

I am writing project in Java using Maven for dependecines and I put on my own maven server lib for client api maven#server:~/public/com/iggroup/publicapi/client/java/api-client-sdk-2.0.5.jar and created in the same location .pom file which looks like below
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.iggroup.publicapi.client.java</groupId>
<artifactId>api-client-sdk</artifactId>
<version>2.0.5</version>
</project>
... and in my project pom.xml file I add dependency
<dependency>
<groupId>com.iggroup.publicapi.client.java</groupId>
<artifactId>api-client-sdk</artifactId>
<version>2.0.5</version>
</dependency>
Maven was refreshed, found correct version but can't load this lib and shows Failed to read artifact descriptor for com.iggroup.publicapi.client.java:api-client-sdk:jar:2.0.5
Lib is OK but maybe I do something wrong with name file, paths or my pom ?
Any idea ?

I found solution. Path in server was wrong, should looks like below:
maven#server:~/public/com/iggroup/publicapi/client/java/api-client-sdk/2.0.5/api-client-sdk-2.0.5.jar

Related

Error while reading JAR from my Remote Repository [Dropbox as Maven Repository]

So I created my own remote repository with Dropbox following this tutorial. Further, I used the following command to deploy 3rd party JARS to my repository.
mvn deploy:deploy-file -DgroupId=com.prowritingaid.java -DartifactId=pro_writing_aid_java -Dversion=2.0.0 -Dpackaging=jar -Dfile=pro_writing_aid_java-2.0.0.jar -Durl=file:/home/de-10/Dropbox/ProWritingAid
The deployment was successful and it successfully synchronised with Dropbox as well. But now when I try to refer to these jars via pom.xml, it isn't working.
I added the Dropbox URL to my repositories list:
<repository>
<id>ProWritingAid</id>
<name>Remote ProWritingAid Repository</name>
<url>https://www.dropbox.com/sh/fbv...</url>
</repository>
and I've defined the dependencies like:
<!-- Keshavram Kuduwa's Dropbox Repository -->
<dependency>
<groupId>com.prowritingaid.java</groupId>
<artifactId>pro_writing_aid_java</artifactId>
<version>2.0.0</version>
</dependency>
<!-- Keshavram Kuduwa's Dropbox Repository -->
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>logging-interceptor</artifactId>
<version>2.7.5</version>
</dependency>
The compile-time error is:
Description Resource Path Location Type
Archive for required library: '/home/de-10/.m2/repository/com/prowritingaid/java/pro_writing_aid_java/2.0.0/pro_writing_aid_java-2.0.0.jar' in project 'papertrue' cannot be read or is not a valid ZIP file papertrue Build path Build Path Problem
But on the other hand, when I install these packages locally with the following, it works:
mvn install:install-file -DgroupId=com.prowritingaid.java -DartifactId=pro_writing_aid_java -Dversion=2.0.0 -Dpackaging=jar -Dfile=pro_writing_aid_java-2.0.0.jar
Moreover, if I delete these locally installed packages and force update the project, the error shows up again. I also replaced the JAR in the remote repository but it didn't help.
The Jar I was deploying didn't have a pom.xml file and hence the error. I tried something different, to use an in-project repository -> Creating an In-Project Maven Repository and deploying 3rd party JARs to it.

Cucumber without Maven

We are not Maven yet, and I’m trying to run a cucumber feature. Getting the below error.
java.lang.NoClassDefFoundError: org.picocontainer.PicoBuilder at
cucumber.runtime.java.picocontainer.PicoFactory.start(PicoFactory.java:17)
Below is my folder structure for src.
src
test.java.stepdefinition.holiday
Myholiday_StepDef.java
MyRunner.java
test.resources.features
holiday.feature
Add Jar file of “PicoContainer Core” to build path of your project if you are using java project.
You can use maven dependency for “PicoContainer Core” to your pom.xml (for Maven project) as mentioned below.
<dependency>
<groupId>org.picocontainer</groupId>
<artifactId>picocontainer</artifactId>
<version>2.14.1</version>
</dependency>

Compilation error with maven

I have a compilation error in one of my projects
Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile
because it does not find all the classes from another project that I already included using
<dependency>
<groupId>com.laberint</groupId>
<artifactId>laberint-core</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
and I don't have any compilation problems from Eclipse. I already deleted all the repository.
The errors are because a missing classes that all are in the laberint-core artifact. I already deleted the whole repository folder
I also installed the jar
mvn install:install-file -Dfile=laberint-core-0.0.1-SNAPSHOT.jar -DgroupId=com.laberint -DartifactId=laberint-core -Dversion=0.0.1-SNAPSHOT -Dpackaging=jar
Simply create a jar from your another project and add it in local lib directory of your current project. Another option is install the jar file in to your local maven repository like below:-
mvn install:yourlocal-jarfile
-Dfile=<path-to-your jar>
-DgroupId=<group-id> --> the group that the file should be registered under
-DartifactId=<artifact-id> --> give a artifact name to your jar
-Dversion=<version> --> version of your jar file
-Dpackaging=<packaging> --> jar
-DgeneratePom=true
Also you can try with below option:-
<dependency>
<groupId>com.laberint</groupId>
<artifactId>laberint-core</artifactId>
<version>0.0.1-SNAPSHOT</version>
<systemPath>/pathto/yourJar.jar</systemPath>
</dependency>
Hope this will help your. Good Luck!!!
As you stated in your comment you are developing the laberint-core project in the same Eclipse workspace as the project you are trying to build. The problem you have is that while Eclipse knows each project in your workspace and can resolve those project dependencies, Maven does not have this Information which means that it searches the repositories (your local one in ~/.m2 and Maven Central) for the dependency.
As you said, you have already installed the laberint-core project to your local Maven repository via mvn install. That's why Maven can find the dependency at all and you do not get a dependency could not be resolved exception but I would guess that you installed the dependency some time ago and so some of the classes that your created in the Eclipse project after installing are missing.
There are two ways how you can resolve this issue
Create and install the dependency jar each time before you build the main project
This means some more manual overhead when you are building the main project but it can be automated if you are only building in Eclipse and not directly from the command line.
Create an aggregator project as shown here.
This would basically be a third project that consists only of a pom.xml file that looks somewhat 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
https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.laberint</groupId>
<artifactId>aggregator</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>relative/path/to/laberint-core</module>
<module>relative/path/to/laberint-main</module>
</modules>
</project>
To build the project you would then call the goals you called on the main project before on the aggregator project. Basically if you called mvn package before from the root directory of the main project you would now change to the root directory of the aggregator project and call mvn package. By convention the aggregator pom should lay in the parent directory of its modules.

class import not resolved on external jars installed in maven local repository

I am using maven 3.2.5. I have one external jars which I need to use in my maven project which is not available in maven repository.
I installed those jars by using following command:
1) mvn install:install-file -Dfile=p-unit-0.15.319.jar -DgroupId=org.punit -DartifactId=p-unit -Dversion=0.15.319 -Dpackaging=jar
2) After this command, I saw in my M2 repository, jar & pom was created
.m2\repository\org\punit\p-unit\0.15.319\p-unit-0.15.319.jar
.m2\repository\org\punit\p-unit\0.15.319\p-unit-0.15.319.pom
created pom content:
<?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>
<groupId>org.punit</groupId>
<artifactId>p-unit</artifactId>
<version>0.15.319</version>
<description>POM was created from install:install-file</description>
</project>
3) Updated the pom file
<dependency>
<groupId>org.punit</groupId>
<artifactId>p-unit</artifactId>
<version>0.15.319</version>
<scope>provided</scope>
</dependency>
Issue: When I tried to use class of this jar,
import org.punit.runner.*;
getting error: import org.punit.runner can't be resolved.
I tried many combination to define the dependency but not able to use the classes.
How can I resolve it??
Add the corresponding dependency to the pom.xml file of your project under the tag dependencies.
Example :
<dependencies>
<dependency>
<groupId>org.punit</groupId>
<artifactId>p-unit</artifactId>
<version>0.15.319</version>
<scope>test</scope>
</dependency>
</dependencies>
Note : assuming the group,artifact ids and version are correct as mentioned in the question.
One thing which I missed, I am mentioning here, which solved this issue.
I had put the dependency in wrong profile which was not called during my compilation.
When I put in correct profile it worked.
Second option:
We can directly add external jar through eclipse:
Properties -> Java Build Path -> Libraries -> Add External Jars.
and locate the library on the file system.
Answer to similar query:
The import org.junit cannot be resolved

Adding dependent project's properties file to the build target folder in Maven

I'm new to Maven, have looked for some help with my problem but couldn't find a proper solution.
I have a main project in Maven, which has a dependency to my second project:
<dependency>
<groupId>a.b.c</groupId>
<artifactId>childproject</artifactId>
<version>1.1</version>
</dependency>
Both projects have their properties files: mainproject.properties, childproject.properties.
When I deploy the main project, childproject.jar goes to \lib folder, along with all other dependencies. But the childproject.properties is "build into" the childproject.jar. If I place another childproject.properties file next to mainproject.properties in \configuration folder, it is seen and used.
What could I do so Maven places childproject.properties automatically in the \configuration folder?
childproject.properties
pom mainproject has :
<dependency>
<groupId>a.b.c</groupId>
<artifactId>childproject</artifactId>
<version>1.1</version>
</dependency>
And add file in :
mainproject
/src/main/resources/mainproject.properties
childproject , add file in:
childproject
/src/main/resources/childproject.properties
When you deploy the main project => childproject.jar contain in classpath childproject.properties
You do not need to create a directory 'configuration' for the project 'mainproject' uses 'childproject.properties'.

Categories

Resources