highsource / highsource/jaxb-tools

[BUG] JAXB2 Namespace Prefix Plugin creating duplicated package info namespace

Open
#577 5 comments 0 reactions 0 assignees View on GitHub
question
Dominant language
Java
Stars
465
Forks
105
PR merge metrics
No merged PRs in 30d

Description

Hey there.

## My usage of jaxb-tools

I'm using jaxb-tools in a [factur-x API](https://fnfe-mpe.org/factur-x/) for :
- Generating classes from `xsd` files using `xjc` and your maven plugin
- Mapping appropriate namespaces to the XML tags when marshalling my object into a `xml` string

## Context

Basically, my process involves :
1. Sending a `json` file with the appropriate serialized object along with a pdf
2. The `json` is mapped into an object from the jaxb-generated classes
3. I then marshal this object into a proper `xml` file with the correct namespaces
4. I incorporate the `xml` into the `pdf` to create a factur-x file

## My issue

My issue is related to namespaces associations in the `package-info` file.

I don't understand why my generated `package-info` would be different if my executions in the `pom.xml` file are identical, same thing for the `bindings.xjb` files. But here they are :

![image](https://github.com/user-attachments/assets/596e4f69-9fd2-448f-acd2-75c1828de37f)

Hence, the minimal profile is working fine with proper generation of factur-x compliant file.

The 4 other profiles don't work well at all.

## Reproducible example

Here is my plugin config inside my `pom.xml` :

```xml

org.jvnet.jaxb
jaxb-maven-plugin
4.0.8

true

-Xnamespace-prefix



org.jvnet.jaxb
jaxb-plugins
4.0.8





xjc-minimum

generate


${project.basedir}/src/main/resources/schemas/minimum
${project.build.directory}/generated-sources/jaxb/minimum
REDACTED.entity.generated.minimum
false



xjc-basicwl

generate


${project.basedir}/src/main/resources/schemas/basicwl
${project.build.directory}/generated-sources/jaxb/basicwl
REDACTED.entity.generated.basicwl



xjc-basic

generate


${project.basedir}/src/main/resources/schemas/basic
${project.build.directory}/generated-sources/jaxb/basic
REDACTED.entity.generated.basic



xjc-en16931

generate


${project.basedir}/src/main/resources/schemas/en16931
${project.build.directory}/generated-sources/jaxb/en16931
REDACTED.entity.generated.en16931



xjc-extended

generate


${project.basedir}/src/main/resources/schemas/extended
${project.build.directory}/generated-sources/jaxb/extended
REDACTED.entity.generated.extended




```

Here you can find the approporiate filestructure using the `xsd` files from fnfe-mpe.org zip :

![image](https://github.com/user-attachments/assets/5d77a55f-4727-40d0-8316-6f0bb8109ba4)

And finally, here is a `bindings.xjb` file example, only the `schemaLocation` is changing :

```xml














```

Note that the globalBindings part is used for defining the XmlRootElement that would otherwise be missing when marshalling to `xml` :

```txt
jakarta.xml.bind.MarshalException - with linked exception:[com.sun.istack.SAXException2: unable to marshal type "REDACTED.entity.generated.extended.CrossIndustryInvoiceType" as an element because it is missing an @XmlRootElement annotation
```

## Questions

- Is there anything I'm doing that is wrong ? I have read extensively your documentation and stack overflow posts, but I might have missed something
- Otherwise, maybe something is wrong in the librairy handling of multiple executions. Maybe I can help finding a fix ?

Thanks in advance and have a great day !

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.