specified user toolchains file does not exist - maven

I am trying to run a test on one of the pools present and while doing do I am getting the below error
Apache Maven 3.3.9
Maven home: /usr/share/maven
Java version: 1.8.0_282, vendor: Private Build
Java home: /usr/lib/jvm/java-8-openjdk-amd64/jre
Default locale: en_US, platform encoding: ANSI_X3.4-1968
OS name: "linux", version: "3.10.0-1127.13.1.el7.x86_64", arch: "amd64", family: "unix"
/usr/bin/mvn -f /azp/_work/81/s/pom.xml -tags=#FmaTest clean test
[ERROR] Error executing Maven.
[ERROR] The specified user toolchains file does not exist: /azp/_work/81/s/ags=#Test
tried with a couple of options that I found online but all in vain

The specified user toolchains file does not exist:
Based on the error info, the cause of this issue is that the toolchains.xml hasn't been added to the $HOME/.m2 folder.
You can try to check the $Home in Pipeline with the following script:
steps:
- script: echo $HOME
Then you can use the Copy File task to copy the toolchains.xml to the target folder.
For example: the $Home : /home/vsts
- task: CopyFiles#2
displayName: 'Copy Files to: /home/vsts/.m2'
inputs:
SourceFolder: '$(build.sourcesdirectory)'
Contents: toolchains.xml
TargetFolder: /home/vsts/.m2
In this case, I can run the maven task successfully.
Here is the doc about using the toolchains
This file should be put in your ${user.home}/.m2 directory.

Related

Maven-encrypted password suddenly not working anymore? Any clues?

We again and again encounter the situation that our local builds suddenly fail to access our repository (Artifactory/JFrog) with "Authentication failed for https:///.../<some-arbitrary .pom or .jar filename here> 401 Unauthorized" errors.
As we found out by some lengthy trial and error in such situations we need to re-encrypt our (same) password anew (using mvn --encrypt-password <password>) and need to put the newly generated output into our settings.xml file (or - as most of us do - update a corresponding environment variable with the new value).
But why is that so? These passwords seem to be invalidated seemingly at random. Some people haven't seen that effect for >1 year. Some have it every other week (and that gets mighty annoying!).
What could be causing this? Is there some info stored somewhere that could be accidentally deleted again and again or what mechanism could be causing this?
Addendum: Maven and Java version info:
C:> mvn -version
executing: "C:\Program Files\Apache\Maven\bin\mvn.cmd"
========================
JAVA_HOME=C:\Program Files\Java\jdk-1.8.0
JAVACMD=C:\Program Files\Java\jdk-1.8.0\bin\java.exe
========================
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: C:\Program Files\Apache\Maven\bin\..
Java version: 1.8.0_292, vendor: AdoptOpenJDK, runtime: C:\Program Files\Java\jdk-1.8.0\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"

DigitalExperienceManager-CommunityDistribution-7.3.1.0 starts with error 'Cannot set maven executable to mvn, please check your configuration'

I've installed DigitalExperienceManager-CommunityDistribution-7.3.1.0-r59490.jar on my MAC, and run the commands to start it:
cd /Applications/DigitalExperienceManager-CommunityDistribution-7.3.1.0/
./start.sh
I find this error in catalina.out:
2020-12-16 19:14:55,509: INFO [ProcessHelper] - [mvn, -version]
2020-12-16 19:14:55,517: ERROR [ModuleBuildHelper] - Cannot set maven
executable to mvn, please check your configuration
org.jahia.exceptions.JahiaRuntimeException: java.io.IOException:
Cannot run program "mvn" (in directory "."): error=2, No such file or
directory at
org.jahia.utils.ProcessHelper.execute(ProcessHelper.java:203) at
org.jahia.utils.ProcessHelper.execute(ProcessHelper.java:138) at
org.jahia.services.templates.ModuleBuildHelper.checkMavenExecutable(ModuleBuildHelper.java:493)
at
org.jahia.services.templates.ModuleBuildHelper.afterPropertiesSet(ModuleBuildHelper.java:534)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1573)
at
org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
at
org.apache.pluto.driver.PortalStartupListener.contextInitialized(PortalStartupListener.java:108)
at
org.jahia.bin.listeners.JahiaContextLoaderListener.contextInitialized(JahiaContextLoaderListener.java:235)
Caused by: java.io.IOException: Cannot run program "mvn" (in directory
"."): error=2, No such file or directory at
java.lang.ProcessBuilder.start(ProcessBuilder.java:1048) at
java.lang.Runtime.exec(Runtime.java:620) at
org.apache.commons.exec.launcher.Java13CommandLauncher.exec(Java13CommandLauncher.java:61)
at
org.apache.commons.exec.DefaultExecutor.launch(DefaultExecutor.java:279)
at
org.apache.commons.exec.DefaultExecutor.executeInternal(DefaultExecutor.java:336)
at
org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:166)
at org.jahia.utils.ProcessHelper.execute(ProcessHelper.java:199) ...
80 more Caused by: java.io.IOException: error=2, No such file or
directory at java.lang.UNIXProcess.forkAndExec(Native Method) at
java.lang.UNIXProcess.(UNIXProcess.java:247) at
java.lang.ProcessImpl.start(ProcessImpl.java:134) at
java.lang.ProcessBuilder.start(ProcessBuilder.java:1029) ... 86 more
2020-12-16 19:14:55,523: ERROR [ModuleBuildHelper] - Until maven
executable is correctly set, the studio will not be available
But I'm sure maven is installed on my machine already:
$ mvn -version Apache Maven 3.6.3
(cecedd343002696d0abb50b32b541b8a6ba2883f) Maven home:
/Users/george/apache-maven-3.6.3 Java version: 1.8.0_191, vendor:
Oracle Corporation, runtime:
/Library/Java/JavaVirtualMachines/jdk1.8.0_191.jdk/Contents/Home/jre
Default locale: zh_CN, platform encoding: UTF-8 OS name: "mac os x",
version: "10.15.5", arch: "x86_64", family: "mac"
What can I do to solve this problem?
Do you have maven in your path? Seems Jahia cannot find maven on startup. When it is not in path you can specify in jahia.properties (\digital-factory-config\jahia\jahia.properties) the full path to maven:
#mvnPath = mvn
Uncomment this property and specify the right path to maven like:
mvnPath = /usr/local/apache-maven/bin/mvn

