NoClassDefFoundError: javax.persistence.Persistence (OSGi JPA2)

Description

OSGi r4v4.2 (chap. 127.1.3) defines the JPA versions as:

JPA

Packages

Export Version

Client Import Range

Provider Imp. Range

JPA 1.0

javax.persistence

1.0

[1.0,2.0)

[1.0,1.1)

 

javax.persistence.spi

1.0

[1.0,2.0)

[1.0,1.1)

JPA 2.0

javax.persistence

1.1

[1.1,2.0)

[1.1,1.2)

 

javax.persistence.spi

1.1

[1.1,2.0)

[1.1,1.2)

Compliant SPIs export as 1.1, so the import for javax.persistence should be [1.1.0,3.0.0) instead of [2.0.0,3.0.0).

In my case, DefaultTraversableResolver happens to find the 2.0 environment using reflection (since JPA2 is available in the classpath), but later fails with NoClassDefFoundError because of the wrong version import.

Environment

an OSGi-compliant environment with JPA 2 (WebSphere 8.5.5, e.g.)

Status

Assignee

Unassigned

Reporter

Matt Parker

Labels

Feedback Requested

None

Feedback Requested By

None

backPortable

None

Suitable for new contributors

None

Pull Request

None

backportDecision

None

backportReEvaluate

None

Components

Affects versions

Priority

Major
Configure