Maven build fails on Ubuntu 12.04, JDK1.7 - java

My maven build is fine on Windows machine but fails with compilation error on Ubuntu.
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.0.2:compile (default-compile) on project [XXX]: Compilation failure: Compilation failure:
[ERROR] /usr/share/tomcat7/[XXX]:[24,23] error: no suitable constructor found for XXX
[ERROR]
[ERROR] constructor XXX is not applicable
[ERROR] (actual argument Class<XXX> cannot be converted to Class<? extends XXX> by method invocation conversion)
[ERROR] constructor XXX is not applicable
[ERROR] (actual and formal argument lists differ in length)
[ERROR] /usr/share/tomcat7/[XXX]:[36,24] error: no suitable constructor found for XXX)
[ERROR] -> [Help 1]
cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=12.04
DISTRIB_CODENAME=precise
DISTRIB_DESCRIPTION="Ubuntu 12.04.4 LTS"
java -version
java version "1.7.0_51"
OpenJDK Runtime Environment (IcedTea 2.4.4) (7u51-2.4.4-0ubuntu0.12.04.2)
OpenJDK Client VM (build 24.45-b08, mixed mode, sharing)
mvn -version
Apache Maven 3.0.4
Maven home: /usr/share/maven
Java version: 1.7.0_51, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-7-openjdk-i386/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.5.0-46-generic", arch: "i386", family: "unix"
I already tried building it on java 1.6 and changing java to oracle-7-JDK...
Error stays the same.
Can you help me?
EDIT
I have installed Oracle JDK according to provided instructions
Now it looks like this:
java -version
java version "1.7.0_51"
Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
Java HotSpot(TM) Client VM (build 24.51-b03, mixed mode)
mvn -version
Apache Maven 3.0.4
Maven home: /usr/share/maven
Java version: 1.7.0_51, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-7-oracle/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.5.0-46-generic", arch: "i386", family: "unix"
Build still fails with the same error message

Update your pom file to use an up-to-date maven-compiler-plugin version (you are using 2.0.2 extremly old).
<project>
...
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<!-- put your configurations here -->
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
...
</project>

Related

Maven Build Error: java.security.InvalidAlgorithmParameterException

I am doing a maven build, but it gets an error related to one of the dependencies. If I (and other developers) build this on our local machines or on other linux servers, it builds with no problems. However, on one particular linux server, it gets the following error when building.
mvn clean install DskipTests=true -U
maven Build Error:
[ERROR] Failed to execute goal on project corporateInterface: Could
not resolve dependencies for project
com.travellinck:corporateInterface:war:3.10: Failed to collect
dependencies at
com.github.Cloudmersive:Cloudmersive.APIClient.Java:jar:v3.62: Failed
to read artifact descriptor for
com.github.Cloudmersive:Cloudmersive.APIClient.Java:jar:v3.62: Could
not transfer artifact
com.github.Cloudmersive:Cloudmersive.APIClient.Java:pom:v3.62 from/to
jitpack.io (https://jitpack.io): Transfer failed for
https://jitpack.io/com/github/Cloudmersive/Cloudmersive.APIClient.Java/v3.62/Cloudmersive.APIClient.Java-v3.62.pom:
java.lang.RuntimeException: Unexpected error:
java.security.InvalidAlgorithmParameterException: the trustAnchors
parameter must be non-empty -> [Help 1] [ERROR]
So I think there must be something different on this server that is causing the dependency error. Any ideas please?
I see it gets a java.security.InvalidAlgorithmParameterException, so this suggests that there is probably some restriction configured on the server that is preventing the dependency being downloaded to the server.
More info:
pom.xml
<dependency>
<groupId>com.github.Cloudmersive</groupId>
<artifactId>Cloudmersive.APIClient.Java</artifactId>
<version>v3.62</version>
<exclusions>
<exclusion>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</exclusion>
</exclusions>
</dependency>
Maven version on linux server with the error:
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f) Maven
home: /home/jboss/.sdkman/candidates/maven/current Java version:
1.7.0_95, vendor: Oracle Corporation, runtime: /usr/java/java-7-openjdk-amd64/jre Default locale: en_US, platform
encoding: ANSI_X3.4-1968 OS name: "linux", version:
"3.10.0-1160.15.2.el7.x86_64", arch: "amd64", family: "unix"
Maven version of linux server that has no error:
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f) Maven
home: /opt/apache-maven-3.6.3 Java version: 1.7.0_161, vendor: Oracle
Corporation, runtime:
/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.161-2.6.12.0.el7_4.x86_64/jre
Default locale: en_US, platform encoding: ANSI_X3.4-1968 OS name:
"linux", version: "3.10.0-957.21.3.el7.x86_64", arch: "amd64", family:
"unix"
Maven version on localhost that has no error:
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5;
2015-11-10T18:41:47+02:00) Maven home:
/Users/richardmarais/Development/java/Maven/apache-maven-3.3.9 Java
version: 1.7.0_80, vendor: Oracle Corporation Java home:
/Library/Java/JavaVirtualMachines/jdk1.7.0_80.jdk/Contents/Home/jre
Default locale: en_GB, platform encoding: UTF-8 OS name: "mac os x",
version: "10.16", arch: "x86_64", family: "mac"
I fixed this issue. The problem was the Java version. I temporally build with Java 8 (to download the Cloudmersive api), then switched back to Java 7. Build is successful.

