Maven not downloading jars behind proxy - java

Maven is unable to download jar (s) (Dependency) behind proxy.
Here is my pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<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
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.faizan.firstbootapp.group1</groupId>
<artifactId>com-faizan-firstbootapp-group-1</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>FirstBootApp</name>
<description>Test app for Maven build system</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.2.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Here is my settings.xml at path C:\Users\faizanmubasher\.m2\settings.xml. I have added proxies in it.
<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
https://maven.apache.org/xsd/settings-1.0.0.xsd">
<proxies>
<proxy>
<id>skm--http-proxy</id>
<active>true</active>
<protocol>http</protocol>
<host>my.proxy.ip.here</host>
<port>8080</port>
<username>faizanmubasher</username>
<password>*****</password>
</proxy>
<proxy>
<id>skm--https-proxy</id>
<active>true</active>
<protocol>https</protocol>
<host>my.proxy.ip.here</host>
<port>8080</port>
<username>faizanmubasher</username>
<password>*****</password>
</proxy>
</proxies>
</settings>
Username and password are correct.
Is it due to my office's proxy that is not allowing to download jar or is it some Maven settings that I need to configure?
I am facing this error on STS IDE.
The container 'Maven Dependencies' references non existing library 'C:\Users\faizanmubasher\.m2\repository\org\springframework\boot\spring-boot-autoconfigure\2.0.2.RELEASE\spring-boot-autoconfigure-2.0.2.RELEASE.jar' FirstBootApp Build path Build Path Problem
My Maven version is Apache Maven 3.5.3.
EDIT
The command set MAVEN_OPTS="-DhttpProxyHost=xxx.xx.xx.xx -DsocksProxyPort=8080" doesn't work as well.

Try this, if 1 does not work try 2, then 3:
1) First update the project, Alt-F5
2) Then go to your repo and blow away the directory for that dependency which should be in the directory C:\Users\faizanmubasher.m2\repository\org\springframework\boot\spring-boot-autoconfigure\2.0.2.RELEASE Then do an Alt-F5 again.
3) If this fails try a mvn clean install -U from the command line.
You can test your maven to maven central repo connectivity with the following command:
mvn archetype:generate
You should see over 2000 archetypes returned

I have encountered the same problem.
And I turned back to older versions of maven which is 3.1.0.
I was trying to use a http proxy to get reached to maven https
repository.
Here, there is a issue for newer versions in maven's jira.
https://issues.apache.org/jira/browse/PROXY-27

Related

how to add dom4j dependecy in maven pom with spring boot

I want to use dom4j to parse xml string. But when I add dom4j dependency in pom file, my dev tool(Eeclipse) prompt errors below:
I tried to refresh project and maven's update project, the errors still occured. If remove the dependency, all of errors disappear, also dom4j cannot use.
Eclipse version:
Eclipse Java EE IDE for Web Developers.
Version: Photon Release (4.8.0)
Build id: 20180619-1200
POM file:
http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
<groupId>test</groupId>
<artifactId>test</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.3.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
</dependency>
</dependencies>
<properties>
<java.version>1.8</java.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
Maven Version:
I figured out it through a whole day working, the fix steps are:
1. the first line of errors prompt in eclipse is : fail to read artifact descriptor for xml-apis:xml-apis:jar:1.4.01.(the first capture image of the question)
2. I assumed that something are wrong with xml-apis in maven repository, so I find the directory of xml-apis in maven repository and remove them all
3. After that, I use Maven->Update project in eclipse, the errors run away.
I think the reason is: some files of xml-apis were damaged.

Differenet Errors while running maven project with existing pom.xml to netbeans

this is my first project using Spring (and I'm not too experienced with Maven either)
I tried to import a new maven project with existing pom.xml to netbeans.
I saw a lot of questions asked here before but the answers didn't fix these errors.
mvn clean install return this error
[INFO] -----------------------------------------------------------------------
[ERROR]
Failed to execute goal org.springframework.boot:spring-boot-maven-plugin
:1.2.0.RELEASE:repackage (default) on project ssh-on-web: Execution default of g
oal org.springframework.boot:spring-boot-maven-plugin:1.2.0.RELEASE:repackage fa
iled: Unable to find main class -> [Help 1]
Also when i try to run the maven web-application with tomcat it returns this error :
Undeploying ...
undeploy?path=/
OK - Application non déployée pour le chemin de contexte /
In-place deployment at C:\Users\admin\Desktop\ssh-on-web-master\target\ssh-on-web-1.0-SNAPSHOT
Deployment is in progress...
deploy?config=file%3A%2FC%3A%2FUsers%2Fadmin%2FAppData%2FLocal%2FTemp%2Fcontext6208589662765502295.xml&path=/
ECHEC - Application déployée pour le chemin de contexte / mais le démarrage du contexte a échoué
here you find how the pom.xml looks like :
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<packaging>war</packaging>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.3.RELEASE</version>
<relativePath/>
<!-- lookup parent from repository -->
</parent>
<groupId>ssh-on-web</groupId>
<artifactId>ssh-on-web</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.hierynomus</groupId>
<artifactId>sshj</artifactId>
<version>0.11.0</version>
</dependency>
<dependency>
<groupId>net.sf.expectit</groupId>
<artifactId>expectit-core</artifactId>
<version>0.6.1</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-websocket</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<!--<scope>provided</scope>-->
</dependency>
<dependency>
<groupId>javax.el</groupId>
<artifactId>javax.el-api</artifactId>
<version>2.2.4</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>com.kodcu.ApplicationStarter</mainClass>
<layout>ZIP</layout>
<goal> run </goal>
</configuration>
</plugin>
</plugins>
</build>
</project>
and this is how my project directories looks like :
My web-application tree
Best regards
I had the same problem, I found out later that I had put pom.xml in the wrong directory. I had put it in: src/main/java/. The correct location for pom.xml is in the src folder, at the same level with the main folder.
If you made the same error, just put it in the right folder in src, and then run mvn clean install again, and it'll run just fine.

Why is GWT 2.5.1 missing from Maven repo?

I just installed m2e (the Maven Eclipse plugin) and created a new Maven Project with a Quickstart archetype. I then went to the official Maven repo to pull down GWT 2.5.1's dependencies, and see that it wants you to add the following <dependency> element to your project's pom.xml file:
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt</artifactId>
<version>2.5.1</version>
</dependency>
So, altogether, my pom.xml looks like:
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.me.myorg</groupId>
<artifactId>maven-resolver</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>maven-resolver</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt</artifactId>
<version>2.5.1</version>
</dependency>
</dependencies>
</project>
I am getting the following error:
Missing artifact com.google.gwt:gwt:jar:2.5.1
And furthermore, in Eclipse's Package Explorer, under my project's Maven Dependencies library, nothing is resolving.
What's going on here? Thanks in advance!
Update: the contents of ~/.m2/repository/com/google/gwt/gwt/2.5.1 are as follows:
gwt-2.5.1.jar.lastUpdated gwt-2.5.1.pom.sha1
gwt-2.5.1.pom _maven.repositories
This gwt dependencie it's a parent pom for the gwt project. This means that the repo will only contain the hash and the pom, but not the jar.
You need to use two libraries: gwt-servlet and gwt-user:
I've found this configuration for GWT development (maybe you don't need to put the <scope> as described):
<dependencies>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-servlet</artifactId>
<version>2.5.1</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<version>2.5.1</version>
<scope>provided</scope>
</dependency>
<dependencies>
Remove your dependencies and update your pom with these two shown above.
You can also use the gwt-maven-plugin to manage your gwt project and deploy via maven. I've found this information there.
I hope that works!

Creating apklibs with maven and IntelliJ

