5

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.

Tiago Machado
  • 355
  • 7
  • 24

1 Answers1

8

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
Milen Dyankov
  • 2,972
  • 14
  • 25
  • Hey, thanks for the answer. but I dont have the javax.xml.bind.annotation... im gonna update my question with the poms dependecies – Tiago Machado Sep 02 '19 at 08:31
  • I didn't say you have it in your code. But clearly something does. The POMs will not be of much help I'm afraid. Can you provide more context of the actual error? What bundles are there? Or better yet, reproduce with minimal bundle set. – Milen Dyankov Sep 02 '19 at 08:36
  • This started to happen after updating openApi to 3.3.1 before that all worked just fine I have 5 bundles in each webservice. this one doesnt work, but there are some that works fine. – Tiago Machado Sep 02 '19 at 08:46
  • @TiagoMachado Same problem. Did you ever resolve this? – Jonathan Komar Aug 05 '20 at 13:18
  • @JonathanKomar It was a long time ago, I dont remember very well how I resolved this. But if im not mistaken, I used the same dependecy version in all poms (In some i was using diff version). I think I had some XmlType and XmlAccessorType in models that should too and that caused problems too. besides that, there was a problem too with jaxb using new openApi 3.3.1. because karaf dependecy of jaxb wouldnt allow a higher version, so the trick was changing some karaf config and tell him that would start jaxb with version X. sorry boing so abstract, dont remember very well now – Tiago Machado Aug 05 '20 at 13:57