Affects Version/s: 6.0.2.Final
Fix Version/s: 6.0.3.Final
hibernate-validator-cdi.jar (org.hibernate.validator:hibernate-validator-cdi:6.0.2.Final) has a MANIFEST.MF file that contains a number of problems with the OSGi headers.
The MANIFEST.MF in question is as follows:
The problems are:
1. Name host bundle referenced is the wrong one
The header referencing the host bundle is Fragment-Host: org.hibernate.validator, but the host in hibernate-validator.jar (org.hibernate.validator:hibernate-validator:6.0.2.Final) has the header Bundle-SymbolicName: org.hibernate.validator.hibernate-validator, meaning the referenced name is wrong.
The header should be:
2. Export for CDI extension package missing: org.hibernate.validator.cdi.internal
As per META-INF/services/javax.enterprise.inject.spi.Extension in hibernate-validator-cdi.jar, the portable CDI extension is:
Meaning that the most important package to be exported is org.hibernate.validator.cdi.internal. However as can be seen above in the MANIFEST.MF file, that package is not being exported.
The export header should be:
3. Own package import: org.hibernate.validator.cdi
The import header in the MANIFEST.MF file shown above has an entry for the package org.hibernate.validator.cdi. This package however is defined by the bundle itself and thus should not be imported.
4. Limited to CDI 1.x -> max version should be higher
Hibernate Validator implements Bean Validation 2, which sits together with CDI 2.0 in Java EE 8. Yet all imports for CDI packages in the the MANIFEST.MF file shown above explicitly exclude version 2. Instead of e.g. javax.enterprise.context;version="[1.2,2.0)" it should be e.g.
5. Import for javax.validation.bootstrap missing
The CDI extension implicitly references the type javax.validation.bootstrap.GenericBootstrap, yet the package for this is not imported. The MANIFEST.MF should add an import for this, e.g.:
6. Imports number of packages that the host already imports
A number of packages that the host (hibernate-validator.jar) imports or provides are explicitly imported by the fragment (hibernate-validator-cdi.jar). According to the OSGi spec this should not be done. E.g. org.hibernate.validator should not be imported as the host provides this.
The following shows a MANIFEST.MF for hibernate-validator-cdi.jar with all of the above points addressed:
I've tested this extensively with Felix 5.6.6 and this works perfectly in combination with Hibernate Validator 6.0.2.Final.