Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Equinox » javax.annotation : osgi uses constraint violation(problem after updat RCP from 4.6 to 4.14)
javax.annotation : osgi uses constraint violation [message #1839140] Mon, 15 March 2021 15:20 Go to next message
khalid kherrazi is currently offline khalid kherraziFriend
Messages: 2
Registered: March 2021
Junior Member
Hello all,

i have an app using an embedded jetty server with rest compatibility with jax-rs and glassfish.jersey for supporting multipart forms.

I updated rcp from 4.6 to 4.14 ( embeded jetty server from v9.3.9 to v9.4.24 ) and glassfish.jersey from v2.25.1 to v2.33

it compile fine but when starting the app, osgi does not succeed to resolve my plugin because of a uses constraint violation of 'javax.annotation'.

i'm getting this error :


org.osgi.framework.BundleException: Impossible de résoudre le module :myRestPlugin[832]
  Bundle was not resolved because of a uses constraint violation.
  org.apache.felix.resolver.reason.ReasonException: Uses constraint violation. Unable to resolve resource myRestPlugin [osgi.identity; osgi.identity="myRestPlugin"; type="osgi.bundle"; version:Version="1.0.0.qualifier"] because it is exposed to package 'javax.annotation' from resources org.eclipse.osgi [osgi.identity; osgi.identity="org.eclipse.osgi"; type="osgi.bundle"; version:Version="3.15.100.v20191114-1701"; singleton:="true"] and javax.annotation-api [osgi.identity; osgi.identity="javax.annotation-api"; type="osgi.bundle"; version:Version="1.3.2"] via two dependency chains.

Chain 1:
  myRestPlugin [osgi.identity; osgi.identity="myRestPlugin"; type="osgi.bundle"; version:Version="1.0.0.qualifier"]
    require: (osgi.wiring.bundle=org.eclipse.osgi)
     |
    provide: osgi.wiring.bundle: [org.eclipse.osgi, system.bundle]
  org.eclipse.osgi [osgi.identity; osgi.identity="org.eclipse.osgi"; type="osgi.bundle"; version:Version="3.15.100.v20191114-1701"; singleton:="true"]

Chain 2:
  myRestPlugin [osgi.identity; osgi.identity="myRestPlugin"; type="osgi.bundle"; version:Version="1.0.0.qualifier"]
    require: (&(osgi.wiring.bundle=org.glassfish.jersey.media.jersey-media-multipart)(bundle-version>=2.33.0))
     |
    provide: osgi.wiring.bundle; bundle-version:Version="2.33.0"; osgi.wiring.bundle="org.glassfish.jersey.media.jersey-media-multipart"
  org.glassfish.jersey.media.jersey-media-multipart [osgi.identity; osgi.identity="org.glassfish.jersey.media.jersey-media-multipart"; type="osgi.bundle"; version:Version="2.33.0"]
    import: (&(osgi.wiring.package=org.glassfish.jersey.internal.util)(&(version>=2.33.0)(!(version>=3.0.0))))
     |
    export: osgi.wiring.package=org.glassfish.jersey.internal.util; uses:=javax.annotation
  org.glassfish.jersey.core.jersey-common [osgi.identity; osgi.identity="org.glassfish.jersey.core.jersey-common"; type="osgi.bundle"; version:Version="2.33.0"]
    import: (&(osgi.wiring.package=javax.annotation)(&(version>=1.2.0)(!(version>=3.0.0))))
     |
    export: osgi.wiring.package: javax.annotation
  javax.annotation-api [osgi.identity; osgi.identity="javax.annotation-api"; type="osgi.bundle"; version:Version="1.3.2"]
	at org.eclipse.osgi.container.Module.start(Module.java:462)
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel$2.run(ModuleContainer.java:1844)
	at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor$1$1.execute(EquinoxContainerAdaptor.java:136)
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1837)
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1780)
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1742)
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1664)
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1)
	at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:234)
	at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:345)


the java version is 1.8.

It would be highly appreciated if someone has any tip for me how to solve this.

Thanks a lot !

[Updated on: Mon, 15 March 2021 23:12]

Report message to a moderator

Re: javax.annotation : osgi uses constraint violation [message #1839169 is a reply to message #1839140] Tue, 16 March 2021 13:07 Go to previous messageGo to next message
BJ Hargrave is currently offline BJ HargraveFriend
Messages: 59
Registered: July 2009
Member
It looks like your bundle, myRestPlugin, has Require-Bundle to org.eclipse.osgi ("require: (osgi.wiring.bundle=org.eclipse.osgi)") and a Require-Bundle to org.glassfish.jersey.media.jersey-media-multipart ("require: (&(osgi.wiring.bundle=org.glassfish.jersey.media.jersey-media-multipart)(bundle-version>=2.33.0))"). Both of these expose your bundle to different javax.annotation packages. The best solution is to not use Require-Bundle. It is not a best practice (despite its regular use in Eclipse). You are far better off importing packages which allows the better resolve solutions.
Re: javax.annotation : osgi uses constraint violation [message #1839206 is a reply to message #1839169] Wed, 17 March 2021 13:02 Go to previous message
khalid kherrazi is currently offline khalid kherraziFriend
Messages: 2
Registered: March 2021
Junior Member
Thanks BJ Hargrave for your replay

I solved the problem by adding 'javax.annotation' as required bundle at fist to force osgi to pick up the good implementation :

Require-Bundle:  
 javax.annotation,
 org.eclipse.osgi,
 ...
 ...


I m using required bundles certainly because it's simple and it is easier to quickly get a clear view of what components my plugins depends upon.

A mix of require bundle to add internal dependencies and import package to add external dependencies may be more convenient for me.
Previous Topic:Problem with eclipse.publish.featuresAndBundles
Next Topic:Controlling dependency startLevel
Goto Forum:
  


Current Time: Tue Sep 21 17:18:55 GMT 2021

Powered by FUDForum. Page generated in 0.02155 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top