Building Maven Project : Giving compilation Error - java

I am new to Java/Maven, and I am trying to build a maven Spring Boot project, it was earlier working and was successfully creating jar package as well. But it suddenly stopped working and started giving Maven Compile error.
I know it has something to do with the pom.xml file. My best guess : Some changes in this file has caused it to fail.
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.loanglide</groupId>
<artifactId>drools-helloworld</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>drools-helloworld</name>
<description>Springboot application</description>
<properties>
<maven.compiler.source>12.0.1</maven.compiler.source>
<maven.compiler.target>12.0.1</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<kie.version>6.1.0.Final</kie.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.spring.platform</groupId>
<artifactId>platform-bom</artifactId>
<version>1.1.1.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.kie</groupId>
<artifactId>kie-ci</artifactId>
<version>6.1.0.Final</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.3.0</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.16</version>
<exclusions>
<exclusion>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- https://mvnrepository.com/artifact/org.freemarker/freemarker -->
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
<version>2.3.28</version>
<exclusions>
<exclusion>
<groupId>freemarker<!-- Legacy org-less group --></groupId>
<artifactId>freemarker</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.0.0</version>
</plugin>
</plugins>
</build>
</project>
Error
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.905 s
[INFO] Finished at: 2019-08-08T01:52:48+05:30
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project springboot-helloworld: Fatal error compiling: error: invalid target release: 12.0.1 -> [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
Java Version
java version "12.0.1" 2019-04-16
Java(TM) SE Runtime Environment (build 12.0.1+12)
Java HotSpot(TM) 64-Bit Server VM (build 12.0.1+12, mixed mode, sharing)
I have tried many stackoverflow answer to similar question, but still not able to resolve this issue.

If you are using Java 12, add the following to Maven pom.xml.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<release>12</release>
</configuration>
</plugin>

The properties maven.compiler.source and maven.compiler.target are used by many plugins on default lifecycle, as compiler, as you can see at this answer.
You must try:
<properties>
<maven.compiler.source>12</maven.compiler.source>
<maven.compiler.target>12</maven.compiler.target>
</properties>
But if you want to override only this goal, you can configure it like:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<release>12</release>
</configuration>
</plugin>
As you are new with Java, keep in mind the new versioning schema so even you have installed the 12 version you can target the 11 LTS target if no new language feature is intended to be used.

Related

Compilation fails: bouncycastle does not exist

This is the first time I am setting up a java project and I have almost understood the problem. I am facing bouncycastle not found issue while building the project with maven build. I need to extract a .war file out of it.
While running maven build - clean install I got :
[ERROR] /home/.../CrlServlet.java:[36,34] package org.bouncycastle.asn1.x509 does not exist
[ERROR] /home/.../CrlServlet.java:[37,29] package org.bouncycastle.cert does not exist
[ERROR] /home/.../CrlServlet.java:[38,29] package org.bouncycastle.cert does not exist
[ERROR] /home/.../CrlServlet.java:[39,29] package org.bouncycastle.cert does not exist
[ERROR] /home/.../CrlServlet.java:[40,36] package org.bouncycastle.cert.jcajce does not exist
[ERROR] /home/.../CrlServlet.java:[41,39] package org.bouncycastle.openssl.jcajce does not exist
[ERROR] /home/.../CrlServlet.java:[42,33] package org.bouncycastle.operator does not exist
[ERROR] /home/.../CrlServlet.java:[43,40] package org.bouncycastle.operator.jcajce does not exist
[ERROR] /home/.../LocalCertificateAdapter.java:[12,29] package org.bouncycastle.cert does not exist
[ERROR] /home/.../LocalCertificateAdapter.java:[13,36] package org.bouncycastle.cert.jcajce does not exist
[ERROR] /home/.../LocalCertificateAdapter.java:[14,32] package org.bouncycastle.openssl does not exist
[ERROR] /home/.../LocalCertificateAdapter.java:[15,39] package org.bouncycastle.openssl.jcajce does not exist
I checked my project documentation, there it's written - bcprov-jdkXXon-XXX.jar into the lib/ext.
I looked into the openjdk path in my ubuntu machine and there is no ext folder inside /usr/lib/jvm/java-11-openjdk-amd64/lib. I got one security folder tho.
Since I have openjdk java 11 version installed, I have a doubt as the project doc is old as per this.
openjdk version "11.0.15" 2022-04-19
OpenJDK Runtime Environment (build 11.0.15+10-Ubuntu-0ubuntu0.20.04.1)
OpenJDK 64-Bit Server VM (build 11.0.15+10-Ubuntu-0ubuntu0.20.04.1, mixed mode, sharing)
Also, when I am dockering the app ,I found extracted war is not working may be of this compilation failure. While checking the docker file it was bcprov-jdk15on-155.jar used.
So my question is :
How to resolve this compilation failure ?
Where I can download the exact version of bouncycastle jar file ?
How and where I can put the jar library to make it work ? Do I need to downgrade the openjdk package to 7-8 ?
EDIT:- added pom file
<modelVersion>4.0.0</modelVersion>
<groupId>serv.back</groupId>
<artifactId>xxxx</artifactId>
<version>0.1.6</version>
<packaging>war</packaging>
<name>xxxx</name>
<dependencies>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.5</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.0</version>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>eclipselink</artifactId>
<version>2.5.2</version>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.4.1212.jre7</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.22</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>4.0.0-b01</version>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-dbcp</artifactId>
<version>9.0.0.M15</version>
</dependency>
<dependency>
<groupId>commons-digester</groupId>
<artifactId>commons-digester</artifactId>
<version>2.1</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
<version>4.5.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.5</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<sourceDirectory>src</sourceDirectory>
<resources>
<resource>
<directory>src</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<debug>true</debug>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.3.1</version>
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<configuration>
<url>http://localhost:8080/manager/text</url>
<path>/xxxx</path>
<username>tomcat</username>
<password>xxxx</password>
</configuration>
</plugin>
</plugins>
</build>
It seems you don't have bouncy castle dependency in your pom.xml:
this is for java 1.8 onwards:
https://mvnrepository.com/artifact/org.bouncycastle/bcprov-jdk18on/1.71
There are other versions also in this mvnrepository, and there is possibility to manually download the jar as well.
Maybe you need to put this library to the path specified by your project requirements -as you mentioned this lib/ext, but I don't know your project requirements so it is just my gues.

fatal error compiling invalid flag --module-path

I have a project. Originally it was a single module project with structure like this
java-cloud-sample\
src\
main\
java
pom.xml
I decided to make it into a multi-module structure - I use java 9 anyway.
So I separated it like this
java-cloud-sample\
java-cloud-rest-api\
src\
pom.xml
pom.xml
Where root pom.xml looks like this
<?xml version="1.0" encoding="UTF-8"?>
<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.lapots.breed.platform.cloud</groupId>
<artifactId>java-cloud-sample</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>java-cloud-rest-api</module>
</modules>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.6.RELEASE</version>
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.compiler.source>1.9</maven.compiler.source>
<maven.compiler.target>1.9</maven.compiler.target>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.0.1</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals><goal>copy-dependencies</goal></goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
And module pom.xml looks like this
<?xml version="1.0" encoding="UTF-8"?>
<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>
<parent>
<groupId>com.lapots.breed.platform.cloud</groupId>
<artifactId>java-cloud-sample</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>java-cloud-rest-api</artifactId>
<description>Demo project for Spring Boot</description>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>build-info</goal>
</goals>
<configuration>
<additionalProperties>
<encoding.source>${project.build.sourceEncoding}</encoding.source>
<encoding.reporting>${project.reporting.outputEncoding}</encoding.reporting>
<java.source>${maven.compiler.source}</java.source>
<java.target>${maven.compiler.target}</java.target>
</additionalProperties>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
But when I try to run mvn clean package I get
INFO] java-cloud-rest-api ................................ FAILURE [ 1.060 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.104 s
[INFO] Finished at: 2017-09-08T17:15:46+03:00
[INFO] Final Memory: 27M/331M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.6.2:compile (default-compile) on project java-cloud-rest-api: Fatal error compiling: invalid flag: --module-path -> [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]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn <goals> -rf :java-cloud-rest-api
What is the problem? (maybe I should split maven project into separate modules and each maven module split into java modules)
This failure occurs when maven installed on your machine is configured with java8 as the default java version. You can confirm this by executing
mvn -version
on your terminal and checking the Java version stated in the configuration.
To resolve the version to a newer and supported version like java9 at the moment, you can create/edit the mavenrc(on MacOS) file on your machine:
vi ~/.mavenrc
to include these
export PATH
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-9.jdk/Contents/Home/
export PATH=${PATH}:$JAVA_HOME/bin
Once you save this configuration, you can confirm maven should be using Java version 9 using the same command and then your project shall build without the stated error.
I had this error with the Maven compiler plugin 3.8.1 when a project was defining a module-info.java and Java 8 was used with Maven to compile the project. It seems that as soon a module-info.java is seen by the Maven compiler plugin it is adding the flag --module-path to the command line which is unknown to the Java 8 compiler. A way to exclude this file and compile the project without module support is to exclude the module-info.java from compilation based on a Maven profile:
<profiles>
<profile>
<id>java8</id>
<activation>
<jdk>1.8</jdk>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<excludes>
<exclude>module-info.java</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</profile>

Vaadin Widgetset Compilation Error After Vaadin8 Migration

I just migrated my Vaadin project from 7.7.6 to 8.0.5. First I wanted to use the Vaadin8 migration tool but my IDE used too many vaadin.* imports so I just did it manually. After hours of work (compatibility package imports) the maven build worked again and I wanted to open the WebApp in my browser but I got the "Failed to load the Widgetset..." error message. I thought that I have to recompile the Widgetset but the vaadin-maven-plugin throws an error:
EDIT 04.05.2017: I removed the QueryDSL dependency "querydsl-apt" and the widgetset is compiling... Does anyone know why this happens?
c:\dev\workspace_intellij\wsi>mvn vaadin:compile
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building wsi 2.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[WARNING] The POM for com.querydsl:querydsl-core:jar:3.7.4 is missing, no dependency information available
[INFO]
[INFO] --- vaadin-maven-plugin:8.0.5:compile (default-cli) # wsi ---
[INFO] auto discovered modules [WsiWidgetset]
[INFO] Using com.vaadin:vaadin-client-compiler version 8.0.5
[INFO] Compiling module WsiWidgetset
[INFO] [ERROR] An internal compiler exception occurred
[INFO] com.google.gwt.dev.jjs.InternalCompilerException: Error constructing Java AST
[INFO] at com.google.gwt.dev.jjs.impl.GwtAstBuilder.translateException(GwtAstBuilder.java:3944)
[INFO] at com.google.gwt.dev.jjs.impl.GwtAstBuilder.getInternalCompilerException(GwtAstBuilder.java:4351)
[INFO] at com.google.gwt.dev.jjs.impl.GwtAstBuilder.createMembers(GwtAstBuilder.java:4043)
[INFO] at com.google.gwt.dev.jjs.impl.GwtAstBuilder.processImpl(GwtAstBuilder.java:3883)
[INFO] at com.google.gwt.dev.jjs.impl.GwtAstBuilder.process(GwtAstBuilder.java:3918)
[INFO] at com.google.gwt.dev.javac.CompilationStateBuilder$CompileMoreLater$UnitProcessorImpl.process(CompilationStateBuilder.java:129)
[INFO] at com.google.gwt.dev.javac.JdtCompiler$CompilerImpl.process(JdtCompiler.java:384)
[INFO] at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:470)
[INFO] at com.google.gwt.dev.javac.JdtCompiler.doCompile(JdtCompiler.java:1092)
[INFO] at com.google.gwt.dev.javac.CompilationStateBuilder$CompileMoreLater.compile(CompilationStateBuilder.java:325)
[INFO] at com.google.gwt.dev.javac.CompilationStateBuilder.doBuildFrom(CompilationStateBuilder.java:548)
[INFO] at com.google.gwt.dev.javac.CompilationStateBuilder.buildFrom(CompilationStateBuilder.java:479)
[INFO] at com.google.gwt.dev.javac.CompilationStateBuilder.buildFrom(CompilationStateBuilder.java:465)
[INFO] at com.google.gwt.dev.cfg.ModuleDef.getCompilationState(ModuleDef.java:423)
[INFO] at com.google.gwt.dev.Precompile.precompile(Precompile.java:222)
[INFO] at com.google.gwt.dev.Precompile.precompile(Precompile.java:202)
[INFO] at com.google.gwt.dev.Precompile.precompile(Precompile.java:143)
[INFO] at com.google.gwt.dev.Compiler.compile(Compiler.java:204)
[INFO] at com.google.gwt.dev.Compiler.compile(Compiler.java:155)
[INFO] at com.google.gwt.dev.Compiler.compile(Compiler.java:144)
[INFO] at com.google.gwt.dev.Compiler$1.run(Compiler.java:118)
[INFO] at com.google.gwt.dev.CompileTaskRunner.doRun(CompileTaskRunner.java:55)
[INFO] at com.google.gwt.dev.CompileTaskRunner.runWithAppropriateLogger(CompileTaskRunner.java:50)
[INFO] at com.google.gwt.dev.Compiler.main(Compiler.java:125)
[INFO] Caused by: java.lang.NoSuchMethodError: org.eclipse.jdt.internal.compiler.lookup.MethodBinding.isDefaultMethod()Z
[INFO] at com.google.gwt.dev.jjs.impl.GwtAstBuilder.createMethod(GwtAstBuilder.java:4138)
[INFO] at com.google.gwt.dev.jjs.impl.GwtAstBuilder.createMembers(GwtAstBuilder.java:4033)
[INFO] ... 21 more
[INFO] [ERROR] at SVGPathSegLinetoVerticalAbs.java(30): public interface SVGPathSegLinetoVerticalAbs extends SVGPathSeg
[INFO] org.eclipse.jdt.internal.compiler.ast.TypeDeclaration
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 13.929 s
[INFO] Finished at: 2017-05-02T15:04:34+02:00
[INFO] Final Memory: 35M/434M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.vaadin:vaadin-maven-plugin:8.0.5:compile (default-cli) on project wsi: Command [[
[ERROR] C:\Program Files\Java\jdk1.8.0_102\jre\bin\java -Xmx1G -Dgwt.persistentunitcache=false com.google.gwt.dev.Compiler -logLevel INFO -style OBF -war c:\dev\workspace_intellij\wsi\target\classes\VAADIN\widgetsets -localWorkers 4 -failOnError -XfragmentCount -1 -sourceLevel auto -gen c:\dev\workspace_intellij\wsi\target\.generated WsiWidgetset
[ERROR] ]] failed with status 1
[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/MojoExecutionException
My pom.xml looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<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>
[...]
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.2.RELEASE</version>
<relativePath />
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<vaadin.version>8.0.5</vaadin.version>
<vaadin.plugin.version>8.0.5</vaadin.plugin.version>
<vaadin.charts.version>4.0.0</vaadin.charts.version>
<vaadin.spring.version>2.0.1</vaadin.spring.version>
<vaadin.context.menu.version>2.0.0</vaadin.context.menu.version>
<vaadin.fontawesome.version>1.3.4</vaadin.fontawesome.version>
<vaadin.componentrenderer.version>2.0.0</vaadin.componentrenderer.version>
[...]
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-ldap</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-spring-boot-starter</artifactId>
<version>${vaadin.spring.version}</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.0</version>
</dependency>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-push</artifactId>
</dependency>
<dependency>
<groupId>org.vaadin.addons</groupId>
<artifactId>fontawesomelabel</artifactId>
<version>${vaadin.fontawesome.version}</version>
</dependency>
<dependency>
<groupId>org.apache.directory.server</groupId>
<artifactId>apacheds-server-jndi</artifactId>
<version>1.5.5</version>
</dependency>
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-core</artifactId>
<version>4.0.1</version><!--$NO-MVN-MAN-VER$-->
</dependency>
<dependency>
<groupId>org.imgscalr</groupId>
<artifactId>imgscalr-lib</artifactId>
<version>4.2</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jms</artifactId>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-broker</artifactId>
</dependency>
<dependency>
<groupId>com.querydsl</groupId>
<artifactId>querydsl-core</artifactId>
<version>4.1.4</version>
</dependency>
<dependency>
<groupId>com.querydsl</groupId>
<artifactId>querydsl-apt</artifactId>
<version>4.1.4</version>
</dependency>
<dependency>
<groupId>com.querydsl</groupId>
<artifactId>querydsl-jpa</artifactId>
<version>4.1.4</version>
</dependency>
<dependency>
<groupId>org.vaadin.addons</groupId>
<artifactId>mediaelementjs-player</artifactId>
<version>1.3.3</version>
</dependency>
<dependency>
<groupId>org.vaadin.patrik</groupId>
<artifactId>GridFastNavigation</artifactId>
<version>0.2.1</version>
</dependency>
<!-- Eigenes Kompilat, da Sourcen nicht attached waren -->
<dependency>
<groupId>org.vaadin.addons.lazyquerycontainer</groupId>
<artifactId>vaadin-lazyquerycontainer</artifactId>
<version>7.6.1.3</version>
</dependency>
<!-- WIDGETSET -->
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-charts</artifactId>
<version>${vaadin.charts.version}</version>
</dependency>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-context-menu</artifactId>
<version>${vaadin.context.menu.version}</version>
</dependency>
<dependency>
<groupId>de.datenhahn.vaadin</groupId>
<artifactId>componentrenderer</artifactId>
<version>${vaadin.componentrenderer.version}</version>
</dependency>
<!-- WIDGETSET END -->
[...]
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-compatibility-server</artifactId>
</dependency>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-compatibility-client</artifactId>
</dependency>
</dependencies>
<repositories>
<repository>
<id>vaadin-addons</id>
<url>http://maven.vaadin.com/vaadin-addons</url>
</repository>
</repositories>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-bom</artifactId>
<version>${vaadin.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<!-- Clean up also any pre-compiled themes -->
<configuration>
<filesets>
<fileset>
<directory>src/main/webapp/VAADIN/themes</directory>
<includes>
<include>**/styles.css</include>
<include>**/styles.scss.cache</include>
</includes>
</fileset>
</filesets>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
<!-- Exclude some unnecessary files generated by the GWT compiler. -->
<packagingExcludes>WEB-INF/classes/VAADIN/gwt-unitCache/**, WEB-INF/classes/VAADIN/widgetsets/WEB-INF/**</packagingExcludes>
</configuration>
</plugin>
<plugin>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-maven-plugin</artifactId>
<version>${vaadin.plugin.version}</version>
<configuration>
<extraJvmArgs>-Xmx1G</extraJvmArgs>
</configuration>
<executions>
<execution>
<goals>
<goal>update-theme</goal>
<goal>update-widgetset</goal>
<goal>compile</goal>
<!-- Comment out compile-theme goal to use on-the-fly theme compilation -->
<goal>compile-theme</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.mysema.maven</groupId>
<artifactId>apt-maven-plugin</artifactId>
<version>1.1.3</version>
<executions>
<execution>
<goals>
<goal>process</goal>
</goals>
<configuration>
<outputDirectory>target/generated-sources</outputDirectory>
<processor>com.querydsl.apt.jpa.JPAAnnotationProcessor</processor>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
[...]
</project>
My Widgetset.gwt.xml looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.5.1//EN"
"http://google-web-toolkit.googlecode.com/svn/tags/2.5.1/distro-source/core/src/gwt-module.dtd">
<module>
<!--
Uncomment the following to compile the widgetset for one browser only.
Multiple browsers can be specified as a comma separated list. The supported user agents at the moment of writing were:
ie8,ie9,gecko1_8,safari,opera
The value gecko1_8 is used for Firefox and safari is used for webkit based browsers including Google Chrome.
-->
<!-- <set-property name="user.agent" value="safari"/> -->
<!--
To enable SuperDevMode, uncomment this line.
See https://vaadin.com/wiki/-/wiki/Main/Using%20SuperDevMode for more information and instructions.
-->
<!-- <set-configuration-property name="devModeRedirectEnabled" value="true" /> -->
<!--<inherits name="com.vaadin.DefaultWidgetSet"/>-->
<inherits name="com.vaadin.v7.Vaadin7WidgetSet" />
<inherits name="com.vaadin.addon.charts.Widgetset"/>
<inherits name="de.datenhahn.vaadin.componentrenderer.ComponentRendererWidgetSet"/>
<inherits name="com.vaadin.contextmenu.WidgetSet" />
<inherits name="org.vaadin.patrik.GridFastNavigation" />
</module>
Does anyone know whats going wrong?
Best regards
Generally NoSuchMethodError indicates a classpath problem, in the sense that the library that you have in your cp when writing the code (and your IDE is compiling inline your code to check it for errors) is a different version from the one in the maven compile-time cp. So a method that is available when writing the code is no longer found when compiling or running the code (see late binding).
In your particular case, this is most likely an indirect consequence due to the QueryDSL dependency that uses a JDT version, and the Vaadin maven plugin using a GWT plugin that references another JDT version.
As a workaround, you can explicitly exclude the JDT transitive dependency from either your QueryDSL version or the Vaadin maven plugin, and try to see if that works.
P.S. To see who exactly is referencing the JDT dependency you can run mvn dependency:tree
That worked> Thanks a lot. I added :
<exclusion>
<groupId>org.eclipse.jdt.core.compiler</groupId>
<artifactId>ecj</artifactId>
</exclusion>
in my pom dependency.

maven is unable to find any package from test cases

package my.helloworld;
import org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
import org.junit.Test;
public class HomeControllerTest {
}
The above is my test code. Even this empty code isn't compiling. Below 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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>my.helloworld</groupId>
<artifactId>spring-helloworld</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>spring-helloworld</name>
<url>http://maven.apache.org</url>
<properties>
<jdk.version>1.6</jdk.version>
<spring.version>3.2.13.RELEASE</spring.version>
<jstl.version>1.2</jstl.version>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>${jstl.version}</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>${jdk.version}</source>
<target>${jdk.version}</target>
</configuration>
</plugin>
<!-- embedded Jetty server, for testing -->
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.2.11.v20150529</version>
<configuration>
<scanIntervalSeconds>10</scanIntervalSeconds>
<webApp>
<contextPath>/spring3</contextPath>
</webApp>
</configuration>
</plugin>
<!-- configure Eclipse workspace -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.9</version>
<configuration>
<downloadSources>true</downloadSources>
<downloadJavadocs>true</downloadJavadocs>
<wtpversion>2.0</wtpversion>
<wtpContextName>spring3</wtpContextName>
</configuration>
</plugin>
</plugins>
</build>
</project>
now when I run mvn jetty:run or mvn clean install or mvn test, i get the following error :
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.3:testCompile (default-testCompile) on project spring-helloworld: Compilation failure: Compilation failure:
[ERROR] /home/kay/Projects/Spring/MVC/HelloWorld/spring-helloworld/src/test/java/my/helloworld/HomeControllerTest.java:[3,1] package org.springframework.test.web.servlet.result.MockMvcResultMatchers does not exist
[ERROR] /home/kay/Projects/Spring/MVC/HelloWorld/spring-helloworld/src/test/java/my/helloworld/HomeControllerTest.java:[7,17] package org.junit does not exist
[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
Earlier, it was giving error that package org was not found. What am I missing here?
The class org.springframework.test.web.servlet.result.MockMvcResultMatchers you are trying to import is part of the spring-test module. Add that as a test dependency, because otherwise, it will not be on your classpath and thus, your compiler cannot find it.
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${spring.version}</version>
<scope>test</scope>
</dependency>
And if you don't import something that comes from org.*, then the compiler will not find the package org. But to say something more exact about that, we would need the code and preferably the error message.
Have you tried removing <scope>test</scope> to see whether it works then?

gwt-maven-plugin javascript compilation error

We are moving our build system to use maven. One of our project's uses gwt (version 2.2.0). It compiles to javascript without any errors on Eclipse, but we are having some problems in maven.
Following is the error message when running "mvn clean package"
[INFO]
[INFO] --- gwt-maven-plugin:2.2.0:compile (default) # Analytics ---
[INFO] auto discovered modules [com.ivstel.af.AF]
[INFO] Compiling module com.ivstel.af.AF
[INFO] Validating newly compiled units
[INFO] [ERROR] Errors in 'jar:file:/C:/Users/Croydon.IVSTEL1/.m2/repository/com/google/gwt/google-apis/gwt-visualization/1.1.1/gwt-visualization-1.1.1.jar
!/com/google/gwt/visualization/client/CommonOptions.java'
[INFO] [ERROR] Line 61: The method toJsArrayString(String[]) is undefined for the type ArrayHelper
[INFO] [ERROR] Errors in 'jar:file:/C:/Users/Croydon.IVSTEL1/.m2/repository/com/google/gwt/google-apis/gwt-visualization/1.1.1/gwt-visualization-1.1.1.jar
!/com/google/gwt/visualization/client/DataTable.java'
[INFO] [ERROR] Line 140: The method toJsArrayInteger(int[]) is undefined for the type ArrayHelper
[INFO] [ERROR] Errors in 'jar:file:/C:/Users/Croydon.IVSTEL1/.m2/repository/com/google/gwt/google-apis/gwt-visualization/1.1.1/gwt-visualization-1.1.1.jar
!/com/google/gwt/visualization/client/DataView.java'
[INFO] [ERROR] Line 62: The method toJsArrayInteger(int[]) is undefined for the type ArrayHelper
[INFO] [ERROR] Line 74: The method toJsArrayInteger(int[]) is undefined for the type ArrayHelper
[INFO] [ERROR] Line 82: The method toJsArrayInteger(int[]) is undefined for the type ArrayHelper
[INFO] [ERROR] Line 94: The method toJsArrayInteger(int[]) is undefined for the type ArrayHelper
[INFO] [ERROR] Errors in 'jar:file:/C:/Users/Croydon.IVSTEL1/.m2/repository/com/google/gwt/google-apis/gwt-visualization/1.1.1/gwt-visualization-1.1.1.jar
!/com/google/gwt/visualization/client/VisualizationUtils.java'
[INFO] [ERROR] Line 30: The method toJsArrayString(String[]) is undefined for the type ArrayHelper
[INFO] [ERROR] Line 44: The method toJsArrayString(String[]) is undefined for the type ArrayHelper
However, the jar in question does contain the function toJsArrayInteger in gwt-visualization-1.1.1.jar\com\google\gwt\ajaxloader\client\ArrayHelper.java
<?xml version="1.0" encoding="UTF-8"?>
<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/maven-v4_0_0.xsd">
<!-- POM file generated with GWT webAppCreator -->
<modelVersion>4.0.0</modelVersion>
<groupId>com.ivstel.analytics</groupId>
<artifactId>Analytics</artifactId>
<packaging>war</packaging>
<version>1</version>
<name>Analytics</name>
<properties>
<!-- Convenience property to set the GWT version -->
<gwtVersion>2.2.0</gwtVersion>
<!-- GWT needs at least java 1.5 -->
<maven.compiler.source>1.5</maven.compiler.source>
<maven.compiler.target>1.5</maven.compiler.target>
<webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- Shared version number properties -->
<com.google.gwt.version>${gwtVersion}</com.google.gwt.version>
</properties>
<dependencies>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-servlet</artifactId>
<version>${com.google.gwt.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<version>${com.google.gwt.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.gwt.google-apis</groupId>
<artifactId>gwt-maps</artifactId>
<version>1.0.4</version>
</dependency>
<dependency>
<groupId>com.google.gwt.google-apis</groupId>
<artifactId>gwt-visualization</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>org.gwtmultipage</groupId>
<artifactId>gwtmultipage-core</artifactId>
<version>1.0.0.Beta5</version>
</dependency>
<!-- Other dependencies ....... -->
</dependencies>
<build>
<!-- Generate compiled stuff in the folder used for developing mode -->
<outputDirectory>${webappDirectory}/WEB-INF/classes</outputDirectory>
<plugins>
<!-- GWT Maven Plugin -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>2.2.0</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>test</goal>
<goal>i18n</goal>
<!-- http://stackoverflow.com/questions/3611775/gwt-maven-eclipse-plugin-compilation-fails-due-to-duplicate-class -->
<!-- <goal>generateAsync</goal> -->
</goals>
</execution>
</executions>
<!-- Plugin configuration. There are many available options, see gwt-maven-plugin
documentation at codehaus.org -->
<configuration>
<runTarget>AF.html</runTarget>
<hostedWebapp>${webappDirectory}</hostedWebapp>
<i18nMessagesBundle>com.ivstel.af.client.Messages</i18nMessagesBundle>
</configuration>
<dependencies>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-servlet</artifactId>
<version>${com.google.gwt.version}</version>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<version>${com.google.gwt.version}</version>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-dev</artifactId>
<version>${com.google.gwt.version}</version>
</dependency>
</dependencies>
</plugin>
<!-- Copy static web files before executing gwt:run -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>exploded</goal>
</goals>
</execution>
</executions>
<configuration>
<webappDirectory>${webappDirectory}</webappDirectory>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>noTest</id>
<properties>
<maven.test.skip>true</maven.test.skip>
</properties>
</profile>
</profiles>
</project>
The problem was that I was using an older version of gwt-maps, which used an older version of ajaxloader. Since the gwt-maps dependency was before gwt-visualizations, the compiler ignored the ajaxloader classes in gwt-visualizations.
Seems that the ideal way to do solve this situtaions is to use the noredist artifacts and then include the gwt-ajaxloader dependency explicitly. We also have to exclude the gwt-dev dependency from ajaxloader (gwt-maven-plugin requirement).
<dependency>
<groupId>com.google.gwt.google-apis</groupId>
<artifactId>gwt-ajaxloader</artifactId>
<version>1.1.0</version>
<exclusions>
<exclusion>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-dev</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.google.gwt.google-apis</groupId>
<artifactId>gwt-maps</artifactId>
<version>1.1.0</version>
<classifier>noredist</classifier>
</dependency>
<dependency>
<groupId>com.google.gwt.google-apis</groupId>
<artifactId>gwt-visualization</artifactId>
<version>1.1.1</version>
<classifier>noredist</classifier>
</dependency>

Categories