On 29 May 2012, at 16:21, Mirko Swillus wrote:

> Hej,
> 
> please have a look at the following setup, where the Import-Package 
> instruction is not calculated in a way I would have expected:
> 
> I got two Maven projects X and Y, where X has a dependency to Y. Both 
> projects are build as bundles, with maven-bundle-plugin (2.3.7) in its 
> default configuration (just Export-Package is configured to export everything 
> below the particular package root).
> 
> Project X contains an interface A, which extends an interface B which is 
> located in project Y.
> 
> When building project X, the Import-Package section of the generated MANIFEST 
> does only contain the imports that A defines itself. The imports defined in 
> the super interface B are not observed.
> 
> The result is a NoClassDefFoundError at runtime. The BundleClassLoader of X 
> is not able to find the types which are imported by interface B in bundle Y.
> 
> What I would have expected is that maven-bundle-plugin does consider all 
> requirements of those compound types when calculating the Import-Package 
> instructions of the MANIFEST.
> 
> What do you think? Do I have to resolve this dependency manually by adding 
> explicit <Import-Package> to the pom, or is there a special 'import 
> transitive imports as well'-switch I missed so far?

Can you share the full stack trace of the NoClassDefFoundError?

Bnd analyses the compiled bytecode (not the Java source) so if the bytecode of 
a class doesn't contain a reference to a given package then it is not strictly 
required to load that class.
In almost all cases you don't need to import packages referenced by 
superclasses imported from other bundles because that class will have been 
loaded in the other bundle's context.
But... if you're using code (typically legacy reflection code) that incorrectly 
assumes the class and its superclass are visible from the same classloader then 
you'd need extra imports.

> Any comment is highly appreciated. Regards,
> Mirko
> 
> ____________________________________________________________________
> 
> [ M i r k o  S w i l l u s ]
> 
>   Software Development
> 
>   Qualitype AG
>   Quality Management Systems | Bioinformatics
>   Moritzburger Weg 67 | 01109 Dresden
>   fon +49.351.8838 2813 | fax +49.351.8838 2809
>   e-mail: [email protected] | http://www.qualitype.de
> 
>   Sitz der Gesellschaft: Dresden | Amtsgericht Dresden HRB 19830
>   Vorstand: Dr. Wilhelm Zörgiebel | Dr. Frank Götz
>   Aufsichtsratsvorsitz: Prof. Dr. Gerhard P. Fettweis
> ____________________________________________________________________
> 
> The information in this email and any attachments is confidential and is
> intended for the addressee only. If you are not the intended recipient,
> please delete this message and any attachments and advise the sender by
> return email.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to