Newbee
Newbee

Reputation: 1397

Maven reading settings.xml from wrong place

I am new to Maven and Ubuntu. I am having trouble building maven projects. When I run the mvn clean -X command I can see the below DEBUG logs.

[DEBUG] Reading global settings from /space/user/programs/apache-maven-3.5.3/conf/settings.xml
[DEBUG] Reading user settings from ?/.m2/settings.xml
[DEBUG] Reading global toolchains from /space/user/programs/apache-maven-3.5.3/conf/toolchains.xml
[DEBUG] Reading user toolchains from ?/.m2/toolchains.xml
[DEBUG] Using local repository at /space/user/git/receiver/?/.m2/repository

I have following settings in .bashrc file

export JAVA_HOME=/space/user/programs/jdk1.8.0_162
export M2_HOME=/space/user/programs/apache-maven-3.5.3
export MAVEN_HOME=/space/user/programs/apache-maven-3.5.3

And I have settings.xml file in /home/user/.m2 folder

Why maven is not picking /home/user/.m2/settings.xml? What is it that I am missing here please? If you need any further information please let me know and I will update the question.

I am using Ubuntu 16.04.

UPDATE: Output of mvn --version command

Apache Maven 3.5.3 (3383c37e1f9e9b3bc3df5050c29c8aff9f295297; 2018-02-24T19:49:05Z)
Maven home: /space/user/programs/apache-maven-3.5.3
Java version: 1.8.0_162, vendor: Oracle Corporation
Java home: /space/user/programs/jdk1.8.0_162/jre
Default locale: en_GB, platform encoding: UTF-8
OS name: "linux", version: "4.13.0-37-generic", arch: "i386", family: "unix"

UPDATE: Overriding settings on command line like this mvn --settings /home/user/.m2/settings.xml clean -X works fine. But this is not the solution I want.

Upvotes: 1

Views: 1583

Answers (2)

David
David

Reputation: 3261

Note: your linux machine might have both a 32-bit and a 64-bit version of the JVM installed. Even Java 11. @Newbee is correct that this can cause weird maven behavior that they described. Check your alternatives to see which one is being pointed at (for CentOS / RHEL machines):

 ls -l /etc/alternatives/java_sdk_11
 sudo alternatives --display java_sdk_11
 sudo alternatives --config java_sdk_11

Upvotes: 0

Newbee
Newbee

Reputation: 1397

The solution was to use 64-bit JDK on a 64-bit system. I somehow copied 32-bit JDK, and this was the problem. It worked as expected with a 64-bit runtime.

This question helped me solve the issue - Java: System.getProperty("user.home") returns "?"

Upvotes: 2

Related Questions