Why i always gets the [INFO] Unable to find resource in repository? - maven-2

greetings all
I am using maven 2 in my spring project
and when I try to build the project from the terminal using the commands (mvn clean-mvn install)
it cannot download any dependency from any of the repos, and I always gets Info like :
Downloading: http://repo1.maven.org/maven2/velocity-tools/velocity-tools-generic/1.4/velocity-tools-generic-1.4.pom
[INFO] Unable to find resource 'velocity-tools:velocity-tools-generic:pom:1.4' in repository first (http://repo1.maven.org/maven2)
Downloading: http://mirrors.ibiblio.org/pub/mirrors/maven2//velocity-tools/velocity-tools-generic/1.4/velocity-tools-generic-1.4.pom
[INFO] Unable to find resource 'velocity-tools:velocity-tools-generic:pom:1.4' in repository second (http://mirrors.ibiblio.org/pub/mirrors/maven2/)
Downloading: http://repository.jboss.com/maven2//velocity-tools/velocity-tools-generic/1.4/velocity-tools-generic-1.4.pom
[INFO] Unable to find resource 'velocity-tools:velocity-tools-generic:pom:1.4' in repository jboss (http://repository.jboss.com/maven2/)
Downloading: http://maven.jahia.org/maven2/velocity-tools/velocity-tools-generic/1.4/velocity-tools-generic-1.4.pom
[INFO] Unable to find resource 'velocity-tools:velocity-tools-generic:pom:1.4' in repository additional (http://maven.jahia.org/maven2)
Downloading: http://208.79.234.53:8081/artifactory/libs-releases-local/velocity-tools/velocity-tools-generic/1.4/velocity-tools-generic-1.4.pom
[WARNING] Unable to get resource 'velocity-tools:velocity-tools-generic:pom:1.4' from repository host.varaza.com (http://208.79.234.53:8081/artifactory/libs-releases-local): Error transferring file: Connection timed out
any ideas, why such thing occurs ?

From the repository link, it looks like this dependency does not have an associated pom file. This is the reason for the warning.
Typically, dependencies in the repository also have a pom file, which describes the project, as well as specifies its dependencies. Maven first downloads this pom file, so that it can resolve transitive dependencies, if any.

Maven is just trying to get the pom files from your repositories and will try for as long as it can't download them.
This is happening most probably because the libraries (dependencies) you reference don't have a pom file in any of the remote repositories available. This is probably normal.
However if you want to get rid of the message you could deploy minimal pom files for those dependencies in your company's repository. You can choose to just install them locally but then other developers in your team would still have those messages.

Maven can't reach the sites where dependencies are located.
Try running
ping repo1.maven.org
or opening it in your web browser. Maybe you should set the firewall to allow Maven downloading stuff from internet.

I used the following dependency - works for me.
<dependency>
<groupId>velocity-tools</groupId>
<artifactId>velocity-tools-generic</artifactId>
<version>1.4</version>
</dependency>

Related

maven archetype plugin - No archetype found in remote catalog. Defaulting to internal catalog

$ mvn -version
Apache Maven 3.5.2 (138edd61fd100ec658bfa2d307c43b76940a5d7d; 2017-10-18T09:58:13+02:00)
Fetching dependencies from the central repository works very well.
I have a problem with fetching archetypes though.
For example I am trying to use an archetype which is present in the central archetype catalog:
mvn archetype:generate -DgroupId=com.example -DartifactId=sample-ear -DarchetypeArtifactId=wildfly-javaee7-webapp-ear-archetype -DarchetypeGroupId=org.wildfly.archetype -DinteractiveMode=false
Maven fails. It basically cannot see any archetypes in the remote catalog:
[WARNING] No archetype found in remote catalog. Defaulting to internal catalog
[WARNING] Specified archetype not found.
I am able to access the HTTP link for the catalog in a browser.
Documentation (http://maven.apache.org/archetype/maven-archetype-plugin/specification/archetype-catalog.html) states clearly:
The Archetype Plugin knows by default about its internal catalog. It also knows about the local and remote catalogs.
remote represents the http://repo.maven.apache.org/maven2/archetype-catalog.xml catalog file.
Have you ever had such issue ?
I would be grateful for any hint that could direct me to find a solution.
Add option -DarchetypeVersion=8.2.0.Final

Maven: How to install a plugin in offline mode

I'm sitting behind a firewall and therefore maven can't connect to central repositories (error message is given below).
However, I can connect to the internet via HTTP.
How can I install a maven plugin (e. g. archetype) in offline mode (i. e. download some file in a browser and then install the plugin by executing some commands) ?
Thanks in advance
Dmitri
P. S.: Here is the error message:
E:\>mvn archetype:generate -DarchetypeGroupId=com.vaadin
-DarchetypeArtifactId=vaadin-archetype-clean -DarchetypeVersion=LATEST -DgroupI
d=at.swdev -DartifactId=pcc -Dversion=1.0 -Dpackaging=war
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'archetype'.
[INFO] org.apache.maven.plugins: checking for updates from central
[WARNING] repository metadata for: 'org.apache.maven.plugins' could not be retri
eved from repository: central due to an error: Error transferring file: Connecti
on refused: connect
[INFO] Repository 'central' will be blacklisted
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] The plugin 'org.apache.maven.plugins:maven-archetype-plugin' does not exi
st or no valid version could be found
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1 second
[INFO] Finished at: Thu Jul 22 15:17:00 CEST 2010
[INFO] Final Memory: 1M/15M
[INFO] ------------------------------------------------------------------------
I'm sitting behind a firewall and therefore maven can't connect to central repositories (error message is given below). However, I can connect to the Internet via HTTP.
Maybe you should clarify a bit because Maven uses HTTP as well. If you connect through some kind of proxy, you CAN configure Maven to do so by declaring the proxy in your ~/.m2/settings.xml. See Configuring a proxy.
How can I install a maven plugin (e. g. archetype) in offline mode (i. e. download some file in a browser and then install the plugin by executing some commands)?
You can install any jar in your local repository using the install:install-file goal (see the Usage page). But this is only a small part of the story, you'll need to install dependencies of the plugin too. And then dependencies of dependencies. This will very quickly become a real nightmare and unmanageable task (that Maven precisely tries to solve). So either:
Configure Maven to access Internet if this is possible ~or~
Setup a corporate repository (like Nexus) on a dedicated machine, see with your admins how to allow it to access Internet) and configure your Maven client to use it ~or~
Copy a "pre-populated" local repository from an existing machine to your machine and run maven offline (with all the limitations this implies) ~or~
Don't use Maven
If you can not use proxy, then you should download all dependencies of plugin as Pascal said. Easiest way to do this.
Download all dependencies using a machine with normal/proxied http connection. Maven dependency plug-in has a goal which can help you. mvn dependency:go-offline
For example I use it to get maven dependencies of app-fuse tutorial.
svn co (http here ) appfuse-demos.googlecode.com/svn/trunk/helloworld
(check out source code)
mvn install (install and see that it works in normal machine)
mvn dependency:go-offline (it downloads everything. Help :tells Maven to resolve everything this project is dependent on (dependencies, plug-ins, reports) in preparation for going offline.)
after that in your local m2 repository (~/m2/repository) , you will find everything you need. Zip that folder. Get it inside your intranet. extract it to your local repository or
corporate repository (nexus, artifactory ..)
you should be able to use that plug-in now.
http://maven.apache.org/plugins/maven-dependency-plugin/
I guess your security firewall doesn't allow you to download from maven central repo.So, you can simply specify mirrors in the settings.xml file in the maven_home. if you have any repository for your company say like nexus, give the server url of that nexus in the mirrors section in your settings.xml.
Note that in case if you don't have any repo for your company you have to download all the dependencies offline and install using mvn install in the local repository in your build server.

Maven grails plugin issue

I'm trying to create the pom for an existing grails project via:
mvn grails:create-pom -DgroupId=ourcompany.com
Now, we have our maven repository available in a local nexus repo:
http://ourcompany.com/nexus
But when i run the above, i get the below error
Downloading: http://ourcompany.com/nexus/content/groups/public/ourcompany/com/hibernate-core/3.3.1.GA/hibernate-core-3.3.1.GA.jar
[INFO] Unable to find resource 'ourcompany.com:hibernate-core:jar:3.3.1.GA' in repository
central (http://repo1.maven.org/maven2)
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
But it is in there at simply:
http://ourcompany.com/nexus/content/groups/public/hibernate-core/3.3.1.GA/hibernate-core-3.3.1.GA.jar
Ie, w/o the "ourcompany.com" path. From my perspective, it should just try to pull down hibernate w/o inserting the groupId, but maybe i'm not understanding how i'm supposed to run this command?
What happens is you just run:
mvn grails:create-pom

Why is my Maven so slow on Ubuntu?

I have Maven on Ubuntu server.
It seems to try lots and lots of places to download from but the download times out, but the timeout takes ages, so my whole build takes more than a hour.
Downloading: http://scala-tools.org/repo-releases/org/apache/maven/maven-repository-metadata/2.0.3/maven-repository-metadata-2.0.3.pom
[INFO] Unable to find resource 'org.apache.maven:maven-repository-metadata:pom:2.0.3' in repository scala-tools.org (http://scala-tools.org/repo-releases)
Downloading: http://download.java.net/maven/2/org/apache/maven/maven-repository-metadata/2.0.3/maven-repository-metadata-2.0.3.pom
[WARNING] Unable to get resource 'org.apache.maven:maven-repository-metadata:pom:2.0.3' from repository java.net (http://download.java.net/maven/2): Error transferring file: Connection timed out
Downloading: http://download.java.net/maven/1/org.apache.maven/poms/maven-repository-metadata-2.0.3.pom
[WARNING] Unable to get resource 'org.apache.maven:maven-repository-metadata:pom:2.0.3' from repository m1.java.net (http://download.java.net/maven/1): Error transferring file: Connection timed out
Downloading: http://download.java.net/maven/2/org/apache/maven/maven-repository-metadata/2.0.3/maven-repository-metadata-2.0.3.pom
[INFO] Unable to find resource 'org.apache.maven:maven-repository-metadata:pom:2.0.3' in repository maven2-repository.dev.java.net (http://download.java.net/maven/2)
Downloading: http://repository.jboss.org/maven2/org/apache/maven/maven-repository-metadata/2.0.3/maven-repository-metadata-2.0.3.pom
[INFO] Unable to find resource 'org.apache.maven:maven-repository-metadata:pom:2.0.3' in repository repository.jboss.org (http://repository.jboss.org/maven2)
Downloading: http://repo1.maven.org/maven2/org/apache/maven/maven-repository-metadata/2.0.3/maven-repository-metadata-2.0.3.pom
I only have two repos set in my maven build
<repository>
<id>central</id>
<name>Maven Repository Switchboard</name>
<layout>default</layout>
<url>http://repo1.maven.org/maven2</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>maven2-repository.dev.java.net</id>
<name>Java.net Repository for Maven</name>
<url>http://download.java.net/maven/2</url>
</repository>
<repository>
<id>repository.jboss.org</id>
<name>JBoss Repository</name>
<url>http://repository.jboss.org/maven2</url>
</repository>
Thanks, philip
It seems that Ubuntu's packaged Maven version comes with a /etc/maven2/settings.xml. Have a look at this file to see if it contains additional repositories. Also check the file ~/.m2/settings.xml of the user you are using.
PS: I don't really like using .deb for this kind of software and recommend installing it "manually" (i.e. just download the archive, unzip it somewhere, set the M2_HOME env variable and add $M2_HOME/bin to the $PATH).
Maybe overkill if you're the only one working on the project but I'd recommend installing a Maven repository manager like Artifactory (http://www.jfrog.org/products.php) or Nexus. I'm not familiar with Nexus but Artifactory installation is dead simple - just unzip and you're good to go (since it comes with an embedded jetty).
Why will this make your Maven builds faster ?
Repository managers employ more sophisticated caching than the Maven core itself
(at least with Artifactory) You can restrict which Maven repositories are queried for which group IDs. This speeds up things considerably if you need to fetch dependencies from multiple different Maven repositories
Make sure you can access these resources (in your case the POMs) outside of Maven, if the machine has no network connectivity for example (or can't resolve hostnames), it will time out, and it will take a long time (as you noted).
If you don't need to re-download the resources every time, just run Maven in the "offline" mode with the -o switch.
Also, just a tip, you may want to create and install POMs, even for third party JARs, and then get them in your local repo. That way Maven will not have to go out to the tubes to get resources each time (it will check em, but they will be resolved locally).
For third party or otherwise non Maven JARs you can install then with the install plugin.

How do I stop Maven 2.x from trying to retrieve non-existent pom.xml files for dependencies every build?

In my project, there are a number of dependencies that are transitively included from other dependencies that do not have pom.xml files available in any of our corporate repositories. These are internal jar-only libraries supported by various teams which have been uploaded into repositories for convenience from non-Maven teams, however these repositories are unfortunately not mine to play with.
For these dependencies, Maven insists on trying to retrieve the poms from each of my repository list every time I run a build, or mvn dependency:list. This means maven tries to retrieve 8x pom files from 7 different repository locations, and given this is over the global corporate WAN; it's really slow.
e.g. for one particular dependency
C:\Working\dev\workspace\project>mvn dependency:list
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'dependency'.
[INFO] ------------------------------------------------------------------------
[INFO] Building project
[INFO] task-segment: [dependency:list]
[INFO] ------------------------------------------------------------------------
[WARNING] Unable to get resource 'aGroupId:anArtifactId:pom:4.0.14i' from repository inhouse (http://someRepo1/proximity/repository/inhouse): While configuring wagon for 'inhouse': Unable to apply wagon configuration.
Downloading: http://someRepo1/proximity/repository/extFree/aGroupId/anArtifactId/4.0.14i/anArtifactId-4.0.14i.pom
[INFO] Unable to find resource 'aGroupId:anArtifactId:pom:4.0.14i' in repository extFree (http://someRepo1/proximity/repository/extFree)
Downloading: http://someRepo1/proximity/repository/externalNonFree/aGroupId/anArtifactId/4.0.14i/anArtifactId-4.0.14i.pom
[INFO] Unable to find resource 'aGroupId:anArtifactId:pom:4.0.14i' in repository extNonFree (http://someRepo1/proximity/repository/externalNonFree)
Downloading: http://someRepo2/efs/dist/maven/maven2-repository/incr/common/lib/aGroupId/anArtifactId/4.0.14i/anArtifactId-4.0.14i.pom
[INFO] Unable to find resource 'aGroupId:anArtifactId:pom:4.0.14i' in repository efsRepo (http://someRepo2/efs/dist/maven/maven2-repository/incr/common/lib)
Downloading: http://someRepo2/efs/dist/btijava/maven2-repository/incr/common/lib/aGroupId/anArtifactId/4.0.14i/anArtifactId-4.0.14i.pom
[INFO] Unable to find resource 'aGroupId:anArtifactId:pom:4.0.14i' in repository efsBTI (http://someRepo2/efs/dist/btijava/maven2-repository/incr/common/lib)
Downloading: http://someRepo3/maven/aGroupId/anArtifactId/4.0.14i/anArtifactId-4.0.14i.pom
[INFO] Unable to find resource 'aGroupId:anArtifactId:pom:4.0.14i' in repository internal.repo (http://someRepo3/maven)
Downloading: http://repo1.maven.org/maven2/aGroupId/anArtifactId/4.0.14i/anArtifactId-4.0.14i.pom
[INFO] Unable to find resource 'aGroupId:anArtifactId:pom:4.0.14i' in repository central (http://repo1.maven.org/maven2)`
...
etc
...
[INFO] [dependency:list {execution: default-cli}]
[INFO]
[INFO] The following files have been resolved:
... etc
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 20 seconds
[INFO] Finished at: Tue Jan 26 15:01:48 CST 2010
[INFO] Final Memory: 31M/74M
[INFO] ------------------------------------------------------------------------
On the other hand, for POMs which are just invalid (older modelVersion, or corrupt/invalid XML, for example) it just checks my local repo, complains it's invalid and then continues. Which is fine; at least that doesn't try again over the WAN.
Is there a way (setting, override, repository config change) I can prevent Maven's dependency plugin/artifact resolver from repeatedly trying to locate missing POMs, if it already has the jar file in the local repo?
Specs:
Maven 2.2.1 (default superPOM plugin definitions)
JDK 1.6.0_18
Pascal's answer is correct for two local build workarounds. However, your best option is to request the owners of these projects to create POMs for the artifacts. They don't need to be complex, the simple alternative that Maven is using internally will work:
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>aGroupId</groupId>
<artifactId>aArtifactId</artifactId>
<version>4.0.14i</version>
</project>
Downloading a POM is really a central concept in Maven to support transitive dependencies (actually, a dependency isn't just a JAR, see 3.5.5. Maven's Dependency Management for nice details on that) so I don't know if you can prevent it.
Of course, the right thing to do would be to fix the root cause of the problem. But if you can't, maybe you can run your build in offline mode (using the -o option). Or maybe you could just "install" the artifacts in your local repository using install:install-file and instruct the plugin to generate a pom for them using the generatePom optional parameter (but this obviously doesn't "scale" really well).
Set up a Nexus Repository (or similar) and upload the artifacts there. Nexus will automatically create basic poms for artifacts you upload.
download to local repo
setup nexus and upload
work offline
maybe the best idea is to get rid of maven all the way, it is horror !