maven failure to resolve archetype ear-jee5 - maven

I am trying to create an EAR maven module project (in eclipse) with ear-jee5 as the archetype. It fails with the following error.
Could not resolve archetype org.codehaus.mojo.archetypes:ear-jee5:1.3 from any of the configured repositories.
Could not resolve artifact
Missing org.codehaus.mojo.archetypes:ear-jee5:pom:1.3
Could someone please help me resolve this error or show me an alternate way to create the project structure for Maven EAR module?
Thanks.

Apparently, the failure seems to be because I am behind a proxy/firewall at office. The solution is add proxy configurations or add repository mirrors not blocked by firewall in your settings.xml.
hope this helps someone.
Add proxy
<proxies>
<!-- proxy
| Specification for one proxy, to be used in connecting to the network.
|
<proxy>
<id>optional</id>
<active>true</active>
<protocol>http</protocol>
<username>proxyuser</username>
<password>proxypass</password>
<host>proxy.host.net</host>
<port>80</port>
<nonProxyHosts>local.net|some.host.com</nonProxyHosts>
</proxy>
-->
</proxies>
or mirrors
<mirrors>
<!-- mirror
| Specifies a repository mirror site to use instead of a given repository. The repository that
| this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used
| for inheritance and direct lookup purposes, and must be unique across the set of mirrors.
|
<mirror>
<id>mirrorId</id>
<mirrorOf>repositoryId</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://my.repository.com/repo/path</url>
</mirror>
<mirrors>
Thanks

Related

How to let Maven download from Nexus but bypass it for external jars

I understand Nexus is supposed to download the external dependencies, but the company Nexus server (over which I have no control) cannot access the internet or download external jars.
As a workaround I have 2x settings.xml files which I manually switch. One settings.xml use the corporate Nexus server for internal jars and the other uses the company proxy to download external dependencies from the default Maven repositories. Once all the dependencies are in my local Maven repo compilings works.
settings.xml for Nexus (excluding proxies)
<settings>
<mirrors>
<mirror>
<id>some-repo-mirror</id>
<mirrorOf>*</mirrorOf>
<url>https://brokennexus/repository/maven-public/</url>
</mirror>
</mirrors>
<servers>
<server>
<id>some-repo-mirror</id>
<username>me</username>
<password>secret</password>
</server>
</servers>
</settings>
settings.xml for internet (excluding mirrors and servers)
<settings>
<proxies>
<proxy>
<id>company-proxy-http</id>
<active>true</active>
<protocol>http</protocol>
<username>me</username>
<password>secret</password>
<host>proxy.server</host>
<port>8080</port>
</proxy>
<proxy>
<id>company-proxy-https</id>
<active>true</active>
<protocol>https</protocol>
<username>me</username>
<password>secret</password>
<host>proxy.server</host>
<port>8080</port>
</proxy>
</proxies>
</settings>
Both files works on their own, but I cannot figure out how to combine them into one.
Is there a way to configure maven in such a way that if the company Nexus cannot resolve a dependency it would fall back and attempt to download from an external repo through the company's internet proxy or the other way around so that I do not have to switch between the two settings.xml files?
You can configure the proxy in your "normal" settings.xml and exclude your Nexus as nonProxyHost:
https://maven.apache.org/guides/mini/guide-proxies.html
Furthermore, you need to change the mirror configuration <mirrorOf>*</mirrorOf> to something like <mirrorOf>*,!central</mirrorOf> to be able to connect MavenCentral (and other repositories directly).
Of course, the preferred solution would be to talk to the admin if they can add the external repositories to the company Nexus.

How to make maven search for artifacts in local repository

I have a project that worked fine on another pc. And now i'm trying to run it on another pc. There is no acces to proxy. And after any action it says that
couldn't transfer artifact. no route to host
But i have all depandencies in local repository, maven just doesn't want to take it from there. Is there a way to make him take all artifacts from local repo first?
There must be a version difference in the artifacts you have in your local repository and the ones mentioned in pom.xml
Your error : couldn't transfer artifact. no route to host
is because you have'nt added proxy to your pom. eg :
<proxies>
<!-- proxy
| Specification for one proxy, to be used in connecting to the network.
|
-->
<proxy>
<id>optional</id>
<active>true</active>
<protocol>http</protocol>
<username>username</username>
<password>yourpassword</password>
<host>yourhost#host.com</host>
<port>80</port>
<nonProxyHosts>local.net|some.host.com</nonProxyHosts>
</proxy>
</proxies>
Add it to the settings.xml file in conf folder of maven and try again

Maven Archetype generate proxy issue, searching for remote catalog