Build error in jenkins ERROR: Maven Home /home/app/maven-2.2.1 doesn’t exist

I am trying run Jenkins and Building a project.
I have install Maven 2.2.1. I downloaded Maven 2.2.1 and extracted in a folder Maven 2.2.1.
set the home path in .bash_profile.
content of .bash_profile
M2_HOME=/home/qaserver3/app/maven-2.2.1
export M2_HOME
PATH=$M2_HOME/bin:$JAVA_HOME/bin:$PATH
when I run mvn --version on terminal, I get
Apache Maven 2.2.1 (r801777; 2009-08-07 00:46:01+0530)
Java version: 1.6.0_45
Java home: /home/qaserver3/app/jdk1.6.0_45/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux" version: "2.6.32-358.el6.x86_64" arch: "amd64" Family: "unix"
[root#qaserver3 qaserver3]#
when I run echo $M2_HOME I get the correct home path
/home/qaserver3/app/maven-2.2.1
The above home path I have set in Jenkins.
Manage Jenkins -> Configure System -> Maven -> Maven installations ->
MAVEN_HOME = /home/qaserver3/app/maven-2.2.1
beloo I get a warining saying :
`home/qaserver3/app/maven-2.2.1 is not a directory on the Jenkins
master (but perhaps it exists on some slaves)'
but when I build the project I get this error
Console Output
ERROR: Maven Home /home/qaserver3/app/maven-2.2.1 doesn’t exist
How do I solve this issue?
Try this:
Give R/w permissions to your Jenkins user
chmod 0755 /home/qaserver3/
chmod -R 0755 /home/qaserver3/app/maven-2.2.1
Make ensure Jenkins can access all the files
sudo -iu jenkins
Run:
/home/qaserver3/app/maven-2.2.1/bin/mvn -v
You are most likely to see this warning 'home/qaserver3/app/maven-2.2.1 is not a directory on the Jenkins master (but perhaps it exists on some slaves)' when the path in your system information tab is different than you have provided in the environmental variable.
Go to manage jenkins->system information->now check the path of maven in the table.
Copy that path and paste it into the MAVEN_HOME field.
The warning should be gone by now and save it
cheers!

Java_home in Maven

When I ran mvn -version, I noticed the java_home points to ...jdk\jre (as shown below).
Is that wrong? Isn't it supposed to point to ...\jdk.x.y.z (without the \jre)?
If so, how do I reset it? (In global %java_home% points to the jdk directory)
C:\Users\Owner>mvn -version
Apache Maven 2.2.1 (r801777; 2009-08-06 15:16:01-0400)
Java version: 1.7.0_17
Java home: C:\Program Files\Java\jdk1.7.0_17\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 7" version: "6.1" arch: "amd64" Family: "windows"
No, it's not wrong. It is pointing to the JRE used by your JDK, which is what it's supposed to. If you print out JAVA_HOME outside maven, it should print correctly:
C:\>echo %JAVA_HOME%
C:\Program Files\Java\jdk1.7.0_07
C:\>mvn -version
Apache Maven 3.0.4 (r1232337; 2012-01-17 10:44:56+0200)
Maven home: C:\APPS\apache-maven-3.0.4\bin\..
Java version: 1.7.0_07, vendor: Oracle Corporation
Java home: C:\Program Files\Java\jdk1.7.0_07\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows"
C:\>
So basically JAVA_HOME needs to point to a JDK installation (maven needs the tools.jar) but maven actually uses the jre within the JDK to run itself.
When using mvn -version, maven uses java internal java.home property, as can be seen from source code:
version.append( "Java home: " + System.getProperty( "java.home", "<unknown java home>" ) ).append( LS );
This property is not the same thing as JAVA_HOME environment setting, so it might fool you. It is actually dynamic property showing you which JRE is running your code. If you compile and execute a Test.java test class printing the same, you can see that if your JAVA_HOME points to a JDK, the value of java.home is not equal to your JAVA_HOME. This is expected.
Quoting this:
What's the difference between JAVA_HOME and java.home?
JAVA_HOME is the JDK install directory, e.g., C:\jdk5. It's meant to be
set as an environment variable and referenced in Windows batch files or
Unix scripts. I always have it in my Windows Control Panel and .tcsh
files,along with other common environment variables. Some Java
applications use the name jdk.home for this purpose, which I think is
a better name. But JAVA_HOME has been used since the beginning and is
now a convention.
java.home is the JRE install directory, e.g., C:\jdk5\jre, or
C:\Program Files\Java\jre1.5.0_06. Unlike JAVA_HOME, I never seen
java.home as an environment variable. java.home is a build-in Java
system property, whose value is the JRE install directory. Since all
Java system properties are also exposed as Ant build properties, you
can also use ${java.home} in build files.
Would jre.home be a better name? Maybe, but I don't think Sun will
change it.
You can see that maven uses JAVA_HOME on mvn.bat:
:endInit
SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
..
%MAVEN_JAVA_EXE% %MAVEN_OPTS% -classpath %CLASSWORLDS_JAR% ..
And if you want to make sure, you can comment out "#echo off" statement in mvn.bat, so you can see that it is being used.
TL;DR: Based on the information you've given, your configuration is correct, no need to change anything.
Edit: thanks to this thread, there was also an issue about this being confusing, which resulted in change of output for Maven version 3.5.4.
What helped me debugging mvn/jdk issues is to set this before running mvn:
set MAVEN_BATCH_ECHO=on
You get verbose output (on windows), including info how Maven picks java.

Maven home (M2_HOME) not being picked up by IntelliJ IDEA

I am trying to do a simple maven build with IntelliJ IDEA 10.5.1 on OS X Lion and am getting the following error:
Error running my-app [package]: No valid Maven installation found.
Either set the home directory in the configuration dialog or set the
M2_HOME environment variable on your system.
I have set M2_HOME to the following, but I am still having issues. And yes, I did restart IntelliJ.
$ echo $M2_HOME
/usr/share/maven
I then manually entered the path to maven in IntelliJ's Maven Settings for the project. This is not something that I want to do for every project, so is there something I am missing with how to get IntelliJ know where my maven home is?
type in Terminal:
$ mvn --version
then get following result:
Apache Maven 3.0.5 (r01de14724cdef164cd33c7c8c2fe155faf9602da; 2013-02-19 16:51:28+0300)
Maven home: /opt/local/share/java/maven3
Java version: 1.6.0_65, vendor: Apple Inc.
Java home: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
Default locale: ru_RU, platform encoding: MacCyrillic
OS name: "mac os x", version: "10.9.4", arch: "x86_64", family: "mac"
here in second line we have:
Maven home: /opt/local/share/java/maven3
type this path into field on configuration dialog. That's all to fix!
Mac OS apps cannot read bash environment variables. Look at this question Setting environment variables in OS X? to expose M2_HOME to all applications including IntelliJ. You do need to restart after doing this.
Another option is to add the M2_HOME variable at: IntelliJ IDEA=>Preferences=>IDE Settings=>Path Variables
After a restart of IntelliJ, IntelliJ IDEA=>Preferences=>Project Settings=>Maven=>Maven home directory should be set to your M2_HOME variable.
Got to this answer ? probably the answers above are to long ...
just type in :
echo "setenv M2_HOME $M2_HOME" | sudo tee -a /etc/launchd.conf
and restart your mac (thats it!)
restarting is annoying ? just use the command :
grep -E "^setenv" /etc/launchd.conf | xargs -t -L 1 launchctl
and restart IntelliJ IDEA
If M2_HOME is configured to point to the Maven home directory then:
Go to File -> Settings
Search for Maven
Select Runner
Insert in the field VM Options the following string:
Dmaven.multiModuleProjectDirectory=$M2_HOME
Click Apply and OK
In case you don't want to use the M2_HOME and want to direct the IntelliJ to the maven installation you can simply set it by:
goto File => Setting => Maven => Maven home directory
point to your maven build directory e.g. /usr/local/maven/apache-maven-3.0.4
A better way is to have a symlink e.g. 'latest' for the latest version and point your IntelliJ to use that for consistency, given latest points to the latest version of maven installed on your box.
If you are having this problem with a homebrew installation of maven 3 on the OSX 10.9.4 then check out this blog post.

Resources