SpringBoot, Maven, Lombok StackOverflowErrorESC - java

I have maven project that success build on Windows environment.
C:\java\apache-maven-3.6.3\bin\mvn -DskipTests=true package -P prod
Build success
but when I've tried to execute the same command on Ubuntu env
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.10.1:compile (default-compile) on project ics3: Fatal error compiling: java.lang.StackOverflowError -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.10.1:compile (default-compile) on project ics3: Fatal error compiling
Caused by: org.apache.maven.plugin.MojoExecutionException: Fatal error compiling
at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute (AbstractCompilerMojo.java:1220)
Caused by: org.codehaus.plexus.compiler.CompilerException: java.lang.StackOverflowError
at org.codehaus.plexus.compiler.javac.JavaxToolsCompiler.compileInProcess (JavaxToolsCompiler.java:197)
Caused by: java.lang.StackOverflowError
at lombok.javac.JavacAST.drill (JavacAST.java:506)
I've tried to set without luck the same memory to maven as on Windows PC
export MAVEN_OPTS="-Xmx3096m -XX:MaxPermSize=512m"
and export JAVA_OPTIONS="-Xmx4g"
my pom.xml is
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
Java 11, SpringBoot 2.7

MAVEN_OPTS="-Xms512m -Xmx2048m -Xss1024m" fixed issue. even -Xss1024k was enought.

Related

Java maven project, build failing to version mismatch