Maven seem to be having a bug related to proxy when fetching archetype from maven's remote catalog.
My computer is behind a proxy server. I am trying to generate a project from maven command line.
D:\test>mvn archetype:generate -DarchetypeArtifactId=scala-archetype-simple -DinteractiveMode=false -DgroupId=com.sparktest -DartifactId=myspark -DarchetypeGroupId=net.alchim31.maven -DarchetypeVersion=1.6 -DarchetypeCatalog=remote -e -X
[DEBUG] Searching for remote catalog: http://repo.maven.apache.org/maven2/archetype-catalog.xml
[DEBUG] Archetype org.apache.maven.archetypes:scala-archetype-simple:1.6 doesn't exist
org.apache.maven.archetype.downloader.DownloadNotFoundException:
Requested org.apache.maven.archetypes:scala-archetype-simple:jar:1.6 download does not exist.
Below Eclipse Bugs are related, however the issue seems to be with maven rather than Eclipse.
https://bugs.eclipse.org/bugs/show_bug.cgi?id=390183#add_comment
Please note there is no issue working on existing maven project. The dependencies get downloaded without any issue once maven proxy is configured in settings.xml. The issue comes when generating a project using archetype:generate and using maven remote archetype-catalog.
Maven archetype-catelog can be opened in a browser without any issue
http://repo.maven.apache.org/maven2/archetype-catalog.xml
It's seems that scala-archetype-simple archetype with groupId org.apache.maven.archetypes doesn't actually exist.
You should try one of these :
net.alchim31.maven
org.scala-tools.archetypes
I had this exact issue and the following worked for me: have two proxies, one for http and one for https.
<proxy>
<id>my-proxy-http</id>
<active>true</active>
<protocol>http</protocol>
<host>xx.xx.x.xxx</host>
<port>8080</port>
<username>myusername</username>
<password>mypassword</password>
</proxy>
<proxy>
<id>my-proxy-https</id>
<active>true</active>
<protocol>https</protocol>
<host>xx.xx.x.xxx</host>
<port>8080</port>
<username>myusername</username>
<password>mypassword</password>
</proxy>

Not able to create maven project under eclipse mars even after setting the proxy

Hi Everyone ,
I am new to Maven environment . Tried all possibilities of enabling the proxy under settings.xml .But no use. Since the maven is integrated in mars I couldn't find the settings.xml and created my own under .m2 . And also tried with the external maven also .But no results .
Below is my settings.xml .
<settings>
<proxies>
<proxy>
<active>true</active>
<protocol>http</protocol>
<host>hostname</host>
<port>port</port>
<username></username>
<password></password>
<nonProxyHosts></nonProxyHosts>
</proxy>
</proxies>
</settings>
The failed request from before has been cached by Maven. You need to run the command with the -U flag to retry. (Or wait until the caching has expired...)

No plugin found for prefix 'install' in the current project

I want to add jdbc oracle to maven repository since it is not in repository, I have to run this command:
mvn install:install-file
-Dfile=D:\Temp\ojdbc6.jar
-DgroupId=com.oracle
-DartifactId=ojdbc6 -
Dversion=11.2.0 -Dpackaging=jar
and run into this error:
[ERROR] No plugin found for prefix 'install' in the current project and in the p
lugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the re
positories [local ({my repository path}), central (https://repo.maven.
apache.org/maven2)]
any help would be appropriated.
I recently got the same error and I tried this command. It worked.
export MAVEN_OPTS=-Dhttps.protocols=TLSv1,TLSv1.1,TLSv1.2
I have faced the same issue, there is a two-step process to resolve this issue:
Configure Maven Proxy Configuration
Open Maven configuration file:
For Linux: ${user.home}/.m2/settings.xml
For Windows: C:\users\username\.m2\settings.xml
If you could find the file open it and search for <proxies></proxies> the segment.
If you cannot find the file, create a new file called settings.xml and add following xml tags <settings></settings>
Add the proxy configurations as below:
<proxies>
<proxy>
<id>example-proxy</id>
<active>true</active>
<protocol>http</protocol>
<host>proxy.example.com</host>
<port>8080</port>
<username>proxyuser</username>
<password>somepassword</password>
<nonProxyHosts>www.google.com|*.example.com</nonProxyHosts>
</proxy>
</proxies>
Update Maven Libraries with a Working Extension
Wagon HTTP lightweight library allows us to connect through NTLM proxies. This can be added as an extension to default Maven libraries.
Download the wagon-http-lightweight-2.2.jar from
https://repo.maven.apache.org/maven2/org/apache/maven/wagon/wagon-http-lightweight/2.2/wagon-http-lightweight-2.2.jar
Copy the downloaded file to %M2_HOME%/lib/ext folder.
Now you are ready to use Maven with your programs.
Try adding this to your Maven configuration file:
<!-- https://mvnrepository.com/artifact/com.oracle/ojdbc14 -->
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc14</artifactId>
<version>10.2.0.4.0</version>
</dependency>
It should install Oracle JDBC to your repository and should install the necessary JARS.
https://www.tech-recipes.com/rx/39256/add-dependencies-to-maven-pom-xml-file/
Add it within the dependencies tag.
Hope it helps!
[ERROR] No plugin found for prefix ‘install’ in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (/Users/amitkumar/.m2/repository), central (https://repo.maven.apache.org/maven2)]
There are 2 steps we need to follow to fix this issues :
Step 1 : Open Maven configuration file: For Linux: ${user.home}/.m2/settings.xml
If you could find the file open it and search for the segment.
If you cannot find the file, create a new file called settings.xml and add following xml tags
Add the proxy configurations as below:
<settings xmlns="http://maven.apache.org/settings/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<proxies>
<proxy>
<active>true</active>
<protocol>http</protocol>
<host>www-proxy.us.oracle.com</host>
<port>80</port>
<nonProxyHosts>adc2170275|*.oracle.com|*.oracleads.com|*.us.oracle.com|
*.uk.oracle.com|*.ca.oracle.com|*.oraclecorp.com|
*.oracleportal.com
</nonProxyHosts>
</proxy>
</proxies>
</settings>
Step 2:
Update Maven Libraries with a Working Extension
Wagon HTTP lightweight library allows us to connect through NTLM proxies. This can be added as an extension to default Maven libraries.
Download the wagon-http-lightweight-2.2.jar from https://repo.maven.apache.org/maven2/org/apache/maven/wagon/wagon-http-lightweight/2.2/wagon-http-lightweight-
2.2.jar
Copy the downloaded file to %M2_HOME%/lib/ext folder.

Resources