Skip to content

Commit

Permalink
HSEARCH-3376 Rely on ORM to declare the dependency to JAXB in Java 9+…
Browse files Browse the repository at this point in the history
… instead of declaring it ourselves
  • Loading branch information
yrodiere committed Dec 4, 2018
1 parent 6c0762a commit 648960a
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 121 deletions.
3 changes: 3 additions & 0 deletions elasticsearch/pom.xml
Expand Up @@ -183,6 +183,7 @@
<jdk>9</jdk>
</activation>
<dependencies>
<!-- HSEARCH-3237: this should be removed when we remove the dependency from the Elasticsearch module to JAXB -->
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
Expand All @@ -195,6 +196,7 @@
<jdk>10</jdk>
</activation>
<dependencies>
<!-- HSEARCH-3237: this should be removed when we remove the dependency from the Elasticsearch module to JAXB -->
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
Expand All @@ -207,6 +209,7 @@
<jdk>11</jdk>
</activation>
<dependencies>
<!-- HSEARCH-3237: this should be removed when we remove the dependency from the Elasticsearch module to JAXB -->
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
Expand Down
22 changes: 0 additions & 22 deletions integrationtest/osgi/karaf-features/src/main/features/features.xml
Expand Up @@ -56,27 +56,5 @@

<!-- Hibernate ORM -->
<feature version="${version.org.hibernate}">hibernate-orm</feature>

<!--
To be removed in HSEARCH-3376, once the Hibernate ORM feature properly declares its dependency to JAXB.
This is a hack to make the JAXB runtime available to Hibernate ORM through the application classpath.
We cannot rely on Hibernate ORM declaring the dependency itself, because it does not (for now).
We cannot rely on the JAXB runtime being provided by the JDK, because the JAXB runtime was removed in JDK11.
We cannot rely on the JAXB runtime being provided by Karaf, because Karaf only provides the JAXB API (strangely).
So we must add the bundle ourselves, and more importantly, make it visible to Hibernate ORM somehow.
To make the bundle visible to Hibernate ORM, we declare the "META-INF.services" "package" as exported
by the bundle; this is enough to make the JAXB API find the service file pointing to the JAXBContext class.
This will work as long as the test bundle imports the "META-INF.services" "package", or just "*".
There are probably better ways to do this, but all the solutions I found were worse or didn't work:
- using the mvn:com.sun.xml.bind/jaxb-osgi/${version.org.glassfish.jaxb} bundle would require us to
add a gazillion extra system packages to the Karaf configuration:
https://github.com/eclipse-ee4j/jaxb-ri/blob/afa88da958e1cfb953fb4c38f0b4a1cfec608162/jaxb-ri/bundles/osgi/tests/pom.xml#L85
- using the mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.jaxb-impl/2.2.11_1 bundle from
Apache ServiceMix does not seem to work: the runtime is not found.
-->
<bundle>wrap:mvn:org.glassfish.jaxb/jaxb-runtime/${version.org.glassfish.jaxb}$Bundle-SymbolicName=org.hibernate.org.glassfish.jaxb.runtime&amp;Export-Package=com.sun.xml.bind.v2;version="${version.org.glassfish.jaxb}&amp;Export-Package=META-INF.services;version="${version.org.glassfish.jaxb}"</bundle>
</feature>
</features>
54 changes: 0 additions & 54 deletions orm/pom.xml
Expand Up @@ -231,58 +231,4 @@
</plugin>
</plugins>
</reporting>

<profiles>
<profile>
<id>jdk9</id>
<activation>
<jdk>9</jdk>
</activation>
<dependencies>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</profile>
<profile>
<id>jdk10</id>
<activation>
<jdk>10</jdk>
</activation>
<dependencies>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</profile>
<profile>
<id>jdk11</id>
<activation>
<jdk>11</jdk>
</activation>
<dependencies>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</profile>
</profiles>
</project>
9 changes: 3 additions & 6 deletions pom.xml
Expand Up @@ -239,8 +239,8 @@
<version.org.apache.derby>10.13.1.1</version.org.apache.derby>

<!-- This should be aligned with the version used in ORM -->
<!-- HSEARCH-3237: this should be removed when we remove the dependency from the Elasticsearch module to JAXB -->
<version.javax.xml.bind.jaxb-api>2.3.1</version.javax.xml.bind.jaxb-api>
<version.org.glassfish.jaxb>2.3.1</version.org.glassfish.jaxb>

<version.org.slf4j>1.7.25</version.org.slf4j>
<version.log4j>1.2.16</version.log4j>
Expand Down Expand Up @@ -676,6 +676,7 @@
<!--
Dependency management is necessary to avoid divergence between the version required by unitils
and the one required by commons-beanutils used in jaxb
HSEARCH-3237: this should be removed when we remove the dependency from the Elasticsearch module to JAXB
-->
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
Expand Down Expand Up @@ -1135,16 +1136,12 @@
</exclusions>
</dependency>

<!-- HSEARCH-3237: this should be removed when we remove the dependency from the Elasticsearch module to JAXB -->
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>${version.javax.xml.bind.jaxb-api}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>${version.org.glassfish.jaxb}</version>
</dependency>
</dependencies>
</dependencyManagement>

Expand Down
39 changes: 0 additions & 39 deletions testing/pom.xml
Expand Up @@ -75,43 +75,4 @@
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>jdk9</id>
<activation>
<jdk>9</jdk>
</activation>
<dependencies>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
</dependency>
</dependencies>
</profile>
<profile>
<id>jdk10</id>
<activation>
<jdk>10</jdk>
</activation>
<dependencies>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
</dependency>
</dependencies>
</profile>
<profile>
<id>jdk11</id>
<activation>
<jdk>11</jdk>
</activation>
<dependencies>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
</dependency>
</dependencies>
</profile>
</profiles>
</project>

0 comments on commit 648960a

Please sign in to comment.