There's a number of techniques you can use to address the issue:
Catalogs
You can use a catalog file to override schema location. Here's a couple of examples:
Use another schema depending on the namespace:
PUBLIC "http://example.org/A" "others/schema_a.xsd"
Use another schema depending on the schema location:
REWRITE_SYSTEM "https://example.org/a.xsd" "others/schema_a.xsd"
Allows you to use a local copy of a schema file.
See this and this guides.
Unfortunatelly, catalog support in XJC is not always working as expected and it's a bit hard to debug it.
Resolving schemas from Maven artifacts
If you're using Maven, you can use maven-jaxb2-plugin which can resolve schemas within Maven artifacts:
REWRITE_SYSTEM "https://example.org/a.xsd" "maven:org.example:a!/a.xsd"
In combination with catalogs, you can make JAXB use a.xsd
inside a-XXX.jar
instead of https://example.org/a.xsd
.
See these sample projects: