灰袍人
灰袍人

Reputation: 11

Jenkins COMPILATION ERROR

I'm building a multi-module maven project with jenkins, reported

[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] Failure executing javac, but could not parse the error
Fatal Error: Unable to find package java.lang in classpath or bootclasspath.

Java version

java version "1.7.0_79"
Java(TM) SE Runtime Environment (build 1.7.0_79-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode)

Maven version

Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-11T00:41:47+08:00)
Maven home: /home/local/apache-maven-3.3.9
Java version: 1.7.0_79, vendor: Oracle Corporation
Java home: /home/local/jdk1.7.0_79/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "2.6.32-431.el6.x86_64", arch: "amd64", family: "unix"

Pom.xml

<repositories>
        <repository>
            <id>nexus</id>
            <name>Team Nexus Repository</name>
            <url>http://192.168.0.252:8081/nexus/content/groups/public</url>
        </repository>
    </repositories>

    <pluginRepositories>
        <pluginRepository>
            <id>nexus</id>
            <name>Team Nexus Repository</name>
            <url>http://192.168.0.252:8081/nexus/content/groups/public</url>
         </pluginRepository>
    </pluginRepositories>

    <distributionManagement>
        <repository>
            <id>nexus-releases</id>
            <url>http://192.168.0.252:8081/nexus/content/repositories/releases/</url>
        </repository>
        <snapshotRepository>
            <id>nexus-snapshots</id>
            <url>http://192.168.0.252:8081/nexus/content/repositories/snapshots/</url>
        </snapshotRepository>
    </distributionManagement>

Linux CLASSPATH

.:/home/local/jdk1.7.0_79/lib/dt.jar:/home/local/jdk1.7.0_79/lib/tools.jar

I think it is jdk configuration problems, but jdk environment variable should be correct. Jenkins Environment Variables:

Any help would be appreciated.

Upvotes: 0

Views: 8810

Answers (2)

Ankit Prajapati
Ankit Prajapati

Reputation: 23

You need to consider three below things to solve this issue:

Jenkins:

  • Once You have Jenkins install, make sure you install Maven Plugins from “Manage Jenkins  Manage Plugins”
  • Then add the Simple New Item, As Maven Project.
  • Keep everything as it is, Add POM details under Build section.
  • You can set the Goals and Options as: clean install or test as well.

Java: - Check the JAVA_HOME file version and add the JDK version accordingly everywhere.

Maven:

  • Make sure you are using the right version of JDK or JRE for the compilation. (Common error of compilation come here)
  • In eclipse, go to “Window  Preference  Java  Installed JRE  Apply the JRE from Execution Environments”
  • Add Maven Compilation Plugins into POM.XML. o Make sure you have correct version of JDK o Below is the sample format

enter image description here

Upvotes: 0

Vika Marquez
Vika Marquez

Reputation: 353

Open "configure system" page in Jenkins, add JDK and path in JDK section, also you may need add JAVA_HOME to "Global Properties - Environment Variables".

Upvotes: 1

Related Questions