Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java 11 with gradle: must specify an absolute path but is ${tools.jar}

We are moving from Java 8 to 11 on a project using jaxb. As it has been removed from the JDK, it has to be included separately, which I have done via gradle config:

compile("javax.xml.bind:jaxb-api:2.2.11")
compile("com.sun.xml.bind:jaxb-core:2.2.11")
compile("com.sun.xml.bind:jaxb-impl:2.2.11")

I am able to run the project, however compileJava gradle job throws errors:

Errors occurred while build effective model from C:\Users\.\.gradle\caches\modules-2\files-2.1\com.sun.xml.bind\jaxb-core\2.2.11\db0f76866c6b1e50084e03ee8cf9ce6b19becdb3\jaxb-core-2.2.11.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-core:2.2.11
Errors occurred while build effective model from C:\Users\.\.gradle\caches\modules-2\files-2.1\com.sun.xml.bind\jaxb-impl\2.2.11\2d4b554997fd01d1a2233b1529b22fc9ecc0cf5c\jaxb-impl-2.2.11.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-impl:2.2.11

The job finishes and there is a jar created, however when run on production server it stops with this error:

java.lang.NoClassDefFoundError: javax/xml/bind/Unmarshaller$Listener

I'm using Spring Boot v1.5.6 and gradle 4.8.1

like image 649
AragornSG Avatar asked Jan 25 '23 15:01

AragornSG


1 Answers

The solution is to use a newer version of the jaxb libraries. 2.3.0 is no longer using tools.jar.

like image 108
AragornSG Avatar answered Feb 06 '23 16:02

AragornSG