hibernate-validator-cdi has invalid OSGi manifest

Description

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:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 Manifest-Version: 1.0 Implementation-Title: hibernate-validator-cdi Bundle-Description: Hibernate Validator CDI Portable Extension Automatic-Module-Name: org.hibernate.validator.cdi Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt Bundle-SymbolicName: org.hibernate.validator.hibernate-validator-cdi Implementation-Version: 6.0.2.Final Built-By: jenkins Bnd-LastModified: 1503403748600 Bundle-ManifestVersion: 2 Implementation-Vendor-Id: org.hibernate.validator Specification-Title: Bean Validation Import-Package: org.hibernate.validator;version="[6.0.2.Final,6.0.2.Fi nal]",org.hibernate.validator.cdi;version="[6.0.2.Final,6.0.2.Final]" ,org.hibernate.validator.internal.engine;version="[6.0.2.Final,6.0.2. Final]",org.hibernate.validator.internal.engine.valueextraction;versi on="[6.0.2.Final,6.0.2.Final]",org.hibernate.validator.internal.util; version="[6.0.2.Final,6.0.2.Final]",org.hibernate.validator.internal. util.classhierarchy;version="[6.0.2.Final,6.0.2.Final]",org.hibernate .validator.internal.util.logging;version="[6.0.2.Final,6.0.2.Final]", org.hibernate.validator.internal.util.privilegedactions;version="[6.0 .2.Final,6.0.2.Final]",javax.annotation;version="[1.2,2.0)",javax.int erceptor;version="[1.2,2.0)",javax.enterprise.context;version="[1.2,2 .0)",javax.enterprise.context.spi;version="[1.2,2.0)",javax.enterpris e.event;version="[1.2,2.0)",javax.enterprise.inject;version="[1.2,2.0 )",javax.enterprise.inject.spi;version="[1.2,2.0)",javax.enterprise.u til;version="[1.2,2.0)" Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.8))" Fragment-Host: org.hibernate.validator Tool: Bnd-3.2.0.201605172007 Implementation-Vendor: org.hibernate.validator Export-Package: org.hibernate.validator.cdi;version="6.0.2.Final" Bundle-Name: Hibernate Validator Portable Extension Bundle-Version: 6.0.2.Final Created-By: Apache Maven Bundle Plugin Build-Jdk: 1.8.0_144 Implementation-URL: http://hibernate.org/validator/ Specification-Version: 2.0

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:

1 Fragment-Host: org.hibernate.validator.hibernate-validator

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:

org.hibernate.validator.cdi.internal.ValidationExtension

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:

1 2 Export-Package: org.hibernate.validator.cdi;version="6.0.2.Final",org. hibernate.validator.cdi.internal;version="6.0.2.Final"

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.

1 javax.enterprise.context;version="[1.2,3.0)

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.:

1 javax.validation.bootstrap;version="[2.0.0,3.0.0)"

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:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 Manifest-Version: 1.0 Specification-Title: Bean Validation Specification-Version: 2.0 Automatic-Module-Name: org.hibernate.validator.cdi Bundle-SymbolicName: org.hibernate.validator.hibernate-validator-cdi Bundle-Name: Hibernate Validator Portable Extension Bundle-Description: Hibernate Validator CDI Portable Extension Bundle-Version: 6.0.2.Final Bundle-ManifestVersion: 2 Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt Implementation-URL: http://hibernate.org/validator/ Implementation-Title: hibernate-validator-cdi Implementation-Vendor: org.hibernate.validator Implementation-Vendor-Id: org.hibernate.validator Implementation-Version: 6.0.2.Final Built-By: jenkins Created-By: Apache Maven Bundle Plugin Build-Jdk: 1.8.0_144 Tool: Bnd-3.2.0.201605172007 Bnd-LastModified: 1503403748600 Fragment-Host: org.hibernate.validator.hibernate-validator Import-Package: javax.annotation;version="[1.2,2.0)",javax.interceptor ;version="[1.2,2.0)",javax.enterprise.context;version="[1.2,3.0)",jav ax.enterprise.context.spi;version="[1.2,3.0)",javax.enterprise.event; version="[1.2,3.0)",javax.enterprise.inject;version="[1.2,3.0)",javax .enterprise.inject.spi;version="[1.2,3.0)",javax.enterprise.util;vers ion="[1.2,3.0)",javax.validation.bootstrap;version="[2.0.0,3.0.0)",ja vax.inject Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.8))" Export-Package: org.hibernate.validator.cdi;version="6.0.2.Final",org. hibernate.validator.cdi.internal;version="6.0.2.Final"

I've tested this extensively with Felix 5.6.6 and this works perfectly in combination with Hibernate Validator 6.0.2.Final.

Environment

None

Status

Assignee

Guillaume Smet

Reporter

Tijms

Labels

Worked in

None

Feedback Requested

None

Feedback Requested By

None

backPortable

None

Community Help Wanted

None

Suitable for new contributors

None

Requires Release Note

None

backportDecision

None

backportReEvaluate

None

Components

Fix versions

Affects versions

6.0.2.Final

Priority

Major
Configure