I have a package X.Y.Z that exists in 2 bundles A and B:
bundle A
package X.Y.Z
class Class1
bundle B
package X.Y.Z
class Class2
Bundle B exports package X.Y.Z.
Bundle A imports package X.Y.Z and gets an exception that his own class Class1 is not found. Should it work?
I use glassfish 3.1 with felix
No it should not work. If you import package X.Y.Z then that import will be used in preference to the bundle’s own internal contents.
More generally, you have a problem known as split packages. Packages should be coherent and exported by a single bundle, not smeared across multiple bundles. You should refactor your bundle contents so that all classes belonging to package X.Y.Z are present in a single bundle.