Issue with deploying Java 11 app to Heroku from GitLab [duplicate] - java

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>

Related

Error while running building maven project - plugins, API incompatibility

I am facing problem while trying to run maven build with JDK6. I am running build inside docker container with JDK6 and Maven.
Do I get it right, that the plugins are not compatibile with JDK6 version and I should use lower version of help plugin? I cannot change JDK version to higher, I ran into this problem while trying to enable bulding project with JDK6, so I want to solve this problem.
error message from Maven:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-help-plugin:3.2.0:evaluate (default-cli) on project security-component: Execution default-cli of goal org.apache.maven.plugins:maven-help-plugin:3.2.0:evaluate failed: Unable to load the mojo 'evaluate' in the plugin 'org.apache.maven.plugins:maven-help-plugin:3.2.0' due to an API incompatibility: org.codehaus.plexus.component.repository.exception.ComponentLookupException: org/apache/maven/plugins/help/EvaluateMojo : Unsupported major.minor version 51.0
[ERROR] -----------------------------------------------------
[ERROR] realm = plugin>org.apache.maven.plugins:maven-help-plugin:3.2.0
mvn -version output:
Maven home: /usr/share/maven
Java version: 1.6.0_41, vendor: Sun Microsystems Inc.
Java home: /usr/lib/jvm/java-6-openjdk-amd64/jre
indeed problem was in too high version of help plugin, I lower it to 2.2 and its fine
adding direct path to selected version of help plugin worked for me:
$MVN_CMD org.apache.maven.plugins:maven-help-plugin:2.2:evaluate

Failed to build app with Maven, I can run code locally, but fail to deploy on heroku

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>

Need help?? Fatal error compiling: invalid target release: 1.8

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.

java.nio.file.NoSuchFileException: /home/user/java/8.0.181-oracle/jre/lib/jfxrt.jar while executing scala program using `sbt runMain`

I'm trying to run a program from SBT using sbt runMain command.
But I'm getting below error -
[error] java.nio.file.NoSuchFileException: /home/user/java/8.0.181-oracle/jre/lib/jfxrt.jar
[error] at sun.nio.fs.UnixException.translateToIOException(UnixException.java:86)
[error] at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
[error] at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)
[error] at sun.nio.fs.UnixFileAttributeViews$Basic.readAttributes(UnixFileAttributeViews.java:55)
[error] at sun.nio.fs.UnixFileSystemProvider.readAttributes(UnixFileSystemProvider.java:144)
[error] at sun.nio.fs.LinuxFileSystemProvider.readAttributes(LinuxFileSystemProvider.java:99)
[error] at java.nio.file.Files.readAttributes(Files.java:1737)
[error] at java.nio.file.FileTreeWalker.getAttributes(FileTreeWalker.java:219)
[error] at java.nio.file.FileTreeWalker.visit(FileTreeWalker.java:276)
[error] at java.nio.file.FileTreeWalker.walk(FileTreeWalker.java:322)
[error] at java.nio.file.Files.walkFileTree(Files.java:2662)
[error] at java.nio.file.Files.walkFileTree(Files.java:2742)
[error] (Compile / runMain) java.nio.file.NoSuchFileException: /home/rajkumar/java/8.0.181-oracle/jre/lib/jfxrt.jar
[error] Total time: 12 s, completed Aug 23, 2018 10:21:44 PM
SBT version details
$ sbt about
[info] This is sbt 1.2.1
[info] The current project is ProjectRef(uri("file:/home/rajkumar/Coding/Java/ConcurrentProgrammingInScala/"), "concurrentprogramminginscala") 0.1
[info] The current project is built against Scala 2.12.6
The java version details -
$ 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)
Also I couldn't find jfxrt.jar file anywhere within jdk folder.
$ find . -type f -name jfxrt.jar
This command return no results.
The fedora version is -
$ cat /etc/fedora-release
Fedora release 28 (Twenty Eight)
Why do I get this this error? How to resolve this error?
I believe the problem lies with the directory structure of the Java JRE. Clearly, your jfxrt.jar is not where your program thinks it is, and this is because in Java 8 this jar is in the java/<version>/jre/lib/ext/ directory as opposed to java/<version>/jre/lib/ which is where your program is looking for it as it seems from the stack trace. One sort of hacky way of fixing this would be to copy your jfxrt.jar to the java/<version>/jre/lib/ directory so it would find the file properly.
There may exist a more stable/safe solution for this, but until I (or someone else) finds this way, I would do this. Leave a comment if you have a question and I'll do my best to answer it. Hope this helps!
EDIT: I was searching around SO, and it appears that this question should also maybe help with getting the path set correctly.

Jenkins maven Unable to locate the Javac compiler in JDK

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 ......

Categories

Resources