I'm creating a apklib from sliding menu because I couldn't find any maven repository. The problem is that when I try from intellij, It imports the library but doesn't add the dependencies to sliding menu library and I have to add it manually.
<?xml version="1.0" encoding="UTF-8"?>
<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 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.slidingmenu</groupId>
<artifactId>library</artifactId>
<version>1.2</version>
<type>apklib</type>
<dependencies>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>4.1.1.4</version>
</dependency>
<dependency>
<groupId>com.google.android.maps</groupId>
<artifactId>maps</artifactId>
</dependency>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>support-v13</artifactId>
<version>r12</version>
</dependency>
<dependency>
<groupId>com.github.rtyley</groupId>
<artifactId>roboguice-sherlock</artifactId>
<version>1.5</version>
</dependency>
<dependency>
<groupId>org.roboguice</groupId>
<artifactId>roboguice</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>com.actionbarsherlock</groupId>
<artifactId>actionbarsherlock</artifactId>
<version>4.2.0</version>
<type>apklib</type>
</dependency>
</dependencies>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<nativeLibrariesDirectory>ignored</nativeLibrariesDirectory>
</configuration>
</plugin>
</plugins>
</build>
</project>
I create the zip, according to the instructions on maven plugin and then I push it to ~/.m2 with this command:
mvn org.apache.maven.plugins:maven-install-plugin:2.4:install-file -DgroupId=com.slidingmenu -DartifactId=library -Dfile=sliding-menu.apklib -Dversion=1.2 -Dpackaging=apklib
You need to install com.slidingmenu in your local repository with mvn clean install instead of install:install-file
mvn clean install will put all the meta-data and the dependencies required by maven in your local repository (i.e. ~/.m2/repository).
In your apk, specify the artifact com.slidingmenu as a dependency of type apklib
I hope it will solve your problems.

Maven not resolving on Netbeans 7.2

I am very very new to Maven. I get the following error
The following artifacts could not be resolved: stax:stax:jar:1.0, stax:stax-ri:jar:1.0, clover:clover:jar:1.3-rc4: Failure to find stax:stax:jar:1.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]
To see the full stack trace of the errors, re-run Maven with the -e switch.
Re-run Maven using the -X switch to enable full debug logging.
After some research (e.g. NetBeans: Re-run Maven with the -e switch on / PluginResolutionException), it is said that I need to edit my ~/.m2/settings.xml file.
I look at the file and I don't see what to change. So I am including it below for input:
settings.xml
<?xml version="1.0" encoding="UTF-8"?>
<!--
User-specific configuration for maven. Includes things that should not
be distributed with the pom.xml file, such as developer identity, along with
local settings, like proxy information. The default location for the
settings file is ~/.m2/settings.xml
-->
<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>
<host>my.proxy.host</host>
</proxy>
</proxies-->
<!--pluginGroups>
<pluginGroup>org.codehaus.mojo</pluginGroup>
</pluginGroups-->
POM.xml
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.schoolsupplies.v5</groupId>
<artifactId>com.schoolsupplies.v5.test</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>com.schoolsupplies.v5.test</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<scope>test</scope>
<type>jar</type>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-client</artifactId>
<version>1.14</version>
<scope>test</scope>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.codehaus.jettison</groupId>
<artifactId>jettison</artifactId>
<version>1.1</version>
<scope>test</scope>
<type>jar</type>
</dependency>
<dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>20040902.021138</version>
<type>jar</type>
</dependency>
</dependencies>
I open the dependencies directories and delete all the jars that were making trouble -- especially since they were not explicitly called for in the pom.xml file. After doing that, everything works fine.
It seems that maven decided that some of my explicitly imported dependencies needed those files. In my case: stax:stax-ri:jar:1.0, clover:clover:jar:1.3-rc4, etc.
I hade the same error. I added the repositories into the pom.xml and everything worked.
Like this example:
<repositories>
<repository>
<id>bukkit-repo</id>
<url>http://repo.bukkit.org/content/groups/public/</url>
</repository>
<repositories>

Categories

Resources