Java maven build failure with source 1.7 (or 7) - java

I am upgrading my java 6 code to java 7. Have updated JAVA_HOME to point to JDK 1.7 on OS X 10.9. The code is not using any Java 7 features yet.
When I run the build "mvn clean install" the build breaks without any helpful error message.
The build succeeds with source=1.6 & target=1.6
But fails for source=1.7 (or 7) & target=1.7 (or 7)
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version> <!-- tried with 2.3.2 and 3.0... no luck -->
<configuration>
<source>7</source>
<target>7</target>
<compilerArgument>-Werror </compilerArgument>
<fork>true</fork>
</configuration>
Error Message:
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 8.773 s
[INFO] Finished at: 2014-06-25T14:56:13-08:00
[INFO] Final Memory: 10M/245M
[INFO] ------------------------------------------------------------------------
[**ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:testCompile (default-testCompile) on project core: Compilation failure
[ERROR] Failure executing javac, but could not parse the error:
[ERROR] 1 error
[ERROR] -> [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/MojoFailureException

I'm guessing that compiling your code with JDK 1.7 produces warnings that compiling with 1.6 did not. Since you're telling the compiler to simply quit when it encounters a warning with <compilerArgument>-Werror </compilerArgument>, that's exactly what it's doing, which isn't very Maven-friendly. I'm guessing Maven swallows the original warning in favor of showing the error of the javac process quitting unexpectedly.
Removing the <compilerArgument>-Werror </compilerArgument> directive should allow compilation to continue. You'll have to deal with the compiler warnings a better way than by just having the compiler quit, perhaps by looking at/parsing the Maven output.

Related

How to deploy spring boot to heroku?

I wanted to deploy my application to heroku server and I am facing this problem. Any idea?
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 13.339 s
[INFO] Finished at: 2021-08-09T04:05:01Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project russion_spring_boot: 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
<properties>
<java.version>15.0.1</java.version>
</properties>
Logs depict the error - invalid target release: 11. Basically this error means that you have mentioned higher/mismatched version of Java in maven compiler's source and target java version settings in your pom.xml compared to the JDK which is being pointed out by JAVA_HOME environment variable.
To fix this error, just check the Java version in pom.xml and JAVA_HOME. They should match.
To know more about this issue, check this post - https://dzone.com/articles/how-to-fix-invalid-target-release-17-18-19-or-110

Apache Beam execution

I'm following this example but in the step: Run WordCount, throught direct command
$ mvn compile exec:java -Dexec.mainClass=org.apache.beam.examples.WordCount \
-Dexec.args="--inputFile=pom.xml --output=counts" -Pdirect-runner
And finally I have this error:
[INFO] -----------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 12.065 s
[INFO] Finished at: 2018-10-02T17:36:05+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.6.0:java (default-cli) on project word-count-beam: An exception occured while executing the Java class. java.lang.UnsupportedOperationException: Cannot define class using reflection: Could not find sun.misc.Unsafe -> [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] 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
You need to use the Java Development Kit (JDK) version 8. Verify that the JAVA_HOME environment variable is set and points to your JDK installation.
To understand this change better, read:
The official Feature Request JEP 260: Encapsulate Most Internal APIs.
Understanding sun.misc.Unsafe

Alfresco-Addon Java

I want to develop a ticket-system Add-On for Alfresco,
I am new into Alfresco so I have some troubles getting started
I have downloaded maven and set the path var
Also for java and javac
And now I installed an simple Maven projects with the command
mvn archetype:generate -Dfilter=org.alfresco:
everything installed fine.
Then I tried used the command
mvn install
but there I get the error:
[INFO] Compiling 3 source files to E:\HTL\Alfresco\maven_projects\quick-
start-project\target\classes
[INFO] -------------------------------------------------------------
[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
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.473 s
[INFO] Finished at: 2018-04-17T15:58:33+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.5:compile (default-compile) on project quick-start-project: Compilation failure
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
[ERROR]
[ERROR] -> [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/MojoFailureException
I also tried to run the run.bat file in my folder, but it closed after some time with an error!
Can anyone help me and has some tips for getting started in developing for Alfresco?
please try this
On your Eclipse IDE, go into Window > Preferences > Java > Installed JREs >
and check your installed JREs.
You should have an entry with a JDK there.
Select the Execution Env as show below.
Click OK
Then Right-Click on your Project -> Maven -> Update Project
and select jdk
refer this community link may help you

Maven Surefire plugin "error in starting fork" while building project with Intellij IDEA

I was trying building a Java plugin with Maven using Intellij IDEA until I came across an error:
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.803 s
[INFO] Finished at: 2015-06-16T16:34:55-10:00
[INFO] Final Memory: 17M/216M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.18.1:test (default-test) on project mc-hyperchat: Error occurred in starting fork, check output in log -> [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/MojoFailureException
I realize that this is because of this line (that I found using the -X flag)
Forking command line: cmd.exe /X /C ""D:\Program Files\Java\jdk1.8.0_45\jre\bin\java" -jar C:\Users\<username>\Documents\+GIT\mc-hyperchat\target\surefire\surefirebooter8505511050498586005.jar C:\Users\<username>\Documents\+GIT\mc-hyperchat\target\surefire\surefire5990474653240919844tmp C:\Users\<username>\Documents\+GIT\mc-hyperchat\target\surefire\surefire_08408900793313340679tmp"
The system cannot find the path specified.
I happen to come across somebody else with the exact same problem:
Maven Surefire 2.13 fails to fork on Windows
The accepted answer seems to be that his JAVA_HOME environment variable was invalid, so I checked mine:
I also echoed the variable on the Command Prompt to make sure it didn't have any quotation marks in it (also me running cmd.exe to see another The system cannot find the path specified message):
I'm convinced my JAVA_HOME environment variable is correct. If that's the case, what else could've caused this problem?
I found this to be a windows related error -
Open the Registry Editor
Navigate to HKCU\Software\Microsoft\Command Processor\AutoRun and clear the values.
Also check HKLM\Software\Microsoft\Command Processor\AutoRun.

Ninja framework Install Error with Maven

I'm trying to learn Ninja framework for building RESTful web services at here
I got the following error when I run "mvn clean install" inside the newly created maven project folder:
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.610 s
[INFO] Finished at: 2014-05-19T11:39:50-07:00
[INFO] Final Memory: 11M/81M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project ninja: Fatal error compiling: invalid target release: 1.7 -> [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
I am on Mac Mavericks with Java 8, if this matters. Thanks
well, it may sound silly, but I fixed the problem by adding JAVA_HOME to the path on my Mac, otherwise, maven still uses Java 1.6 (I've installed Java 1.8) on my computer.
export JAVA_HOME=$(/usr/libexec/java_home)

Categories