Skip to content

ph jaxb

Philip Helger edited this page May 3, 2021 · 2 revisions

A special JAXB helper project. It supports both the JDK included JAXB as well as an external JAXB that is used via a separate Maven artefact.

Maven usage

Add the following to your pom.xml to use this artifact:

<dependency>
  <groupId>com.helger.commons</groupId>
  <artifactId>ph-jaxb</artifactId>
  <version>x.y.z</version>
</dependency>

Note: the Maven groupId changed in v10 from com.helger to com.helger.commons

In your application you also need to provide a real JAXB implementation, as this project is only using the JAXB API as a dependency. To include the reference implementation add this depndency:

<dependency>
  <groupId>com.sun.xml.bind</groupId>
  <artifactId>jaxb-impl</artifactId>
</dependency>

See below what needs to be considered to use alternative JAXB implementations.

Contents

  • com.helger.jaxb - JAXB context cache, abstract reader, writer and validator interfaces.
  • com.helger.jaxb.builder - Abstract builder for JAXB based readers, writers and validators.
  • com.helger.jaxb.validation - validation event handler (factories) for JAXB marshalling/unmarshalling.

Using an alternative JAXB implementation

My information are primarily based on https://docs.oracle.com/middleware/12213/toplink/develop-document-bindings/runtime.htm#TLJAX137

  1. You need at least ph-commons 10.1.2
  2. Add the necessary dependencies to your pom.xml
  3. Please a jaxb.properties file in each JAXB package

Using Eclipselink MOXy

Tested with MOXy 2.7.8

Add this to your pom.xml:

    <dependency>
      <groupId>org.eclipse.persistence</groupId>
      <artifactId>org.eclipse.persistence.moxy</artifactId>
      <version>2.7.8</version>
    </dependency>

if your XSD uses a base64Binary data type, you may also need this dependency:

    <dependency>
      <groupId>com.sun.mail</groupId>
      <artifactId>jakarta.mail</artifactId>
      <version>1.6.5</version>
    </dependency>

and each JAXB package must contain a file jaxb.properties with this content:

javax.xml.bind.context.factory=org.eclipse.persistence.jaxb.JAXBContextFactory