0 Replies Latest reply on Jun 27, 2013 3:44 AM by emlun

    OSGi: Uses constraint violation when both chains end in the same bundle

    emlun Newbie

      Hi, I have a problem with OSGi package resolutions. My application depends on packages org.hibernate.annotations and org.springframework.orm.jpa.vendor. I've fetched all my dependency bundles from Spring EBR (http://ebr.springsource.com/repository/app/). If I try to deploy my application after the server starts up, a uses violation occurs with the following message:

       

      Caused by: org.osgi.service.resolver.ResolutionException: Uses constraint violation. Unable to resolve resource com.example.fail [HostBundleRevision[com.example.fail:1.0.0]] because it is exposed to package 'org.hibernate.annotations' from resources com.springsource.org.hibernate [HostBundleRevision[com.springsource.org.hibernate:3.3.2.GA]] and com.springsource.org.hibernate [HostBundleRevision[com.springsource.org.hibernate:3.3.2.GA]] via two dependency chains.

       

      Chain 1:

        com.example.fail [HostBundleRevision[com.example.fail:1.0.0]]

          import: null

           |

          export: osgi.wiring.package=org.hibernate.annotations

        com.springsource.org.hibernate [HostBundleRevision[com.springsource.org.hibernate:3.3.2.GA]]

       

      Chain 2:

        com.example.fail [HostBundleRevision[com.example.fail:1.0.0]]

          import: null

           |

          export: osgi.wiring.package=org.springframework.orm.jpa.vendor; uses:=org.hibernate

        org.springframework.orm [HostBundleRevision[org.springframework.orm:3.2.3.RELEASE]]

          import: null

           |

          export: osgi.wiring.package=org.hibernate; uses:=org.hibernate.annotations

          export: osgi.wiring.package=org.hibernate.annotations

        com.springsource.org.hibernate [HostBundleRevision[com.springsource.org.hibernate:3.3.2.GA]]

          at org.apache.felix.resolver.ResolverImpl.checkPackageSpaceConsistency(ResolverImpl.java:1142)

          at org.apache.felix.resolver.ResolverImpl.resolve(ResolverImpl.java:197)

          at org.jboss.osgi.resolver.felix.StatelessResolver.resolve(StatelessResolver.java:56)

          at org.jboss.osgi.framework.internal.ResolverImpl.resolveAndApply(ResolverImpl.java:137)

          at org.jboss.as.osgi.service.BundleLifecycleIntegration$BundleLifecycleImpl.activateDeferredPhase(BundleLifecycleIntegration.java:296)

          ... 31 more

       

      However if I start the server with the bundle deployed, this conflict does not happen. Is this a bug in JBoss 7.2.0.Final-testsuite-fix or is it an issue with what order bundles are loaded into the OSGi platform? I've attached a zip file with the deployments needed and a REPRODUCTION.TXT with instructions for reproducing the issue.

       

      The issue is also discussed in further detail (and in prettier format) at http://stackoverflow.com/questions/17317349/why-are-uses-constraints-violated-when-both-chains-end-in-the-same-bundle.