I'm new to maven. I just joined a new company and they use maven for all their projects.
I set up the company's server for maven dependencies.
I'm using Fedora.
For most of the projects everything goes well. For some of them I get this error when running mvn compile:
Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.0.2:compile (default-compile) on project xlayer: Fatal error compiling: Error while executing the external compiler. Error while executing process. Cannot run program "java -classpath "${env.M2_REPO}/org/eclipse/jdt/core/3.4.2.v_883_R34x/core-3.4.2.v_883_R34x.jar" org.eclipse.jdt.internal.compiler.batch.Main -sourcepath "src/main"" (in directory "/home/es/ion_projects/XLayer"): error=2, No such file or directory -> [Help 1]
I looked several hours on the web, nothing would do.
PATH and JAVA_HOME are correctly set.
Running mvn --version gives:
Apache Maven 3.0.4 (rNON-CANONICAL_2013-01-22_13-18_mockbuild; 2013-01-22 14:18:29+0100)
Maven home: /usr/share/maven
Java version: 1.7.0_17, vendor: Oracle Corporation
Java home: /home/es/kit/jdk1.7.0_17/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.8.3-103.fc17.i686", arch: "i386", family: "unix"
UPDATE:
In the pom.xml (of parent, but that is not important), the maven-compiler-plugin defined the executable as
java -classpath "${env.M2_REPO}/org/eclipse/jdt/core/${org.eclipse.jdt.core.version}/core-${org.eclipse.jdt.core.version}.jar" org.eclipse.jdt.internal.compiler.batch.Main -sourcepath "src/main"
in order to use the Eclipse compiler instead of sun's comiler. This worked for developpers using windows. On linux, maven tries to execute "java -classpath ...." as a single command, which does not exist.
I am still loking for a solution. the only hack I found was to put the executable "java -classpath ..." in an executable file on my machine and put the name of that file in the tag on maven.
Related
I was testing the move from a Jenkins docker image to another using Thinbacvkup and restore the backup and restore went well and of course it didn't bring maven with it (No problem there) I went online and got the latest apache maven bin file (apache-maven-3.8.4-bin), extracted and set up the global tool configuration, export M2_HOME ...ETC. BUT for some reason, it didn't work giving me the same message
#tmp/durable-e665ee46/script.sh: 1: mvn: not found
searched and searched nothing worked, so I went to the original docker and got the same maven from there (apache-maven-3.5.3-bin)edited the configs and all, and it worked but now I wanted to know why did this work and that won't is there something with my project, build or what?
Not using a Docker image, but had no problem on a clean install, no plugins,
Global Tool Configuration ( /configureTools/ ), add maven configuration:
Create job with Invoke top-level maven step, choose same maven version:
If a pipeline job, then the reference would be tools:
tools {
maven 'maven-3.8.4'
}
or withMaven:
withMaven(
// Maven installation declared in the Jenkins "Global Tool Configuration"
maven: 'maven-3.8.4',
Works fine. I did not set M2_HOME or add to PATH; Tool configuration takes care of that.
Started by user admin
Running as SYSTEM
Building in workspace C:\Users\jenkins\.jenkins.2.322.new\workspace\M-Foo
Unpacking https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.4/apache-maven-3.8.4-bin.zip to C:\Users\jenkins\.jenkins.2.322.new\tools\hudson.tasks.Maven_MavenInstallation\maven-3.8.4 on Jenkins
[M-Foo] $ cmd.exe /C "C:\Users\jenkins\.jenkins.2.322.new\tools\hudson.tasks.Maven_MavenInstallation\maven-3.8.4\bin\mvn.cmd -version && exit %%ERRORLEVEL%%"
Apache Maven 3.8.4 (9b656c72d54e5bacbed989b64718c159fe39b537)
Maven home: C:\Users\jenkins\.jenkins.2.322.new\tools\hudson.tasks.Maven_MavenInstallation\maven-3.8.4
Java version: 1.8.0_312, vendor: Temurin, runtime: C:\Tools\Java\jdk8\jre
Default locale: en_CA, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
Finished: SUCCESS
Apache Maven 3.8.4 (9b656c72d54e5bacbed989b64718c159fe39b537)
Maven home: C:\Users\jenkins.jenkins.2.322.new\tools\hudson.tasks.Maven_MavenInstallation\maven-3.8.4
Note: you must have proxy set up properly for the "Install from Apache" to populate for "Install automatically".
If you un-tick "Install automatically", then you must input the MAVEN_HOME (which should really be labelled M2_HOME) and then choose that.
Started by user admin
Running as SYSTEM
Building in workspace C:\Users\jenkins\.jenkins.2.322.new\workspace\M-Foo
[M-Foo] $ cmd.exe /C "C:\Tools\apache-maven\apache-maven-3.8.1\bin\mvn.cmd -version && exit %%ERRORLEVEL%%"
Apache Maven 3.8.1 (05c21c65bdfed0f71a2f2ada8b84da59348c4c5d)
Maven home: C:\Tools\apache-maven\apache-maven-3.8.1\bin\..
Java version: 1.8.0_312, vendor: Temurin, runtime: C:\Tools\Java\jdk8\jre
Default locale: en_CA, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
Finished: SUCCESS
Apache Maven 3.8.1 (05c21c65bdfed0f71a2f2ada8b84da59348c4c5d)
Maven home: C:\Tools\apache-maven\apache-maven-3.8.1\bin..
While running a build in Jenkins Maven is complaining about JDK. I know very well that it's some challenge with env variables. I have set JAVA_HOME to JDK installation path but no luck. I have searched the whole web and know that other people have faced this but their solution isn't working for me. Any help would be really appreciated !
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
[INFO] 1 error
FYR, my maven version output.
root#zarvis:~# mvn -version
Apache Maven 3.3.3 (7994120775791599e205a5524ec3e0dfe41d4a06; 2015-04-22T17:27:37+05:30)
Maven home: /usr/local/apache-maven-3.3.3
Java version: 1.7.0_101, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-7-openjdk-amd64/jre
Default locale: en_IN, platform encoding: UTF-8
OS name: "linux", version: "3.19.0-31-generic", arch: "amd64", family: "unix"
JAVA_HOME is set but not sure why maven appends it with JRE.
root#zarvis:~# echo $JAVA_HOME
/usr/lib/jvm/java-1.7.0-openjdk-amd64
Thanks in advance !
Try adding JDK_HOME to your path
New to maven. When I run this command i get access denied error? any help? I am trying to configure maven to run with eclipse. Let me know if you need more information.
mvn -Declipse.workspace=<c:\temp\eclipse\workspace>eclipse:add-mvn-repo
Path:
C:\apache-tomcat-7.0.55\bin;C:\apache-ant-1.9.4-bi
n\bin;C:\apache-maven-3.2.2\bin;C:\Program Files (x86)\Google\google_appengine\
C:\Temp\eclipse\workspace>mvn -v
Apache Maven 3.2.2 (45f7c06d68e745d05611f7fd14efb6594181933e; 2014-06-17T09:51:4
2-04:00)
Maven home: C:\apache-maven-3.2.2\bin\..
Java version: 1.7.0_25, vendor: Oracle Corporation
Java home: C:\Program Files\Java\jdk1.7.0_25\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows"
C:\Temp\eclipse\workspace>cd\Temp\eclipse\workspace
**C:\Temp\eclipse\workspace>mvn -Declipse.workspace=<C:\Temp\eclipse\workspace> eclipse:add-maven-repo
Access is denied.
C:\Temp\eclipse\workspace>**
Configuring Maven to run within Eclipse.
Eclipse has an embedded version of Maven which you can use. Assuming that you want to use Maven within Eclipse and outside of it, download Maven from http://maven.apache.org/download.cgi, extract it and set the M2_HOME environment variable such that it points to your local Maven installation directory.
Set JAVA_HOME environment variable so that it points to the JDK which you want to use.
Append %JAVA_HOME%\bin and %M2_HOME%\bin to the Path so that the jdk and mvn executables can be executed from anywhere.
Now open an Eclipse Workspace and go to Window > Preferences > Maven > Installations. If you want to use your standalone installation instead of using the embedded one, you can change it here.
If you have a specific Maven settings file which you want to use, then dump that settings.xml file under the .m2 folder of your User home directory.
Once this is done, you can easily use Maven from within eclipse.(File > Import > Maven > Existing Maven Projects) or create a new one (File > New > Maven > Maven Project). Once you have a project in your workspace, you can run different Maven goals on it by right clicking on the Project and selecting what you want from the Run As option.
When I try to compile a project with Maven I get the following error:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project webserverlog: Compilation failure
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project webserverlog: Compilation failure
No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
My JAVA_HOME is pointing to the JDK:
$ echo $JAVA_HOME
/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home
$ $JAVA_HOME/bin/javac -version
javac 1.7.0_25
javac: no source files
Usage: javac <options> <source files>
I'm not sure why Maven adds '/jre' to the end of JAVA_HOME, but looking at some other posts this doesn't seem to be the problem:
$ mvn --version
Apache Maven 3.0.4 (r1232337; 2012-01-17 18:44:56+1000)
Maven home: /Users/jerry/dev/springsource/apache-maven-3.0.4
Java version: 1.7.0_25, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.7.0_25.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.8.4", arch: "x86_64", family: "mac"
I've searched for a solution to this problem and tried different things for the last couple of days, but can't find anything that works. I've seen some threads with a similar problem, but none of the suggestions worked for me.
Does anyone know how to solve this? Any help greatly appreciated...
You should assign the real path to the JDK to the JAVA_HOME variable instead of leaving the CurrentJDK literal. For some reason in Mac OS X the CurrentJDK is not pointing to the actual one regarding Maven. Try something like this in your .profile but replacing you actual jdk folder name:
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home
FYI, one cause of "no source files" is lack of disk space wherever tmp points.
Looks like maven and javac store some items in TEMP/TMP/TMDIR and if that director doesn't exist, lacks space, lacks permissions then you can see that problem. at least we did on windows and I suspect it'll happen on better operating systems too.
I am having some trouble building a Maven project on my Windows machine. I have set my JAVA_HOME environment variable and Maven finds it.
Here are come results from a few executions:
'which mvn'
/cygdrive/c/Program Files/Apache/apache-maven-3.0.5/bin/mvn
'mvn -version'
Apache Maven 3.0.5 (r01de14724cdef164cd33c7c8c2fe155faf9602da; 2013-02-19 05:51:28 0800)
Maven home: C:\Program Files\Apache\apache-maven-3.0.5
Java version: 1.6.0_45, vendor: Sun Microsystems Inc.
Java home: C:\Program Files\Java\jdk1.6.0_45\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 8", version: "6.2", arch: "amd64", family: "windows"
Note: It does find the proper JAVA_HOME path here!
Building w/ Maven:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.
0.2:compile (default-compile) on project sportbukkit-api: Compilation failure
[ERROR] Unable to locate the Javac Compiler in:
[ERROR] C:\Program Files\Java\jre6\..\lib\tools.jar
[ERROR] Please ensure you are using JDK 1.4 or above and
[ERROR] not a JRE (the com.sun.tools.javac.Main class is required).
[ERROR] In most cases you can change the location of your Java
[ERROR] installation by setting the JAVA_HOME environment variable.
As you can see, for some reason it is looking in the completely wrong directory. Please let me know if any more info is needed or if you know how to fix this! Thank you!
Try setting your JAVA_HOME to C:\Program Files\Java\jdk1.6.0_45 instead of C:\Program Files\Java\jdk1.6.0_45\jre