I am trying to build Apache Spark on a Mac. Since I use Macports, the Homebrew option is not feasible. So I manually installed the right version of java and maven and created the right paths:
Sankha-desktop:spark-1.6.1 user$ mvn -version
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-11T00:41:47+08:00)
Maven home: /opt/local/share/java/maven33
Java version: 1.7.0_79, vendor: Oracle Corporation
Java home:
/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.11.3", arch: "x86_64", family: "mac"
Now when I try to install Spark, I get the following error:
Sankha-desktop:spark-1.6.1 user$ build/mvn -Pyarn -Phadoop-2.4 -Dhadoop.version=2.4.0 -DskipTests clean package
Using `mvn` from path: /opt/local/share/java/maven33/bin/mvn
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
~~~~~~~ some more stuff ~~~~~~~
[info] Compiling 3 Java sources to /Users/user/Documents/installers/spark/spark-1.6.1/tags/target/scala-2.10/classes...
[error] javac: invalid source release: 1.7
[error] Usage: javac <options> <source files>
[error] use -help for a list of possible options
[error] Compile failed at Apr 11, 2016 6:14:07 AM [0.024s]
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] Spark Project Parent POM ........................... SUCCESS [ 7.176 s]
[INFO] Spark Project Test Tags ............................ FAILURE [ 1.027 s]
[INFO] Spark Project Launcher ............................. SKIPPED
[INFO] Spark Project Networking ........................... SKIPPED
Apparently my java version is wrong? I explicitly installed version 1.7, and linked to it. I also have the latest version 1.8, but I already removed that from the JAVA_PATH.
Anyone knows what is going on?
I think this is related to the Zinc compiler.
I was able to get it to compile by disabling the Zinc compiler in the pom.xml file. Change this:
<useZincServer>true</useZincServer>
to this:
<useZincServer>false</useZincServer>
My error message was a little bit different as the Zinc compiler was looking for javac in my JRE directory. I tried to figure out how to set a different java_home for Zinc, but couldn't figure it out (there is a -java-home argument, and I tried to add it to the pom, but it didn't seem to have an effect).
Here is the Spark documentation regarding Zinc:
http://spark.apache.org/docs/latest/building-spark.html#speeding-up-compilation-with-zinc
Here is the Zinc GitHub page:
https://github.com/typesafehub/zinc
UPDATE: This may be an issue in the scala-maven-plugin - https://github.com/davidB/scala-maven-plugin/issues/173
Related
This is my code in github:
https://github.com/q463746583/CS4500-Assignment2
I can run it successfully in the local,
but while I try to deploy the code on heroku,
There is the error description:
[INFO] Downloaded from central: https://repo.maven.apache.org/maven2/com/thoughtworks/qdox/qdox/2.0-M9/qdox-2.0-M9.jar (317 kB at 6.0 MB/s)
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 4 source files to /tmp/build_3c4f3b86a26f6e3ae1cbe89639f79f26/target/classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 13.261 s
[INFO] Finished at: 2019-01-24T00:47:07Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) on project myapp: Fatal error compiling: invalid target release: 11 -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
! ERROR: Failed to build app with Maven
We're sorry this build is failing! If you can't find the issue in application code,
please submit a ticket so we can help: https://help.heroku.com/
! Push rejected, failed to compile Java app.
! Push failed
TLDR:
Ensure you're using the appropriate JAVA JDK
Check that your target environment from the Maven compiler is the same as your targeted Heroku JAVA runtime.
If you're not using the default JAVA 8 JDK runtime environment create a system.properties file in your project specifying a different supported JAVA runtime enviroment as listed within Heroku's JAVA buildpack documentation.
I think this has to do with a mismatch between your targeted Java runtime environment on Heroku and your locally compiled code, generated from the Maven compiler, which you're trying to push to Heroku.
According to Heroku's documentation:
Heroku currently uses OpenJDK 8 to run your application by default. OpenJDK versions 9 and 7 are also available.
Other supported default versions are:
Java 7 - 1.7.0_181
Java 8 - 1.8.0_191
Java 9 - 9.0.4
Java 10 - 10.0.2
Java 11 - 11
So you should make sure that within your pom.xml file that your maven compiler is compiling your JAVA code to the appropriate JAVA buildpack you're targeting on Heroku. For example, below we are targeting a Java 7 runtime environment:
pom.xml:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
Then you should create a system.properties file in your project if you're targeting a runtime environment other than Heroku's default JDK 1.8 runtime environment. You can do this by specifying your desired java runtime environment like such:
system.properties:
java.runtime.version=11
As per the previous answers, creating a system.properties file, making a new commit with that change and rerunning the heroku command fixed the issue for me.
Also, please be mindful about the name of your branch if you're not using main as your main branch as that would require a match such as.
git push heroku master:main
or
git push heroku develop:main
I got the same error while deploying the git project in Heroku. I just changed java.version to 8 from 11 in pom.xml and it worked for me:
<properties>
<java.version>8</java.version>
</properties>
To remove this error, simply add one extra file into your repository with the name system.application and
java.runtime.version=11
Tried all the approaches, but none worked.
SOLUTION: Remove all the references to your Java version in your pom.xml, i.e.
<properties>
<java.version>11</java.version>
</properties>
This is my code in github:
https://github.com/q463746583/CS4500-Assignment2
I can run it successfully in the local,
but while I try to deploy the code on heroku,
There is the error description:
[INFO] Downloaded from central: https://repo.maven.apache.org/maven2/com/thoughtworks/qdox/qdox/2.0-M9/qdox-2.0-M9.jar (317 kB at 6.0 MB/s)
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 4 source files to /tmp/build_3c4f3b86a26f6e3ae1cbe89639f79f26/target/classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 13.261 s
[INFO] Finished at: 2019-01-24T00:47:07Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) on project myapp: Fatal error compiling: invalid target release: 11 -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
! ERROR: Failed to build app with Maven
We're sorry this build is failing! If you can't find the issue in application code,
please submit a ticket so we can help: https://help.heroku.com/
! Push rejected, failed to compile Java app.
! Push failed
TLDR:
Ensure you're using the appropriate JAVA JDK
Check that your target environment from the Maven compiler is the same as your targeted Heroku JAVA runtime.
If you're not using the default JAVA 8 JDK runtime environment create a system.properties file in your project specifying a different supported JAVA runtime enviroment as listed within Heroku's JAVA buildpack documentation.
I think this has to do with a mismatch between your targeted Java runtime environment on Heroku and your locally compiled code, generated from the Maven compiler, which you're trying to push to Heroku.
According to Heroku's documentation:
Heroku currently uses OpenJDK 8 to run your application by default. OpenJDK versions 9 and 7 are also available.
Other supported default versions are:
Java 7 - 1.7.0_181
Java 8 - 1.8.0_191
Java 9 - 9.0.4
Java 10 - 10.0.2
Java 11 - 11
So you should make sure that within your pom.xml file that your maven compiler is compiling your JAVA code to the appropriate JAVA buildpack you're targeting on Heroku. For example, below we are targeting a Java 7 runtime environment:
pom.xml:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
Then you should create a system.properties file in your project if you're targeting a runtime environment other than Heroku's default JDK 1.8 runtime environment. You can do this by specifying your desired java runtime environment like such:
system.properties:
java.runtime.version=11
As per the previous answers, creating a system.properties file, making a new commit with that change and rerunning the heroku command fixed the issue for me.
Also, please be mindful about the name of your branch if you're not using main as your main branch as that would require a match such as.
git push heroku master:main
or
git push heroku develop:main
I got the same error while deploying the git project in Heroku. I just changed java.version to 8 from 11 in pom.xml and it worked for me:
<properties>
<java.version>8</java.version>
</properties>
To remove this error, simply add one extra file into your repository with the name system.application and
java.runtime.version=11
Tried all the approaches, but none worked.
SOLUTION: Remove all the references to your Java version in your pom.xml, i.e.
<properties>
<java.version>11</java.version>
</properties>
i want to deploy my maven project to Google Appengine, however an error in that
[INFO] --- maven-compiler-plugin:3.8.0:compile (default-compile) #HospitalReservationSystem ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to /home/rof/src/github.com/jessezzyy/Hospital-Reservation-System/target/HospitalReservationSystem-1.0-SNAPSHOT/WEB-INF/classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.062 s [INFO] Finished at: 2018-09-26T15:17:24Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) on project HospitalReservationSystem: Fatal error compiling: invalid target release: 1.8 -> [Help 1]
The maven project is exactly using java8, and my java jdk is also 1.8enter image description here
ZIJIANdeMacBook-Pro:JavaVirtualMachines Jesse$ echo $JAVA_HOME/Library/Java/JavaVirtualMachines/jdk1.8.0_181.jdk/Contents/HomeZIJIANdeMacBook-Pro:JavaVirtualMachines Jesse$ java -version
java version "1.8.0_181"
Java(TM) SE Runtime Environment (build 1.8.0_181-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.181-b13, mixed mode)
I have tried to change 1.7 instead of 1.8, but it shows error:
Execution default-cli of goal com.google.cloud.tools:appengine-maven-plugin:1.3.2:deploy failed: Non zero exit: 1 -> [Help 1]
First you have to make sure that you have Java 8 and its corresponding compiler installed.
Test that by executing the following code:
java -version
and
javac -version
and
mvn -version
They should be the same version. Sometimes the java is pointing to the right version but javac version might point to an old jdk. If this is the case, you can apply the following steps:
A:Ensure the symbolic link is pointing to the correct jdk. if not, just remove it and recreate a new one for your jdk.
Code:
cd /System/Library/Frameworks/JavaVM.framework/Versions/
rm CurrentJDK
ln -s /Library/Java/JavaVirtualMachines/<jdk version>.jdk/Contents/ CurrentJDK
B:Remove the tools.jar from the extension since it could be related to the old version:
Code:
cd /Library/Java/Extensions
-rw-r--r-- 1 root admin 15286304 Jan 14 2015 tools.jar
Remove this:
sudo rm -rf /Library/Java/Extensions
In addition, you also need to make sure you %JAVA_HOME is set to 1.8 once you install the 1.8 jdk. Keep in mind that Invalid target release refers to the jdk version.
Another solution is to fork the maven-compiler-plugin and set the full path to the correct Java compiler as below:
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<verbose>true</verbose>
<fork>true</fork>
<executable>C:\Program Files\Java\jdk1.8.0_79\bin\javac</executable>
</configuration>
</plugin>
This issue has already been posted along with useful answers and possible solutions to your question: Click Here
Here is another question previously posted regarding the same issue: Click Here
Though this is pretty old post, I thought I will share my quick fix for others use:
I also had faced similar issue where pom.xml is pointing 1.8 and JAVA_HOME is also pointing to 1.8
Maven build was failing through eclipse.
To address this issue, all I had to do is change the JRE version to 1.8 in JRE tab using Alternate JRE option as shown in attached screen shot.
Problem : Unable to build spring maven project using Jenkins with JDK 1.8
Description : Im using Jenkins to build my spring project managed by Maven.I have configured Java 1.7 and 1.8 in Jenkins using the JDK Installations options. when selecting Java 1.7 in the build configuration and running the build, build process is success. But when i select Java 1.8 in the build configuration and running the build, build process gets failed.
****Below is the jenkins console output****
Started by user anonymous
Building in workspace C:\Users\anonymous\.jenkins\jobs\springsecuritysampleproject1\workspace
Updating file:///C:/DevEnv/Repositories/LocalSVNServerRepo/root/springsecuritysample/trunk at revision '2016-01-13T13:35:52.488 +0530'
U src\main\java\org\springframework\security\sample\HomeController.java
At revision 21
Parsing POMs
[workspace] $ C:\DevEnv\ProgramFiles\Java\jdk1.8.0_20/bin/java -cp C:\Users\anonymous\.jenkins\plugins\maven-plugin\WEB-INF\lib\maven31-agent-1.5.jar;C:\DevEnv\ProgramFiles\ProjectTools\Apache_Maven_3.3.3\boot\plexus-classworlds-2.5.2.jar;C:\DevEnv\ProgramFiles\ProjectTools\Apache_Maven_3.3.3/conf/logging jenkins.maven3.agent.Maven31Main C:\DevEnv\ProgramFiles\ProjectTools\Apache_Maven_3.3.3 C:\Users\anonymous\.jenkins\war\WEB-INF\lib\remoting-2.53.2.jar C:\Users\anonymous\.jenkins\plugins\maven-plugin\WEB-INF\lib\maven31-interceptor-1.5.jar C:\Users\anonymous\.jenkins\plugins\maven-plugin\WEB-INF\lib\maven3-interceptor-commons-1.5.jar 52876
<===[JENKINS REMOTING CAPACITY]===>channel started
Executing Maven: -B -f C:\Users\anonymous\.jenkins\jobs\springsecuritysampleproject1\workspace\pom.xml install
Waiting for Jenkins to finish collecting data
[JENKINS] Archiving C:\Users\anonymous\.jenkins\jobs\springsecuritysampleproject1\workspace\pom.xml to org.springframework.security/sample/1.0.0-BUILD-SNAPSHOT/sample-1.0.0-BUILD-SNAPSHOT.pom
Sending e-mails to: test#test.com
channel stopped
Archiving artifacts
Sending e-mails to: test#test.com
Finished: FAILURE
*
I also ran Maven manually with Java 1.7 and no issues observerd. But
when i ran the same with Java 1.8 and redirected the output to file,
found the below error
*
INFO] Compiling 1 source file to C:\DevEnv\STSWorkspaces\springsecuritysample\target\classes
[INFO] -------------------------------------------------------------
**[ERROR] COMPILATION ERROR :**
[INFO] -------------------------------------------------------------
[ERROR] Unable to locate the Javac Compiler in:
C:\DevEnv\ProgramFiles\Java\jdk1.8.0_20\..\lib\tools.jar
Please ensure you are using JDK 1.4 or above and
not a JRE (the com.sun.tools.javac.Main class is required).
In most cases you can change the location of your Java
installation by setting the JAVA_HOME environment variable.
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.640 s
[INFO] Finished at: 2016-01-13T13:40:34+05:30
[INFO] Final Memory: 8M/487M
[INFO] ------------------------------------------------------------------------
JAVA_HOME variable is correctly pointing to the JDK 1.8 installation home directory and the bin folder is also added to the path
echo %JAVA_HOME% results in C:\DevEnv\ProgramFiles\Java\jdk1.8.0_20
When changed the JAVA_HOME variable to point to Java 1.7, build is running normally and no errors
Root Cause
when debugged, it ended up in the file JavacCompiler.java of artifact plexus-compiler-javac. The line System.getProperty( "java.home" ) in the compile process outputs differently for Java 8 and Java 7
Java 7 - C:\DevEnv\ProgramFiles\Java\jdk1.7.0_80\jre
Java 8 - C:\DevEnv\ProgramFiles\Java\jdk1.8.0_20
Worked Solution :
Re-installation of Java 8
Launch the slave through cmd but dont type "java -jar slave.jar .....", rather mention the complete path of java.exe as "C:\Program Files\Java\jdk1.8.0_121\bin\java.exe" -jar slave.jar ......
I'm working on Fedora, my java home is set as :
export JAVA_HOME=/home/UserName/java
export M3_HOME=/home/UserName/softwares/apache-maven-3.0.3
export PATH=$PATH:/home/UserName/java/bin:/home/Udeshika/softwares/apache-maven-3.0.3/bin
Now when I try to run mvn install for maven project, I'm getting following error
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project viewer: Compilation failure
[ERROR] Unable to locate the Javac Compiler in:
[ERROR] /home/UserName/java/jre/../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.
[ERROR] -> [Help 1]
[ERROR]
if I check my maven version
Apache Maven 3.0.3 (r1075438; 2011-02-28 23:01:09+0530)
Maven home: /home/UserName/softwares/apache-maven-3.0.3
Java version: 1.6.0_07, vendor: Sun Microsystems Inc.
Java home: /home/UserName/java/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "2.6.34.9-69.fc13.i686.pae", arch: "i386", family: "unix"
Here maven tells my JAVA_HOME is
Java home: /home/UserName/java/jre
I think I have identified the problem now I don't know to solve it can anyone guide me to solve this problem ??
Thank you in advance
You need to have a Java SDK in order to use Maven. The SDK contains the tools.jar and allows you to compile, whereas the JRE is just a runtime.