简体   繁体   中英

Maven build fails on Ubuntu 12.04, JDK1.7

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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM