Error running generateLookupListConstants task in data service for Leaf 3.14 and Spring

NATS has custom metadata fields and using Leaf 3.14 we are getting this error during the compile process of our data service. If we don’t have custom metadata fields we don’t see this error.

Task :readMetadataFiles

Task :generateLookupListConstants FAILED
Exception in thread “main” java.lang.ExceptionInInitializerError
at com.leidos.leaf.lookuplist.constants.parser.LookupListConstantsParser.(LookupListConstantsParser.java:53)
at com.leidos.leaf.lookuplist.constants.parser.LookupListConstantsParserMain.main(LookupListConstantsParserMain.java:37)
Caused by: java.lang.RuntimeException: javax.xml.bind.JAXBException: Implementation of JAXB-API has not been found on module path or classpath.

  • with linked exception:
    [java.lang.ClassNotFoundException: com.sun.xml.internal.bind.v2.ContextFactory]
    at io.reactivex.rxjava3.internal.util.ExceptionHelper.wrapOrThrow(ExceptionHelper.java:46)
    at io.reactivex.rxjava3.exceptions.Exceptions.propagate(Exceptions.java:46)
    at com.leidos.leaf.util.lambda.ExceptionUtils.wrapCheckedException(ExceptionUtils.java:57)
    at com.leidos.leaf.beans.parsers.lookuplist.LookupListParser.(LookupListParser.java:48)
    … 2 more
    Caused by: javax.xml.bind.JAXBException: Implementation of JAXB-API has not been found on module path or classpath.
  • with linked exception:
    [java.lang.ClassNotFoundException: com.sun.xml.internal.bind.v2.ContextFactory]
    at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:278)
    at javax.xml.bind.ContextFinder.find(ContextFinder.java:421)
    at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:721)
    at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:662)
    at com.leidos.leaf.beans.parsers.lookuplist.LookupListParser.lambda$static$0(LookupListParser.java:48)
    at com.leidos.leaf.util.lambda.ExceptionUtils.wrapCheckedException(ExceptionUtils.java:54)
    … 3 more
    Caused by: java.lang.ClassNotFoundException: com.sun.xml.internal.bind.v2.ContextFactory
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
    at javax.xml.bind.ServiceLoaderUtil.nullSafeLoadClass(ServiceLoaderUtil.java:122)
    at javax.xml.bind.ServiceLoaderUtil.safeLoadClass(ServiceLoaderUtil.java:155)
    at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:276)
    … 8 more

FAILURE: Build failed with an exception.

I think it’s likely the case that your FieldMetadata class has XML annotations. If you aren’t writing your BeanMetadata files as XML, you can probably just remove those annotations. If you are, you’ll need to migrate the JAX-B annotations to use the new Jakarta namespace.

IntelliJ IDEA Ultimate edition (paid) has a tool that can help with the upgrade, but it should generally be as simple as removing the javax imports, and when you re-import those classes using your IDE, make sure to select the ones in jakarta packages.

For example:

import javax.xml.bind.annotation.XmlElement;

Should become:

import jakarta.xml.bind.annotation.XmlElement;

I converted all of our custom metadata fields to jakarta and I still see the same error. Could it be that the Leaf metadata gradle plugin needs to be updated?

Ah yeah I think you’re correct. The LEAF team that manages Gradle plugins saw this and is tracking it now. Hopefully can get a release out today.

That release is out now, so you should be able to upgrade to it. It has the same version name as the LFS one.

Thank you for quick response. I’m still seeing the same errors but maybe I’m not getting the correct plugin? Is this the correct plugin version?

plugins {
id ‘com.leidos.leaf.base’ version “3.14.0”
id “com.leidos.leaf.metadata” version “3.14.0”
…
}

That’s not the correct version, it’ll be 3.14.0-nats.

When I replaced the leaf plugin versions with 3.14.0-nats I’m getting this error. I haven’t seen it before.

  • What went wrong:
    A problem occurred configuring root project ‘nats-data-svc’.

java.util.concurrent.ExecutionException: org.gradle.api.GradleException: Failed to create Jar file /home/nats/nats-source/provision/nats-build/leaf-3.14/gradle-run-home/caches/jars-9/6b475b24173502a904998db53a2faa11/jackson-core-2.16.1.jar.

It looks like it’s related to the version of Gradle. The Leaf Service generator creates code that uses Gradle 8.2.1. That version appears to be incompatible with the Leaf Gradle plugin changes. I updated to Gradle 8.7 and I got past the error and generated the bean metadata.

1 Like