Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java 11 issue with jaxb dependencies

Tags:

java

gradle

I'm attempting an upgrade from the Java 8 version to 11 for a project and I've encountered the following error during build-time after I've manually added the JAXB dependencies:

'dependencyManagement.dependencies.dependency.systemPath' for com.sun:tools:jar must specify an absolute path but is ${tools.jar} in com.sun.xml.bind:jaxb-impl:2.2.11

I'm using Gradle, so I've added the following dependencies:

implementation "javax.xml.bind:jaxb-api:2.2.11"
implementation "com.sun.xml.bind:jaxb-core:2.2.11"
implementation "com.sun.xml.bind:jaxb-impl:2.2.11"
implementation "javax.activation:activation:1.1.1"

I've tried to scour the jaxb pom to search for the place in which the property it's looking for (tools.jar) is specified but couldn't find anything.

What am I doing wrong?

like image 343
Cristina_eGold Avatar asked May 16 '19 15:05

Cristina_eGold


3 Answers

Just use 2.3+ version of jaxb-... artifacts. If we check jaxb-parent-2.3.0.pom then we see that it doesn't use <systemPath>${tools.jar}</systemPath> anymore

like image 68
Dmitry Khamitov Avatar answered Nov 05 '22 07:11

Dmitry Khamitov


You can use ./gradlew dependencies to find the parent dependency of that jaxb dependency which caused the error.

Then upgrade that dependency to the latest.

For example to fix the error:

Errors occurred while build effective model from /home/gayanw/.gradle/caches/modules-2/files-2.1/com.sun.xml.bind/jaxb-osgi/2.2.10/c926a537af564ec047ec6308df1d0d2a03364a86/jaxb-osgi-2.2.10.pom:
    'dependencyManagement.dependencies.dependency.systemPath' for com.sun:tools:jar must specify an absolute path but is ${tools.jar} in com.sun.xml.bind:jaxb-osgi:2.2.10
$ ./gradlew dependencies
|    \--- io.rest-assured:xml-path:3.0.2 -> 3.3.0
|         +--- org.codehaus.groovy:groovy-xml:2.4.15 -> 2.5.9 (*)
|         +--- org.codehaus.groovy:groovy:2.4.15 -> 2.5.9
|         +--- io.rest-assured:rest-assured-common:3.3.0 (*)
|         +--- org.apache.commons:commons-lang3:3.4
|         +--- org.ccil.cowan.tagsoup:tagsoup:1.2.1
|         +--- javax.xml.bind:jaxb-api:2.2.12 -> 2.3.1
|         |    \--- javax.activation:javax.activation-api:1.2.0
|         +--- com.sun.xml.bind:jaxb-osgi:2.2.10

Here in my case jaxb-osgi is introduced by io.rest-assured:xml-path. So upgrading that dependency should fix it.

testImplementation 'io.rest-assured:xml-path:4.2.0'
like image 7
Gayan Weerakutti Avatar answered Nov 05 '22 06:11

Gayan Weerakutti


have same issue now , i just upgrade everthing in my gradle

implementation 'io.rest-assured:rest-assured:4.3.2'
implementation 'io.rest-assured:json-path:4.3.2'
compile group: 'com.sun.xml.bind', name: 'jaxb-osgi', version: '2.3.2'

the error disappear EDIT : for my project, if i used more updated version of jaxb-osgi , it wouldnt work (the error disappear but the test stop to run )

like image 1
Vladi Avatar answered Nov 05 '22 08:11

Vladi