Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Virgo » ImportMergeException for aspectj
ImportMergeException for aspectj [message #829358] Mon, 26 March 2012 03:29 Go to next message
Piotrek De is currently offline Piotrek De
Messages: 5
Registered: March 2012
Junior Member
Hi,

I want to use AspectJ (ebr.springsource.com/repository/app/library/detail?name=org.aspectj) in my OSGI bundle on the latest (3.0.2.RELEASE) Virgo release.
No matter if an entire library, or all bundles included are imported, ImportMergeException is raised. In order to build by bundle, I use maven-bundle-plugin in the latest 2.3.7 version.

In case of the following settings:
<Import-Library>
  org.springframework.spring;version="3.0.5.RELEASE"
</Import-Library>
<Import-Bundle>
  com.springsource.org.aspectj.runtime;version="1.6.5.RELEASE",
  com.springsource.org.aspectj.weaver;version="1.6.5.RELEASE"
</Import-Bundle>


Exception below is thrown:
Caused by: org.eclipse.virgo.kernel.osgi.framework.ImportMergeException: cannot merge imports of package 'org.aspectj.lang' from sources 'Import-Library 'org.springframework.spring' version '3.0.5.RELEASE'(null), Import-Bundle 'com.springsource.org.aspectj.runtime' version '1.6.5.RELEASE', Import-Bundle 'com.springsource.org.aspectj.weaver' version '1.6.5.RELEASE'' because of conflicting values 'com.springsource.org.aspectj.weaver', 'com.springsource.org.aspectj.runtime' of attribute 'bundle-symbolic-name'


Exactly the same when I use an entire library instead of a single bundles imports:
<Import-Library>
  org.springframework.spring;version="3.0.5.RELEASE",
  org.aspectj;version="1.6.5.RELEASE"
</Import-Library>


Caused by: org.eclipse.virgo.kernel.osgi.framework.ImportMergeException: cannot merge imports of package 'org.aspectj.lang.annotation' from sources 'Import-Library 'org.aspectj' version '1.6.5.RELEASE'(Import-Bundle 'com.springsource.org.aspectj.weaver' version '1.6.5.RELEASE', Import-Bundle 'com.springsource.org.aspectj.runtime' version '1.6.5.RELEASE')' because of conflicting values 'com.springsource.org.aspectj.runtime', 'com.springsource.org.aspectj.weaver' of attribute 'bundle-symbolic-name'


I've also tried to upgrade AspectJ libs, but unfortunately still unsuccessfully. The same exception is for all versions 1.6.5+ (1.6.12.RELEASE is the latest one):

<Import-Library>
  org.springframework.spring;version="3.0.5.RELEASE"
</Import-Library>
<Import-Bundle>
  com.springsource.org.aspectj.runtime;version="1.6.6.RELEASE",
  com.springsource.org.aspectj.weaver;version="1.6.6.RELEASE"
</Import-Bundle>



Caused by: org.eclipse.virgo.kernel.osgi.framework.ImportMergeException: cannot merge imports of package 'org.aspectj.lang' from sources 'Import-Library 'org.springframework.spring' version '3.0.5.RELEASE'(null), Import-Bundle 'com.springsource.org.aspectj.runtime' version '1.6.6.RELEASE', Import-Bundle 'com.springsource.org.aspectj.weaver' version '1.6.6.RELEASE'' because of conflicting values 'com.springsource.org.aspectj.weaver', 'com.springsource.org.aspectj.runtime' of attribute 'bundle-symbolic-name'


Downgrading is not possible - it seems that spring requires aspectj in version 1.5 at least:

<Import-Library>
  org.springframework.spring;version="3.0.5.RELEASE"
</Import-Library>
<Import-Bundle>
  com.springsource.org.aspectj.runtime;version="1.6.3.RELEASE",
  com.springsource.org.aspectj.weaver;version="1.6.3.RELEASE"
</Import-Bundle>


Uses violation: <Import-Package: org.springframework.aop.aspectj.annotation; version="0.0.0"> in bundle <com.company.bundle_0.4.0.SNAPSHOT[1332744741530]>
Found conflicts:
                package        'org.springframework.core.io.support_3.0.5.RELEASE' in bundle 'org.springframework.core_3.0.5.RELEASE[25]' used by 'org.springframework.aop.aspectj.annotation_3.0.5.RELEASE' in bundle 'org.springframework.aop_3.0.5.RELEASE[21]'
                conflicts with 'org.springframework.core.io.support_3.0.5.RELEASE' in bundle 'org.springframework.core_3.0.5.RELEASE[88]' used by 'org.springframework.orm.jpa_3.0.5.RELEASE' in bundle 'org.springframework.orm_3.0.5.RELEASE[91]'
                package        'org.aopalliance.aop_1.0.0' in bundle 'com.springsource.org.aopalliance_1.0.0[32]' used by 'org.springframework.aop.aspectj.annotation_3.0.5.RELEASE' in bundle 'org.springframework.aop_3.0.5.RELEASE[21]'
                conflicts with 'org.aopalliance.aop_1.0.0' in bundle 'com.springsource.org.aopalliance_1.0.0[71]' used by 'org.springframework.scheduling.annotation_3.0.5.RELEASE' in bundle 'org.springframework.context_3.0.5.RELEASE[87]'
                package        'org.springframework.asm.commons_3.0.5.RELEASE' in bundle 'org.springframework.asm_3.0.5.RELEASE[22]' used by 'org.springframework.aop.aspectj.annotation_3.0.5.RELEASE' in bundle 'org.springframework.aop_3.0.5.RELEASE[21]'
                conflicts with 'org.springframework.asm.commons_3.0.5.RELEASE' in bundle 'org.springframework.asm_3.0.5.RELEASE[85]' used by 'org.springframework.orm.jpa_3.0.5.RELEASE' in bundle 'org.springframework.orm_3.0.5.RELEASE[91]'

        Uses violation: <Import-Package: org.springframework.aop.aspectj.autoproxy; version="0.0.0"> in bundle <com.company.bundle_0.4.0.SNAPSHOT[1332744741530]>
             Resolver reported uses conflict for import constrained to bundle <org.springframework.aop> constrained bundle version range "[3.0.5.RELEASE,3.0.5.RELEASE]"


This defect is reported in the enterprise bundle repo issue tracker (issuetracker.springsource.com/browse/EBR-581) but unfortunately it's still unresolved. Is there any workaround for now?

Of cource it is possible to embed aspectj JARs inside particular bundles, but it seems to do not work properly in case of compile-time weaving.

Thanks in advance for any hints!
Re: ImportMergeException for aspectj [message #829597 is a reply to message #829358] Mon, 26 March 2012 10:24 Go to previous messageGo to next message
Glyn Normington is currently offline Glyn Normington
Messages: 1222
Registered: July 2009
Senior Member
Unfortunately, the AspectJ runtime and weaver bundles in the EBR both export certain packages. I believe the EBR AspectJ runtime bundle was built from aspectjrt.jar which is a strict subset of the aspectjweaver.jar which was used to build the EBR AspectJ weaver bundle. So I think you can get rid of one source of the import merge exception (which is objecting to packages split across imported bundles) by importing the weaver bundle but not the runtime bundle.

Let me now try to provide some commentary on the exception so you have a better chance of understanding the root cause and making progress.
Caused by: org.eclipse.virgo.kernel.osgi.framework.ImportMergeException: cannot merge imports of package 'org.aspectj.lang' from sources 'Import-Library 'org.springframework.spring' version '3.0.5.RELEASE'(null), Import-Bundle 'com.springsource.org.aspectj.runtime' version '1.6.5.RELEASE', Import-Bundle 'com.springsource.org.aspectj.weaver' version '1.6.5.RELEASE'' because of conflicting values 'com.springsource.org.aspectj.weaver', 'com.springsource.org.aspectj.runtime' of attribute 'bundle-symbolic-name'

Virgo expands Import-Library and Import-Bundle into a bunch of package imports, but since any given package may be imported from just one bundle, the merge logic fails if there is a package imported from two or more imported bundles (via import-bundle or import-library). The message above shows that the package org.aspectj.lang is exported by the bundles with symbolic names com.springsource.org.aspectj.weaver and com.springsource.org.aspectj.runtime.

In general, if you really need to import the same "split" package from multiple bundles, you need to use Require-Bundle, but there are quite a few issues with this approach and it is best avoided if you can.

Please try importing the weaver bundle only and see if that helps.
Re: ImportMergeException for aspectj [message #829603 is a reply to message #829597] Mon, 26 March 2012 10:35 Go to previous messageGo to next message
Glyn Normington is currently offline Glyn Normington
Messages: 1222
Registered: July 2009
Senior Member
The other complicating factor is that Virgo embeds the AspectJ weaver bundle in the kernel and imports the packages org.aspectj.* into the user region (see packageImports in config/org.eclipse.virgo.kernel.userregion.properties). So this says to me that you should avoid putting AspectJ bundles in repository/usr and should try to live with those provided by Virgo. I haven't tried it, but it is possible that to get Import-Bundle to work correctly, you'll need to change the bundleImports property in config/org.eclipse.virgo.kernel.userregion.properties as follows:
bundleImports = org.eclipse.osgi;bundle-version="0",com.springsource.org.aspectj.weaver;bundle-version="1.6.5.RELEASE"

This will allow the bundle to be visible in the user region which I think will enable the bundle-symbolicname matching attribute added by Import-Bundle to the expanded package imports to match the AspectJ weaver bundle.
Re: ImportMergeException for aspectj [message #830580 is a reply to message #829603] Tue, 27 March 2012 16:44 Go to previous message
Piotrek De is currently offline Piotrek De
Messages: 5
Registered: March 2012
Junior Member
Thank you very much Glyn for an exhaustive answer.
I've done as you recommended: Neither AspectJ is embedded in the bundle nor it's put in the repository/usr. My bundle imports AspectJ packages and it seems that the version provided by Virgo is used. I didn't even have to change anything in userregion properties.
Previous Topic:Cleaning up Virgo repository
Next Topic:Using logback in OSGI Bundle
Goto Forum:
  


Current Time: Thu Apr 17 17:37:18 EDT 2014

Powered by FUDForum. Page generated in 0.10997 seconds