In the pom of a project that uses JAXB, there is the dependency,
<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
<version>2.3.3</version>
</dependency>
When you build the application, the corresponding jar is in WEB-INF/lib.
In the code, I ask which jar JAXBContext is in;
URL location = JAXBContext.class.getProtectionDomain().getCodeSource().getLocation();
It says that it is not the jar in WEB-INF/lib, but the jar in jboss.
jboss-eap-7.4_upgrade/modules/system/layers/base/javax/xml/bind/api/main/jboss-jaxb-api_2.3_spec-2.0.1.Final-redhat-00001.jar!/
I expected that it would have been the jar in WEB-INF/lib. Which rule does JBoss use to choose the jar?
JAXB is part of the Java/Jakarta EE API and thus are provided by the container. It is considered a bad practice to have those jars in the application itself since it can lead to a lot of issues. Either use a jboss-deploymnet.xml to specify that (and exclude the one provided by EAP) or move it in your pom.xml to the provided scope (where it belongs)