maven - Unsupported major.minor version 52.0 (in an SDK class)

I know this question has been asked many times before, but none of the answers has solved my problem thus far.
I am trying to compile a maven project.
The compiled class files must be in the 1.7 format.
But for some reason, it seems to be encountering a JDK class (javax/tools/DiagnosticListener) that has been compiled with version 1.8.
Here is the error I am getting ...
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default-compile of goal org.apache.maven.plugins:maven-compiler-plugin:3.3:compile failed: An API incompatibility was encountered while executing org.apache.maven.plugins:maven-compiler-plugin:3.3:compile: java.lang.UnsupportedClassVersionError: javax/tools/DiagnosticListener : Unsupported major.minor version 52.0
I believe that I've configured the compiler correctly in the pom.xml:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
JAVA_HOME is set correctly ...
๐Ÿ˜ˆ >echo $JAVA_HOME
/Library/Java/JavaVirtualMachines/jdk1.7.0_80.jdk/Contents/Home
๐Ÿ˜ˆ >java -version
java version "1.7.0_80"
Java(TM) SE Runtime Environment (build 1.7.0_80-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.80-b11, mixed mode)
๐Ÿ˜ˆ >javac -version
javac 1.7.0_80\
๐Ÿ˜ˆ >mvn --version
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T08:41:47-08:00)
Maven home: /usr/local/Cellar/maven/3.3.9/libexec
Java version: 1.7.0_80, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.7.0_80.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.11.6", arch: "x86_64", family: "mac"
I have physically removed all versions of jdk 1.8 installed ...
๐Ÿ˜ˆ >ls -lF /Library/Java/JavaVirtualMachines
total 0
drwxr-xr-x 3 root wheel 102 Jul 14 2015 1.6.0.jdk/
drwxr-xr-x 3 root wheel 102 Mar 24 2016 jdk1.7.0_80.jdk/
and yet it seems that maven is still trying to use a 1.8 version of the SDK to compile against.
I'm not sure how this is possible or how to fix it.

mvn build is failing for tigase-web-ui-2.0 final

