내 커뮤니티 업적 표시줄을 확대합니다.

Submissions are now open for the 2026 Adobe Experience Maker Awards.
해결됨

OSGi Bundle Both Imports and Exports the Same Package

Avatar

Level 2

In OSGi bundle, what will happen if you define a package in both Export-Package and Import-Package in the bnd configuration, and how can this lead to class loading issues?

1 채택된 해결책 개

Avatar

정확한 답변 작성자:
Community Advisor

Hi @MateuszNo2,

When the same package is declared in both Export-Package and Import-Package of your OSGi bundle's bnd configuration, it creates a conflict between the bundle acting as a provider and simultaneously a consumer of that package.

Here is what happens:

  • OSGi will prefer the imported version if the same package is available from another bundle.

  • This may cause version mismatches, especially if the imported version differs from the local (exported) one.

  • It can also result in split packages, where classes from the same package are loaded by different classloaders, leading to ClassCastException, NoClassDefFoundError, or unexpected behavior.

Please refer below link for more details: https://techinnovia.com/package-import-and-export/


Santosh Sai

AEM BlogsLinkedIn


원본 게시물의 솔루션 보기

1 답변 개

Avatar

정확한 답변 작성자:
Community Advisor

Hi @MateuszNo2,

When the same package is declared in both Export-Package and Import-Package of your OSGi bundle's bnd configuration, it creates a conflict between the bundle acting as a provider and simultaneously a consumer of that package.

Here is what happens:

  • OSGi will prefer the imported version if the same package is available from another bundle.

  • This may cause version mismatches, especially if the imported version differs from the local (exported) one.

  • It can also result in split packages, where classes from the same package are loaded by different classloaders, leading to ClassCastException, NoClassDefFoundError, or unexpected behavior.

Please refer below link for more details: https://techinnovia.com/package-import-and-export/


Santosh Sai

AEM BlogsLinkedIn