Page 1 of 2 12 LastLast
Results 1 to 10 of 18

Thread: Loader constraint violation in bundles with different versions

  1. #1
    Join Date
    May 2006
    Posts
    16

    Default Loader constraint violation in bundles with different versions

    Hi All

    I have following simple bundles:

    1. Solution 1.0.0
    2. Pricing 1.0.0
    3. Udm 1.0.0
    4. Udm 1.1.0 (Same with the bundle number 3, only different version)

    Following dependencies:

    Solution 1.0.0 -> Pricing 1.0.0
    Solution 1.0.0 -> Udm 1.0.0
    Pricing 1.0.0 -> Udm 1.1.0

    Please see the JPG attachment ("solution pricing udm.jpg") to better understand the dependencies.

    Each bundle exports a simple service and each bundle uses those exported services within the dependencies definition above.

    In the development time everything works fine. But as soon as I start my Solution 1.0.0 bundle I get following error:

    Code:
    osgi> INFO : Starting [org.springframework.bundle.osgi.extender] bundle v.[1.1.2]
    
    ...
    
    [pricingService,udmService,solutionServiceOsgi,solutionService]; root of factory hierarchy
    ERROR: Post refresh error
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'pricingService': FactoryBean threw exception on object creation; nested exception is java.lang.LinkageError: loader constraint violation: loader (instance of org/springframework/osgi/context/internal/classloader/ChainedClassLoader) previously initiated loading for a different type with name "osgi/udm/UdmService"
    	at org.springframework.beans.factory.support.FactoryBeanRegistrySupport$1.run(FactoryBeanRegistrySupport.java:127)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:116)
    	at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:91)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1285)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:217)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
    	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:425)
    	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:729)
    	at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.java:288)
    	at org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterApplicationContextExecutor.java:145)
    	at java.lang.Thread.run(Thread.java:619)
    Caused by: java.lang.LinkageError: loader constraint violation: loader (instance of org/springframework/osgi/context/internal/classloader/ChainedClassLoader) previously initiated loading for a different type with name "osgi/udm/UdmService"
    	at java.lang.Class.forName0(Native Method)
    	at java.lang.Class.forName(Class.java:169)
    	at $Proxy4.<clinit>(Unknown Source)
    	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    	at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    	at java.lang.reflect.Proxy.newProxyInstance(Proxy.java:588)
    	at org.springframework.aop.framework.JdkDynamicAopProxy.getProxy(JdkDynamicAopProxy.java:117)
    	at org.springframework.aop.framework.ProxyFactory.getProxy(ProxyFactory.java:110)
    	at org.springframework.osgi.service.util.internal.aop.ProxyUtils.createProxy(ProxyUtils.java:60)
    	at org.springframework.osgi.service.util.internal.aop.ProxyUtils.createProxy(ProxyUtils.java:37)
    	at org.springframework.osgi.service.importer.support.AbstractServiceProxyCreator.createServiceProxy(AbstractServiceProxyCreator.java:107)
    	at org.springframework.osgi.service.importer.support.OsgiServiceProxyFactoryBean.createProxy(OsgiServiceProxyFactoryBean.java:185)
    	at org.springframework.osgi.service.importer.support.AbstractServiceImporterProxyFactoryBean.getObject(AbstractServiceImporterProxyFactoryBean.java:83)
    	at org.springframework.osgi.service.importer.support.OsgiServiceProxyFactoryBean.getObject(OsgiServiceProxyFactoryBean.java:141)
    	at org.springframework.beans.factory.support.FactoryBeanRegistrySupport$1.run(FactoryBeanRegistrySupport.java:121)
    	... 12 more
    Exception in thread "SpringOsgiExtenderThread-8" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'pricingService': FactoryBean threw exception on object creation; nested exception is java.lang.LinkageError: loader constraint violation: loader (instance of org/springframework/osgi/context/internal/classloader/ChainedClassLoader) previously initiated loading for a different type with name "osgi/udm/UdmService"
    	at org.springframework.beans.factory.support.FactoryBeanRegistrySupport$1.run(FactoryBeanRegistrySupport.java:127)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:116)
    	at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:91)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1285)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:217)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
    	at 
    
    ...
    The complete stack trace can be found in the attachment file: "error-springdm-versions.txt".

    If I change the dependency of following:

    Pricing 1.0.0 -> Udm 1.1.0

    to

    Pricing 1.0.0 -> Udm 1.0.0 (just using one version of the Udm bundle)

    everything works just fine.

    So my question is:
    Is there something I have to do to be able to use one bundle with different versions like Udm 1.0.0 and Udm 1.1.0? I already have an identical example - but without Spring dm, just pure OSGi - and that works just fine.

    Thanks a lot!
    Lofi.
    Attached Images Attached Images
    Attached Files Attached Files

  2. #2
    Join Date
    May 2006
    Posts
    16

    Default

    After looking around a bit further I found following things:

    1. I get better error messages if I use "Import-Package" instead of "Require-Bundle":

    Code:
    ERROR: Post refresh error
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'solutionServiceOsgi': Invocation of init method failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'solutionService' defined in URL [bundleentry://29/META-INF/spring/solutionservice.xml]: Cannot resolve reference to bean 'pricingService' while setting bean property 'pricingService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'pricingService': FactoryBean threw exception on object creation; nested exception is java.lang.LinkageError: loader constraint violation in interface itable initialization: when resolving method "$Proxy4.setUdmService(Losgi/udm/UdmService;)V" the class loader (instance of org/springframework/osgi/context/internal/classloader/ChainedClassLoader) of the current class, $Proxy4, and the class loader (instance of org/eclipse/osgi/internal/baseadaptor/DefaultClassLoader) for interface osgi/pricing/PricingService have different Class objects for the type osgi/udm/UdmService used in the signature
    2. From the messages above it is clear that the UdmService which has two different versions produces the error:

    Solution 1.0.0 -> Pricing 1.0.0 -> Udm 1.1.0
    Solution 1.0.0 -> Udm 1.0.0

    The Pricing 1.0.0 bundle tries to use (to inject) Udm 1.1.0 bundle and at the same time the Solution 1.0.0 tries to use Udm 1.0.0.

    Any ideas to get rid of this problem?

    Thanks,
    Lofi.

  3. #3
    Join Date
    May 2006
    Posts
    16

    Default

    Adding "uses" directive in Pricing 1.0.0 and Solution 1.0.0 like below:

    Pricing 1.0.0:

    Code:
    Manifest-Version: 1.0
    Bundle-ManifestVersion: 2
    Bundle-Name: Pricing
    Bundle-SymbolicName: osgi.pricing
    Bundle-Version: 1.0.0
    Export-Package: osgi.pricing;version="1.0.0";uses:="osgi.udm"
    Import-Package: osgi.udm;version="1.1.0"
    Solution 1.0.0:

    Code:
    Manifest-Version: 1.0
    Bundle-ManifestVersion: 2
    Bundle-Name: Solution
    Bundle-SymbolicName: osgi.solution
    Bundle-Version: 1.0.0
    Export-Package: osgi.solution;version="1.0.0";uses:="osgi.udm, osgi.pricing"
    Import-Package: osgi.pricing;version="1.0.0", osgi.udm;version="[1.0.0,1.0.0]"
    removes the exception: "loader constraint violation".

    But the bundle Solution 1.0.0 is not beeing activated.

    Running the "diag" tool shows this error:

    Code:
    osgi> diag 32
    initial@reference:file:../../osgi.solution/ [32]
      Package uses conflict: Import-Package: osgi.pricing; version="1.0.0"
    So quite the same error as before.

    It's a pitty that this BLOG about "uses" directive: http://blog.springsource.com/2008/10...ses-directive/

    only shows us how to use the same bundle version.

    My question:
    Is there any examples of using different bundle versions with transitive dependencies like my example above (solution 1.0.0, pricing 1.0.0, dm 1.0.0, dm 1.1.0)? IMHO this is the real power of OSGi... not only using the same version for the bundles...

    Thanks,
    Lofi.

  4. #4

    Angry Its now SpringSource

    Don't expect serious questions to be answered here. Remember its not the Interface21 that came out with Spring,.. its SpringSource. Its more committed towards conducting Seminars, business sessions, making Application Servers, devising liicensing policies etc etc,,.. not anything serious that does not churn money.

  5. #5
    Join Date
    May 2006
    Posts
    16

    Default

    Don't expect serious questions to be answered here. Remember its not the Interface21 that came out with Spring,.. its SpringSource. Its more committed towards conducting Seminars, business sessions, making Application Servers, devising liicensing policies etc etc,,.. not anything serious that does not churn money.
    It's a pitty actually, since my problem is quite straight forward... Until now I still cannot find a solution of my problem...

    Cheers
    Lofi.

  6. #6
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    Lofi, I've raised an issue here (http://jira.springframework.org/browse/OSGI-694). By the looks of the stracktrace, it seems to be a proxy creation problem. I will try to reproduce it and report back.

    By the way, thanks for the nice post, stracktraces and images - if only all reports were like this...

    Cheers,
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

  7. #7
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    Thomas, I don't know what you're expectations are but this is a public forum - anyone can post, whenever they chose to, on whatever they wish, if they want to.

    I for example, chose this Sunday, to reply to a batch of questions that were unanswered while I was on holidays, instead of doing something else. Some might do the same, some might not.

    These being said, to not hijack the thread, Thomas, this is the Spring DM forum, let's keep it this way, please. Help others, download the sources, reproduce errors, offer suggestions, links. Be constructive, get involved not the other way around.

    Thanks!
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

  8. #8
    Join Date
    May 2006
    Posts
    16

    Default

    Quote Originally Posted by Costin Leau View Post
    Lofi, I've raised an issue here (http://jira.springframework.org/browse/OSGI-694). By the looks of the stracktrace, it seems to be a proxy creation problem. I will try to reproduce it and report back.

    By the way, thanks for the nice post, stracktraces and images - if only all reports were like this...

    Cheers,
    Hi Costin,

    thanks for your reply. If you want I can upload my example somewhere... Anyway I want to upload the whole example after finishing it... I'm doing this example to show that by using Spring DM we can have better and less code than using pure OSGi . It is a part of my tutorial: http://lofidewanto.blogspot.com/2008...evelopers.html

    Thanks a lot!
    Lofi.

  9. #9
    Join Date
    May 2006
    Posts
    16

    Default

    Hi Costin

    I uploaded an example to this problem:
    http://lofidewanto.googlepages.com/springdm-example.zip

    Just unzip the file and you'll find the examples as I described in the discussion forum above. I also included the Eclipse Target Platform and you'll find both modules over there: udm-1.0.0.jar and udm-1.1.0.jar.

    Hope to get an answer to this problem soon

    Thanks,
    Lofi.

  10. #10
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    Lofi, I've downloaded the sample and tried to run it but the Eclipse target platform configuration seems incorrect. However, I've looked at the udm-1.0.x.jars and the problem seems to be that you are embedding the interface with the implementation. Since you redeploy them, both classes (the interface + implementation) have a new version and thus cannot be used by the consumer bundle unless it is redeployed as well since it is still wired to the old version.
    You can go around this by extracting the interface (the common contract) to a different bundle and then just redeploy the implementation bundles. This way the consumer keeps its wiring intact as do the implementators.

    In the archive that you mentioned, what are the jars that need to be deployer as I would like to reproduce the error. Additionally, can you please try the 1.1.3 and see if this occurs on it as well?

    Thanks,
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •