What is causing ArtifactNotFoundException in anypoint maven? - java

I am trying to create new connector using mulesoft sdk. The connector has been successfully created and and loaded into the internal maven repository. When I try to reference the connector in the anypoint project, I get
Caused by: org.eclipse.aether.transfer.ArtifactNotFoundException: Failure to find org.demo.cloud:mule-connector:pom:1.0.0 in https://maven.anypoint.mulesoft.com/api/v2/maven was cached in the local repository, resolution will not be reattempted until the update interval of anypoint-exchange-v2 has elapsed or updates are forced
When I run the maven cmd in the command line, there are no errors. But as soon as I add dependency in the anypoint project pom file, I get the error. What could be wrong?

It looks like the Mule application project is trying to reference the connector reference with an incorrect Maven classifier. It should be a mule-plugin but the error message implies it is pom.
Example:
<dependency>
<groupId>org.demo.cloud</groupId>
<artifactId>mule-connector</artifactId>
<version>1.0.0</version>
<classifier>mule-plugin</classifier>
</dependency>

I faced similar issue before. I would like to add some extras to the existing answer.
The misuse of classifiers can happen when you try to pull artifacts from maven central without knowing what type of packaging type the artifact is made of during its maven release phase.
mvn release:clean
mvn release:prepare
mvn release:perform
Observe that when you add something as mule-plugin as a classifier in your dependency. It will add the connector plugin in your mule package explorer on the left hand side. This may not still resolve the pom unavailability problem you have pasted in the question.
I also believe that org.demo.cloud is an groupId not an artifact ID. Nevertheless, your application might not be a true mule-plugin based on its pom declaration.
Try packaging your main APP-1 (in maven central) as a mule-plugin in the APP-1 pom file. If not, simply put the packaging as jar type and republish your artifacts. Later, don't mention the classifier section in your APP-2. Simply call the direct dependency.
Check my other answer in here.:Unable to reference to DWL script files in Mule 4 dataweave from Project Libraries(jar)

Related

Maven eclipse error: "Archive for required library cannot be read or is not a valid ZIP file"

I got the "Archive for required library cannot be read or is not a valid ZIP file" error for my maven project I imported in Eclipse. I read some posts about this and suggested is to delete the faulty directory like in my case:
~.m2\repository\com\cogentex\rpw\2.2 and
~.m2\repository\com\cogentex\rpw-lkb\2.2
Then you should update the project via Eclipse: Maven>Update project and click force update of snapshots/releases.
I followed these steps and the directory looks like this now:
So the correct .jar files are still missing and it also results in more erorrs now:
1: Missing artifact com.cogentex:rpw-lkb:jar:2.2
2: Missing artifact com.cogentex:rpw:jar:2.2
3: The container 'Maven Dependencies' references non existing library '~.m2\repository\com\cogentex\rpw\2.2\rpw-2.2.jar'
Here is the snippet from the pom.xml which throws the first two errors:
<dependency>
<groupId>com.cogentex</groupId>
<artifactId>rpw</artifactId>
<version>2.2</version>
</dependency>
<dependency>
<groupId>com.cogentex</groupId>
<artifactId>rpw-lkb</artifactId>
<version>2.2</version>
</dependency>
What do I have to do to make maven download the correct .jar files? I already tried running maven cleanor maven install and restarting Eclipse.
What you see in the folder is some files that indicate the artifact was not found and when was the last time Maven checked.
Whatever com.cogentex:rpw is, it's not in Maven Central so Maven will not find it there. You need to tell Maven where to get it from by providing the URL to a repository that contains it. If/when your POM has the repository, make sure
you do have access to the reposiory from the environment you run your build in (check proxies, firewalls, ...)
the GAV coordinates (groupId, artifactId, version) are correct and match the one in the repository.
the artifact type in the repository is jar. If it is not, provide the correct type in the dependency
the artifact is not deployed to the repository with classifier. If it is, provide the classifier in the dependency

maven can't get dependency from transitive repository (sometimes)

I have following problem which sounds pretty crazy. I have a project A, which uses Lib B which uses Lib C. Lib C isn't in central. Lib B has a parent which defines a repository in which lib C can be found.
Depending on mvn version and maybe some other spices it works or not.
The project is question is MoSKito: https://github.com/anotheria/moskito. MoSKito has a dependency to xchart (com.xeiam.xchart:xchart 2.5.0). xchart uses VectorGraphics2D (de.erichseifert.vectorgraphics2d:VectorGraphics2d:0.9.1). VectorGraphics2D is not in central.
xchart has defined VectorGraphics2D's dependency in its parent (com/xeiam/xchart/xchart-parent/2.5.0/xchart-parent-2.5.0.pom):
<repositories>
<repository>
<id>erichseifert.de</id>
<url>http://mvn.erichseifert.de/maven2</url>
</repository>
</repositories>
Now back to original problem: When I build MoSKito on my machine VectorGraphics2D is downloaded from http://mvn.erichseifert.de/maven2. I see it in my build log and also it is present in repository and the file _remote.repositories contains following content:
#NOTE: This is an Aether internal implementation file, its format can be changed without prior notice.
#Wed Oct 28 16:18:30 CET 2015
VectorGraphics2D-0.9.1.jar>erichseifert.de=
VectorGraphics2D-0.9.1.pom>erichseifert.de=
If someone else builds MoSKito the file is not downloaded and the error message is
[ERROR] Failed to execute goal on project moskito-webui: Could not resolve
dependencies for project net.anotheria:moskito-webui:jar:2.6.4-SNAPSHOT: Failure
to find de.erichseifert.vectorgraphics2d:VectorGraphics2D:jar:0.9.1 in
http://nexus.locale/nexus/content/groups/provided was cached in the local
repository, resolution will not be reattempted until the update interval of nexus
has elapsed or updates are forced -> [Help 1]
Is there any settings which can be made to resolve this issue, so it is at least deterministic?
P.S. whoever marked this question as duplicate of maven force update dependencies question, it has nothing to do with dependencies update. It is about maven resolving an artifact from a repository which is specified in a referenced project. Sometimes it works and sometimes it doesn't.
Ok, I found it out, and posting the answer here for traces. The system which couldn't download the artifact had an active mirror in their settings.xml with
<mirrorOf>*</mirrorOf>
This prevented mvn to download artifact from linked repository, and the mirror didn't now what's happening and couldn't download the artifact. We solved the issue in two ways (two different machines):
1) change mirrorOf from * to central
2) Manually upload the artifact as 3rd party artifact in the mirror nexus (proxy would do it too, probably)
Thank you and good luck ;-)

Can a pom file uploaded to a remote repository via mvn deploy have a classifier in its name?

Can a pom file uploaded to a remote repository via mvn deploy have a classifier in its name?
For example, if I have artifacts Webapp-1.0.war and Webapp-1.0-CLASSIFIER.war can I easily have Webapp-1.0.pom and Webapp-1.0-CLASSIFIER.pom?
I'd like to be able to deploy artifacts with multiple classifiers to the same repository, but the mvn deploy goal always fails because it's trying to upload a pom that's already there.
I don't want to use mvn deploy:deploy-file if I can avoid it because I don't want to unnecessarily complicate my CI build, i.e., having to specify file/url as configuration parameters because the file and url will change depending on whether I'm deploying a snapshot/release version.
Your problem is the understanding of Maven. If you produce an artifact which has an classifier it means having a pom which describes creating the artifact with the classifier as well as an artifact without an classifier. In other words your problem can be solved by having a single pom file. Furthermore you can deploy an artifact and several artifacts with classifiers with a single call to the maven-dependency-plugin call like the following:
mvn deploy:deploy-file
-DgroupId=com.soebes.test
-DartifactId=x1
-Dversion=2.7.5-SNAPSHOT
-Dfile=TheMainArtifact.jar
-Dclassifiers=first,second
-Dfiles=firstFile,secondFile
-Dtypes=zip,xml
-DrepositoryId=RepositoryId
-Durl=URLOfTheRepository
With the above (into a single line) you can deploy several files with a single deploy command without changing the configuration of Neuxs or any other repository manager to allow redeploying (wrong way!).
I've run into this before too. As far as I know, classified POMs aren't allowed.
The trick is to configure the remote repo to allow the POM to be updated while not allowing redeploy of other artifacts.
In Nexus, this is done through Repository Targets. The pattern to match POMs in a repository is .*/(?!.*\.pom).*. The target gets linked to Privileges, which may be assigned to Roles, which are then assigned to Users. (Memory is a little fuzzy here, I got this working and then decided to use deploy:deploy-file instead.)
There's no such thing as a classified pom. For every groupId + artifactId + version there's exactly one pom, and this pom is also used for the attached/classified artifacts. So this means that for instance that the main artifact and all the attached artifacts have the same dependencies.
Most used attached artifacts are javadoc and sources, for which this makes perfectly sense.

Maven not able to download dependency

I have started working on a new project using Maven, and I'm unable to have it work properly on eclipse. I have multiples of this error :
ArtifactTransferException: Failure to transfer com.caucho:hessian:jar:3.1.5 from <repository> was cached in the local repository, resolution will not be reattempted until the update interval of Archiva SIVPN Internal has elapsed or updates are forced. Original error: Could not transfer artifact com.caucho:hessian:jar:3.1.5 from/to Archiva SIVPN Internal (<repository>): No response received after 60000 pom.xml /<file> line 2 Maven Dependency Problem
Description Resource Path Location Type
Missing artifact com.caucho:hessian:jar:3.1.5 pom.xml / line 2 Maven Dependency Problem
After doing some research, I found that it was probably either the pom.xml that's wrong, or that I have proxy problems.
I checked that the resource was available on our repository, and that the pom snippet is the same as declared in my code :
<dependency>
<groupId>com.caucho</groupId>
<artifactId>hessian</artifactId>
<version>3.1.5</version>
</dependency>
My proxy works just fine for the trunk of the project, and there is no other proxy I'm aware of.
I thought it was maybe a one-time connection problem, but making a new maven build with -U didn't resolve the problem.
I also found https://stackoverflow.com/questions/6111408/maven2-missing-artifact-but-jars-are-in-place
with several I-don't-know-what-else-to-do solutions, but it didn't work for me...
Since the lead developer is on vacation and I have little experience on mvn, could someone tell me other potential problems that could be responsible for this ?
Thanks in advance for answers :)
Open a command prompt, go to your project directory and run: mvn eclipse:eclipse -DdownloadSources=true -DdownloadJavadocs=true
The eclipse:eclipse portion will regenerate your project files etc, the last 2 properties are more for convenience but I like downloading the sources and javadoc.
After a failed attempt, maven will leave a small file in your local .m2 repository that will prevent any attempt to re-download the file unless the update interval has elapsed or you force the updates using the maven -U switch described in other answers.
Just delete the folder for that artifact in your local m2 repository and update you project; a new download attempt will trigger.
rm -rf ~/.m2/repository/com/caucho/hessian/3.1.5

m2eclipse will not download any dependencies

I was hoping someone might be able to help.
On a brand new windows machine. I've downloaded and installed java jdk before downloading and running the latest version of eclipse (indigo).
From there I have installed the maven integration plugin from the marketplace and created a new maven projected.
The project has a ton of errors mainly to do with missing dependencies or life cycle management.
When I do maven-clean I get the following error message:
[ERROR] Plugin org.apache.maven.plugins:maven-clean-plugin:2.4.1 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-clean-plugin:jar:2.4.1: Could not transfer artifact org.apache.maven.plugins:maven-clean-plugin:pom:2.4.1 from/to central (http://repo1.maven.org/maven2): Invalid argument: getsockname to http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-clean-plugin/2.4.1/maven-clean-plugin-2.4.1.pom -> [Help 1]
I am not behind a firewall and I do not use a proxy. My maven settings.xml is completely default as is my maven project. No classes added, nothing added to the pom.
Can anyone help?
All the best.
p.s here are the errors shown in the pom:
1:
CoreException: Could not calculate build plan: Plugin org.apache.maven.plugins:maven-compiler-plugin:2.3.2 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-compiler-plugin:jar:2.3.2: ArtifactResolutionException: Failure to transfer org.apache.maven.plugins:maven-compiler-plugin:pom:2.3.2 from http://repo1.maven.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. Original error: Could not transfer artifact org.apache.maven.plugins:maven-compiler-plugin:pom:2.3.2 from/to central (http://repo1.maven.org/maven2): Invalid argument: getsockname to http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-compiler-plugin/2.3.2/maven-compiler-plugin-2.3.2.pom
2:
Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-compiler-plugin:2.3.2:testCompile (execution: default-testCompile, phase: test-compile)
3:
Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (execution: default-compile, phase: compile)
4:
Failure to transfer org.apache.maven.plugins:maven-resources-plugin:pom:2.4.3 from http://repo1.maven.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. Original error: Could not transfer artifact org.apache.maven.plugins:maven-resources-plugin:pom:2.4.3 from/to central (http://repo1.maven.org/maven2): Invalid argument: getsockname to http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-resources-plugin/2.4.3/maven-resources-plugin-2.4.3.pom
Furthermore i recommend to test the configuration etc. first with command line client of Maven (Maven 3.0.X) and not within Eclipse.
The 1./4. shows that you have tried to download some artifact which has failed for whatever reasons. The simple solution for that is to delete the local repository and retry the build. But i recommend to do that first on command line to check if everything is fine.
The 2./3. are indications that the project you are trying to compile does not contain a correct plugin coverage for m2e which can be read in the docs how to solve that.
Problem:
You are missing an artefact in Your maven repository.
How to verify:
If You will browse Your repository You will find out that under .m2/repository/org/apache/maven/plugins/maven-clean-plugin/2.4.1/ artefact will have lastUpdated suffix - maven attempted to download this artefact but failed.
How to solve:
Just add an appropriate artefact into Your maven repository:) There are several ways how to do that but the simplest one will be dropping the folder with the missing artefact. Add since You can build Your project from the CMD just add missing artefact as a dependency into Your project. Build the project from the CMD.
Add dependency is not working through eclipse IDE(JUNO 4.2). Fixed the issue by manually adding dependencies with the below command on command prompt
go to the location where your pom.xml is located
mvn install
once you see status BUILD success from now onwards we can proceed with IDE.
Clearly this is an issue of proxy. Either use VPN or edit procy setting in setting.xml. I searched lot about this error. Finally, I used VPN(Virtual private network ) to disable the proxy and was able to use cetral repository of Maven.
IF you dont want to USE VPN just change Settings.xml host address with proxy address of ur company(which is available in IE->tools->connection->LAN settings->advanced->http. )
This is a proxy problem:
add your proxy config in your setting.xml
remove .m2 folder from your home directory
run any maven command in interactive mode from command line, for example try to create a project
mvn archetype: generate -DarchetypeGroupId=org.apache.maven.archetypes -DarchetypeArtifactId=maven-archetype-webapp -DgroupId=com.mycompany.app -DartifactId=my-webapp
that's all
I had the same problem. It was because I configured the repository in the settings.xml of my Maven Installation. But this in not used by Eclipse as it comes with its own Maven implementation. You need to configure the repositories (mirror section) in the settings.xml in your profile (.m2/settings.xml).

Categories

Resources