Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Uses constraint violation. Unable to resolve resource -javax.xml.bind.annotation and jakarta.xml.bind-api

I searched a looooot and Im not able to find the solution for my problem.

Im using osgi, karaf and java 8.

I have some modules, for example:

WEBSERVICE-SOMETHING inside this module lets say API, PERSISTENCE, ADAPTER

persistence and api starts fine, but adapter gives that error:

Uses constraint violation. Unable to resolve resource adapter [adapter [288](R 288.2)] 
because it is exposed to package 'javax.xml.bind.annotation' from resources 
org.apache.felix.framework [org.apache.felix.framework [0](R 0)] and 
jakarta.xml.bind-api [jakarta.xml.bind-api [79](R 79.0)] via two dependency 
chains.

the chains are in the adapter and the api.

but what does that mean?

I can install it as feature and they will all start, but another bundle of mine will be put at GracePeriod and if i do DIAG on karaf it says:

Status: GracePeriod
Declarative Services
Blueprint
01/09/19 19:00
Missing dependencies:
(&(osgi.unit.name=example_db)(objectClass=javax.persistence.EntityManager))

Take note that I have other webservice modules and some of them work fine, I checked the pom's and they have same dependecies and same versions

the datasource is fine as well and I already tried adding some features like hibernate.entityManager and it does not work.

like image 564
Tiago Machado Avatar asked Sep 01 '19 18:09

Tiago Machado


1 Answers

Based on the limited information you provided, most likely you have two versions of the same package exported by different bundles at runtime.

This is not a problem on its own but, as explained in this answer it causes an error when

  • bundle A needs packages from B and packages from C
  • bundle B needs different version of the same packages from C

In your particular case the package in question seems to be javax.xml.bind.annotation which appears to be exported in 2 different versions by org.apache.felix.framework bundle and jakarta.xml.bind-api bundle.

It's hard to say what is the best way way to fix that without knowing what are the exact requirements and capabilities of the bundles you are trying to install.

UPDATE:

Here are some things you can use to debug the situation:

  • Calling package:exports | grep javax.xml.bind.annotation will tell you which bundles export the package at what versions
  • Calling package:imports | grep javax.xml.bind.annotation will tell you which bundles imports the package at what versions
  • Calling bundle:diag <YOUR_BUNDLE_ID> will give you detailed information why the bundle was not resolved
like image 92
Milen Dyankov Avatar answered Oct 08 '22 04:10

Milen Dyankov