I have cloned a git repo and am trying to build it locally, but getting the following error
[INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 0.850 s [INFO] Finished at:
2021-07-12T15:42:57+02:00 [INFO]
------------------------------------------------------------------------ [ERROR] Failed to execute goal
org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile
(default-compile) on project gtvg: Fatal error compiling: invalid
flag: --release -> [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 have java jdk 8 and 11 installed, currently using java 8
java -version
16:03:24
openjdk version "1.8.0_242"
OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_242-b08)
OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.242-b08, mixed mode)
and maven
mvn -version
Apache Maven 3.6.3
the pom.xml is really large, so I will post the part which I assume is relevant
<properties>
<java.version>8</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<maven.compiler.release>${java.version}</maven.compiler.release>
<project.build.sourceEncoding>US-ASCII</project.build.sourceEncoding>
<thymeleaf.version>3.0.12.RELEASE</thymeleaf.version>
</properties>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
<include>**/*.html</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.2.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.3.1</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
</plugin>
</plugins>
I had hoped (not sure if I am doing the right thing) changing from 3.8.1
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
to 3.6.3
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.3</version>
could solve my issues. But that doesn't work and end up getting another error
Cannot resolve plugin org.apache.maven.plugins:maven-compiler-plugin:3.6.3
How do i get it to build successfully? I am flexible regarding Java versions. I am allowed to use Java 8 - Java 12, but if possible no changes to the Maven version. It should stay as is 3.6.3
You could write one of both 8 or 1.8 into your java version property to declare Java 8. And using Java 8 you can not use maven.compiler.release which could be used only with Java 9+
<java.version>8</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>

mvn exec:java throws ClassNotFoundException when executed on Jetbrains TeamCity

I ran into issue with executing maven exec:java on Jetbrain's TeamCity. The configuration works without any issues locally but on TC it throws constantly:
java.lang.ClassNotFoundException: "…"
at java.net.URLClassLoader.findClass (URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass (ClassLoader.java:424)
at java.lang.ClassLoader.loadClass (ClassLoader.java:357)
at org.codehaus.mojo.exec.ExecJavaMojo$1.run (ExecJavaMojo.java:270)
at java.lang.Thread.run (Thread.java:748)
Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.6.0:java (default-cli) on project …: An exception occured while executing the Java class. "…"
TC configuration is fairly simple:
goals: clean install exec:java
additional commandline args: -DskipTests -Dexec.mainClass="…" -Dexec.args="…"
Basically what I'm using locally. However using TC it throws above exception.
I tried explicitly setting current artifact as dependency and configuring compile dependencies as classpath:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<dependencies>
<dependency>
<groupId>…</groupId>
<artifactId>…</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<configuration>
<classpathScope>compile</classpathScope>
</configuration>
</plugin>
But without any luck. Any help would be appreciated.
Try to add <mainClass> in the <configuration> tag, like this :
<configuration>
<mainClass>com.category.main.Master</mainClass>
<classpathScope>compile</classpathScope>
</configuration>
Then run with the command mvn exec:java -Dexec.mainClass=src.com.category.main.Master
Everything boiled down to quotes in Additional Maven command line parameters: - TC passes them as parameters so -Dexec.mainClass="some.package.Class" became"some.package.Class"in maven (instead ofsome.package.Class`)
I finally noticed it when I was comparing debug from local na remote run:
remote:
[DEBUG] joining on thread Thread["my.package.SummaryGenerator".main(),5,"my.package.SummaryGenerator"]
local:
[DEBUG] joining on thread Thread[my.package.SummaryGenerator.main(),5,y.package.SummaryGenerator]

Custom doclet in a maven project - invalid flag

I am trying to generate javadoc on my maven project. I am using Java 1.8, and have written a small doclet project. The pom on my project has -
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9.1</version>
<configuration>
<aggregate>true</aggregate>
<doclet>org.mydoclet.MyDoclet</doclet>
<docletArtifact>
<groupId>mydoclet</groupId>
<artifactId>mydoclet</artifactId>
<version>0.0.1-SNAPSHOT</version>
</docletArtifact>
<additionalOptions>
<additionalOption>-views</additionalOption>
</additionalOptions>
<useStandardDocletOptions>false</useStandardDocletOptions>
<destDir>docs</destDir>
</configuration>
</plugin>
</plugins>
</build>
I try to run javadoc:aggregate on this. I get an error
Failed to execute goal org.apache.maven.plugins:maven-javadoc-plugin:2.9.1:aggregate (default-cli) on project <>: An error has occurred in JavaDocs report generation:
[ERROR] Exit code: 1 - javadoc: error - invalid flag: -Xdoclint:none
[ERROR]
[ERROR] Command line was: <javahome/bin>/javadoc #options #packages
Any ideas on what I am doing wrong?
I have been following the Maven page on writing doclets - https://maven.apache.org/plugins/maven-javadoc-plugin/examples/alternate-doclet.html#

exec-maven-plugin error, even on working example

EDIT5 Updated /
I'm using Maven 3.3.3.
I just create new project and added compile and exec plugin, as examples on web.
I tried to execute, but I got error
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:java (default-cli) on project QNAProject: An exception occured while executing the Java class. com.jadex.qna.QNAProject.App -> [Help 1]<br>
[ERROR] <br>
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.<br>
[ERROR] Re-run Maven using the -X switch to enable full debug logging.<br>
[ERROR] <br>
[ERROR] For more information about the errors and possible solutions, please read the following articles:<br>
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException<br>
I tried exec-maven-plugin version 1.2.1 and 1.4.0, but got same error. Here is my pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.jadex.qna</groupId>
<artifactId>QNAProject</artifactId>
<version>0.1</version>
<packaging>jar</packaging>
<name>QNAProject</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>maven</executable>
<mainClass>com.jadex.qna.QNAProject.App</mainClass>
</configuration>
</plugin>
</plugins>
</build>
</project>
I even tried a working example project from several sites,
such as
http://examples.javacodegeeks.com/enterprise-java/maven/create-java-project-with-maven-example/
http://www.mkyong.com/maven/how-to-create-a-java-project-with-maven/
but I got same error.
I unzipped maven at C:\apache-maven-3.3.3 and created environment variable MAVEN_HOME as same path.
What is the problem?
====================================
EDIT: Here is the result
Well.. I set MAVEN_HOME, not M2_HOME because tutorial what I found said to set it only...
Of course, echo %MAVEN_HOME% shows
C:\apache-maven-3.3.3
is it wrong?
I added %MAVEN_HOME%\bin to PATH variable, but it did not work too.
And, I'm using eclipse
=====================================
EDIT2: Here is full log. I used goal 'clean exec:java -e -X'
It was too long, so I uploaded to my blog here.
And note that I changed repository folder from C:\Users.....m2 to new local repository folder C:\apache-maven-localrepository
https://arincblossom.wordpress.com/2015/06/15/error-logs/
=======================================
EDIT3: I changed maven-compiler-plugin setting like this
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<verbose>true</verbose>
<fork>true</fork>
<executable>${env.JAVA_HOME}/bin/javac</executable>
<compilerVersion>1.5</compilerVersion>
<!-- <source>1.8</source>
<target>1.8</target> -->
</configuration>
</plugin>
It prevented me from having error from mvn -e compile exec:java but I can't run with mvn exec:java -Dexec.mainClass="com.jadex.qna.QNAProject.App"
=================================
EDIT4: OK, I'll try from the bottom, and post again. Thanks for your sincere helps.
======================================
EDIT5
I reset all the sequences... re-installed eclipse, maven.. and re-created projects... but nothing worked...
I changed eclipse settings to fix JDK path to installed jdk path, not JRE path. then I found that 'mvn -e clean compile exec:java' is working, but I want to just 'mvn clean exec:java' work. It does not work at all.
You can check full source here
https://github.com/arincblossom/MavenTestProject
This is current console message for 'mvn -e clean exec:java'
[WARNING]
[WARNING] Some problems were encountered while building the effective settings
[WARNING] expected START_TAG or END_TAG not TEXT (position: TEXT seen ...ore artifacts.\n |\n | Default: ${user.home}/.m2/repository\n <l... #53:5) # C:\apache-maven-3.3.3\conf\settings.xml, line 53, column 5
[WARNING] expected START_TAG or END_TAG not TEXT (position: TEXT seen ...ore artifacts.\n |\n | Default: ${user.home}/.m2/repository\n <l... #53:5) # C:\apache-maven-3.3.3\conf\settings.xml, line 53, column 5
[WARNING]
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building MavenTestProject 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) # MavenTestProject ---
[INFO] Deleting C:\Users\bonavision_laptop\Desktop\Project\JadeX\MavenTestProject\MavenTestProject\target
[INFO]
[INFO] --- exec-maven-plugin:1.4.0:java (default-cli) # MavenTestProject ---
[WARNING]
java.lang.ClassNotFoundException: com.jadex.qna.MavenTestProject.App
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:281)
at java.lang.Thread.run(Thread.java:745)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.900 s
[INFO] Finished at: 2015-06-15T17:42:19+09:00
[INFO] Final Memory: 8M/153M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.4.0:java (default-cli) on project MavenTestProject: An exception occured while executing the Java class. com.jadex.qna.MavenTestProject.App -> [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
This issue happens, when it is not compatible with eclipse too.
Try this
mvn clean install eclipse:eclipse
Vote up, if it works to help fellow members
The error log which you posted says the following:
java.lang.ClassNotFoundException com.jadex.qna.QNAProject.App
So it clear what the root source of the error is. You are trying to execute the main() method of a class whose class file Maven cannot find. As this SO article discusses, you can try explicitly compiling first, then executing after the class file has been generated:
mvn -e compile exec:java
mvn exec:java -Dexec.mainClass="com.jadex.qna.QNAProject.App"
I ran into this same problem, it was caused by a port conflict.
my tomcat server tried to start on port 8080 but i already had a binding for it.
netstat -anto will show you port bindings 0.0.0.0:8080 or similar and it's PID this will help you determin what process is already running the port bidning, either change it in your timcat server or whatever process is using the bidning. Could be caused by an IIS, SKype or similar.

maven debugging in Vagrant - HADOOP YARN application

I have installed Vagrant as a VM (single node) from this repository and then I installed maven inside so that I can create easily my HADOOP YARN jar files. When I am trying to build my jar mvn package I am getting an error:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.0.2:compile (default-compile) on project YarnTestClient: Compilation failure: Compilation failure:
[ERROR] /vagrant/openlab_ship_proto/YARN/src/main/java/ru/yandex/cern/yarntest/NMCallbackHandler.java:[16,25] generics are not supported in -source 1.3
[ERROR] (use -source 5 or higher to enable generics)
I have searched the whole internet but nothing solved my problem. Had anyone faced the same problem before? Thanks for your help.
Add this snippet to your pom.xml, if build tag didn't exist in pom.xml, maven would build java with source 1.3
<build>
<plugins>
<!-- compiler plugin -->
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven.compiler.version}</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<encoding>${project-sourceEncoding}</encoding>
</configuration>
</plugin>
</plugins>
</build>

Categories