We downloaded the pom.xml available at
https://projects.tigase.org/projects/sureim/repository/revisions/33b2a6f9cc27ced875f7e773f041ac381e2115b9
for
tigase-web-ui-2.0 final
and mvn build is failing
[ERROR] Failed to execute goal on project tigase-web-ui: Could not
resolve dependencies for project
tigase.sure.web:tigase-web-ui:war:2.0: Could not find artifact
tigase.sure.web:theme:jar:2.0.0 in gwt-mobile-webkit
(http://gwt-mobile-webkit.googlecode.com/svn/repo) -> [Help 1]
Where do we find the relevant war / jar files.
Our mvn version is
Apache Maven 3.3.3 (7994120775791599e205a5524ec3e0dfe41d4a06; 2015-04-22T17:27:37+05:30)
Maven home: D:\Spacers\Gurupgm\Apache-maven-3.3.3\bin..
Java version: 1.8.0_45, vendor: Oracle Corporation
Java home: D:\Spacers\Gurupgm\Java8\jre
Default locale: en_IN, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "amd64", family: "dos"
Thanks for your help.
Try downloading the jar manually from the link click
After downloading install into maven repository by using the below command
mvn install:install-file -DgroupId=tigase.sure.web
-DartifactId=vomsProxyInitGUI -Dversion=2.0 -Dpackaging=jar -Dfile=/home/tigase-web-ui-2.0.jar

mvn compilation error due to Java version

It is quite strange in my Ubuntu14.04 system. I installed Oracle JDK 1.7. And then compile the project using mvn. But error reports:
Apache Maven 3.0.5
Maven home: /usr/share/maven
Java version: 1.7.0_40, vendor: Oracle Corporation
Java home: /opt/pro/JDK/jdk1.7.0_40/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.13.0-43-generic", arch: "amd64", family: "unix"
[INFO] Error stacktraces are turned on.
[DEBUG] Reading global settings from /usr/share/maven/conf/settings.xml
[DEBUG] Reading user settings from /home/shijiex/.m2/settings.xml
[DEBUG] Using local repository at /home/shijiex/.m2/repository
[DEBUG] Using manager EnhancedLocalRepositoryManager with priority 10 for /home/shij....
............
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.547s
[INFO] Finished at: Tue Jan 20 15:26:28 AST 2015
[INFO] Final Memory: 7M/155M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.0.2:compile (default-compile) on project org.bytecode.generation.sample: Compilation failure: Compilation failure:
[ERROR] /other/projectbase/workspace/org.bytecode.generation.sample/src/main/java/org/methodhandle/templates/TYPES.java:[3,7] error: enums are not supported in -source 1.3
[ERROR]
[ERROR] (use -source 5 or higher to enable enums)
[ERROR] /other/projectbase/workspace/org.bytecode.generation.sample/src/main/java/org/methodhandle/templates/Templates.java:[7,19] error: generics are not supported in -source 1.3
[ERROR]
[ERROR] (use -source 5 or higher to enable generics)
[ERROR] /other/projectbase/workspace/org.bytecode.generation.sample/src/main/java/org/methodhandle/templates/BaseTemplate.java:[11,9] error: variable-arity methods are not supported in -source 1.3
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.0.2:compile (default-compile) on project org.bytecode.generation.sample: Compilation failure
This errors shows that JDK is 1.7 but it is still use 1.3 so the features, e.g., varity parameters, enum, are not recognized.
Do i missing some configurations?
I did not set JAVA_HOME environment variable. The default is Oracle 1.7 and the maven output also shows it is 1.7.
XXX#shijie-ThinkPad-T410:/other/projectbase/workspace
/org.bytecode.generation.sample$ java -version
java version "1.7.0_40"
Java(TM) SE Runtime Environment (build 1.7.0_40-b43)
Java HotSpot(TM) 64-Bit Server VM (build 24.0-b56, mixed mode)
You can add something like this right into your POM:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<source>${jdk.version}</source>
<target>${jdk.version}</target>
</configuration>
</plugin>
You can find more information on the official Maven Compiler plugin page

Maven build error on MAcOS : " unmappable character for encoding UTF-8"

I working on MacOs on Eclipse Kepler.
I'm trying to run maven with UTF8 to be OS dependent.
I think I have tried a lot of solutions that seems to work for others not for me.
export JAVA _TOOL_OPTIONS -Dfile.encoding=UTF-8
When i Run in console :
mvn -version
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
Apache Maven 3.0.4 (r1232337; 2012-01-17 09:44:56+0100)
Maven home: /usr/share/maven
Java version: 1.6.0_45, vendor: Apple Inc.
Java home: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
Default locale: fr_FR, platform encoding: UTF-8
OS name: "mac os x", version: "10.8.4", arch: "x86_64", family: "mac"
But i am running maven via Eclipse and Eclipse says platform encoding macRoman...
When i run a
clean install
Apache Maven 3.0.4 (r1232337; 2012-01-17 09:44:56+0100)
Maven home: /Users/JP/git/CleanOmicsTracer/EMBEDDED
Java version: 1.6.0_45, vendor: Apple Inc.
Java home: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
Default locale: fr_FR, platform encoding: MacRoman
OS name: "mac os x", version: "10.8.4", arch: "x86_64", family: "mac"
In my pom.xml i have setted as this to set UTF-8:
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<project.resources.sourceEncoding>UTF-8</project.resources.sourceEncoding>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.1</version>
<configuration>
<tag>${project.build.finalName}</tag>
<url>http://localhost:8080/manager/text</url>
<server>localhost</server>
<charset>UTF-8</charset>
<update>true</update>
<path>/${project.build.finalName}</path>
<username>jp</username>
<password>camille</password>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>${jdk.version}</source>
<target>${jdk.version}</target>
<encoding>${project.build.sourceEncoding}</encoding>
<sourceEncoding>${project.build.sourceEncoding}</sourceEncoding>
<fork>true</fork>
<meminitial>128m</meminitial>
<maxmem>1024m</maxmem>
<url>http://localhost:8080/manager/text</url>
<server>localhost</server>
<path>/${project.build.finalName}</path>
</configuration>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
<configuration>
<encoding>${project.build.sourceEncoding}</encoding>
<sourceEncoding>${project.build.sourceEncoding}</sourceEncoding>
</configuration>
</plugin>
It's not working, the รฉ and รจ in my .java create an error :
When i change in maven-compile-plugin this line
macRoman
, it will be ok but no more Os Dependent and characters will be misunderstood in my other computer in linux.
When i clean install, the ouput is ok for ressources but nothing is done for the compiler :
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) #
CleanOmicsTracer --- [INFO] Using 'UTF-8' encoding to copy filtered
resources. [INFO] Copying 36 resources [INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) #
CleanOmicsTracer --- [INFO] Changes detected - recompiling the module!
[INFO] Compiling 142 source files to
/Users/JP/git/CleanOmicsTracer/target/classes [INFO]
[INFO] --- maven-resources-plugin:2.6:testResources
(default-testResources) # CleanOmicsTracer --- [INFO] Using 'UTF-8'
encoding to copy filtered resources. [INFO] skip non existing
resourceDirectory /Users/JP/git/CleanOmicsTracer/src/test/resources
UPDATE : I change eclipse configuration to use /usr/share/maven and not the embeded version.
I still have errors whereas this time the platform encoding is well set to UFT-8:
Apache Maven 3.0.4 (r1232337; 2012-01-17 09:44:56+0100)
Maven home: /usr/share/java/maven-3.0.4
Java version: 1.6.0_45, vendor: Apple Inc.
Java home: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
Default locale: fr_FR, platform encoding: UTF-8
OS name: "mac os x", version: "10.8.4", arch: "x86_64", family: "mac"
[ERROR] /com/clb/genomic/lyon/validator/ParticipantExistenceValidator.java:[101,93] unmappable character for encoding UTF-8
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException:
Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project CleanOmicsTracer: Compilation failure
If it works when the platform encoding is set to MacRoman but fails when it is set to UTF-8 then it means ParticipantExistenceValidator is not in UTF-8 encoding. You need to fix the file, not the configuration.
One easy way to do this is to use native2ascii twice, first to convert MacRoman to unicode escapes and then again with -reverse to convert the escapes back into UTF-8.

Categories