lauhub
lauhub

Reputation: 920

Project build error with Maven under Eclipse : must specify an absolute path

I created a new project using the following maven command:

mvn archetype:generate -DarchetypeCatalog=local -DarchetypeGroupId=com.github.xlongshu.maven -DarchetypeArtifactId=archetype-quickstart

I then entered the following values:

'groupId': com.example.mycompany
'artifactId': myproject
'version' 1.0-SNAPSHOT: : 
'package' com.example.mycompany: : 

I received the following warnings:

[WARNING] CP Don't override file /Users/user/workspace/myproject/pom.xml
[WARNING] CP Don't override file /Users/user/workspace/myproject/README.md

I then import this new project into Eclipse Oxygen 4.7.3a (no update available for now) using Import... > Existing Maven Projects

And I then get the following errors (under Eclipse in pom.xml file) :

Project build error: 'dependencyManagement.dependencies.dependency.systemPath' for jdk.lib:jconsole:jar must specify an absolute path but is ${env.JAVA_HOME}/lib/jconsole.jar  pom.xml /myproject  line 1  Maven pom Loading Problem
Project build error: 'dependencyManagement.dependencies.dependency.systemPath' for jdk.lib:tools:jar must specify an absolute path but is ${env.JAVA_HOME}/lib/tools.jar    pom.xml /myproject  line 1  Maven pom Loading Problem

However, from command line, everything works well:

mvn validate
mvn compile

The error seems to come from parent POM:

                <dependency>
                    <groupId>jdk.lib</groupId>
                    <artifactId>jconsole</artifactId>
                    <version>${jdk.version}</version>
                    <scope>system</scope>
                    <systemPath>${jconsolejar}</systemPath>
                </dependency>

where jconsolejar property is defined as follow:

<jconsolejar>${env.JAVA_HOME}/lib/jconsole.jar</jconsolejar>

What could I do to solve this error in a clean and efficient way ?

(Maven version: 3.5.3)

Upvotes: 0

Views: 5099

Answers (1)

Yu Tian Toby
Yu Tian Toby

Reputation: 419

I had the same issue when I use a variable to specify a system path for a local jar.

The solution I use is to replace the directory with an absolute path such as

C:\Users\XXXX\eclipse-workspace\PROJECTNAME\src\main\webapp\WEB-INF\lib

The error is gone but a warning is left because this is not recommended

Upvotes: 1

Related Questions