Getting jakarta.xml.bind.JAXBContextFactory: Provider org.glassfish.jaxb.runtime.v2.JAXBContextFactory not found error

So i am using Jaxb to unmarshal a stream like below:

				JAXBContext jaxbContext = JAXBContext.newInstance(NXEnvVarList.class);
				Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
				varlist = (NXEnvVarList) jaxbUnmarshaller.unmarshal(stream);
				System.out.println("working");

But I’m getting below error after obfuscation:
Error while searching for service [jakarta.xml.bind.JAXBContextFactory]

  • with linked exception:
    [java.util.ServiceConfigurationError: jakarta.xml.bind.JAXBContextFactory: Provider org.glassfish.jaxb.runtime.v2.JAXBContextFactory not found]
    jakarta.xml.bind.JAXBException: Error while searching for service [jakarta.xml.bind.JAXBContextFactory]
  • with linked exception:
    [java.util.ServiceConfigurationError: jakarta.xml.bind.JAXBContextFactory: Provider org.glassfish.jaxb.runtime.v2.JAXBContextFactory not found]
    at jakarta.xml.bind.ContextFinder$1.createException(ContextFinder.java:85)
    at jakarta.xml.bind.ContextFinder$1.createException(ContextFinder.java:82)
    at jakarta.xml.bind.ServiceLoaderUtil.firstByServiceLoader(ServiceLoaderUtil.java:46)
    at jakarta.xml.bind.ContextFinder.find(ContextFinder.java:364)
    at jakarta.xml.bind.JAXBContext.newInstance(JAXBContext.java:605)
    at jakarta.xml.bind.JAXBContext.newInstance(JAXBContext.java:546)

This snippet of code is being used in a class in package com.sample.app, and it’s working fine.
But the same snippet is giving the above error in a class in package com.sample.app.deploy

Below is my pom.xml for the jaxb artifacts

            <dependency>
                <groupId>org.glassfish.jaxb</groupId>
                <artifactId>jaxb-runtime</artifactId>
                <version>4.0.0</version>
            </dependency>

            <dependency>
                <groupId>jakarta.xml.bind</groupId>
                <artifactId>jakarta.xml.bind-api</artifactId>
                <version>4.0.0</version>
            </dependency>

            <dependency>
                <groupId>com.sun.xml.bind</groupId>
                <artifactId>jaxb-impl</artifactId>
                <version>4.0.0</version>
                <scope>runtime</scope>
            </dependency>

Any help would be appreciated. Thanks