On 11/4/09 4:18, peter lawrey wrote:
Hello,
I have found that having the same package in two bundles, where one
depends on the other causes a problem. This is ok if the bundles are
independent, but if the same package appears in more than one bundle,
only one bundle will work.
You are creating a split package (i.e., a package spanning multiple
bundles) then exporting/importing this package from both bundles. This
sort of thing is specifically not allowed by OSGi, so this is just an
error in your bundles.
If you import a package from another bundle, it will completely shadow
an internal package of the same name. See the OSGi spec on class search
order. Imports are searched before the bundle class path and they are
terminal.
By both importing and exporting the package, you are giving the OSGi
framework the choice to treat the bundle as an importer or an exporter
(in this case the "or" is "xor"). So, in your scenario, most likely one
of your bundles is being selected as an exporter and the other is being
selected as an importer.
Moral to the story, don't use split packages.
-> richard
When I attempt to load the second bundle I get the following error.
However if the second bundle uses a different package, there is no
problem.
I don't know if this should be an error or not but it could be handled
better, either by reporting the true error or not reporting an error and
working.
One think I found confusing was the message "Cannot create a POJO
instance, the POJO constructor invocation has thrown an exception :
null" which indicates that the constructor was called but threw an
unknown exception. Neither the constructor nor the static block for the
class is called.
See attached for an example.
10:08:26,384 | ERROR | Thread-29 | SamePackage Two
| ? ? | [ERROR] SampleImplementation :
[SampleImplementationA] Class not found during the loading phase :
samepackage.SampleImplementation
10:08:26,385 | ERROR | Thread-29 | SamePackage Two
| ? ? | [ERROR] SampleImplementation :
[SampleImplementationA] createInstance -> The POJO constructor
invocation failed : null
10:08:26,387 | ERROR | Thread-29 | SamePackage Two
| ? ? | [ERROR] SampleImplementation :
Cannot create a POJO instance, the POJO constructor invocation has
thrown an exception : null
java.lang.RuntimeException: Cannot create a POJO instance, the POJO
constructor invocation has thrown an exception : null
at
org.apache.felix.ipojo.InstanceManager.createObject(InstanceManager.java
:639)
at
org.apache.felix.ipojo.InstanceManager.getPojoObject(InstanceManager.jav
a:776)
at
org.apache.felix.ipojo.handlers.lifecycle.callback.LifecycleCallbackHand
ler.__stateChanged(LifecycleCallbackHandler.java:156)
at
org.apache.felix.ipojo.handlers.lifecycle.callback.LifecycleCallbackHand
ler.stateChanged(LifecycleCallbackHandler.java)
at
org.apache.felix.ipojo.InstanceManager.setState(InstanceManager.java:440
)
at
org.apache.felix.ipojo.InstanceManager.start(InstanceManager.java:321)
at
org.apache.felix.ipojo.ComponentFactory.createInstance(ComponentFactory.
java:155)
at
org.apache.felix.ipojo.IPojoFactory.createComponentInstance(IPojoFactory
.java:298)
at
org.apache.felix.ipojo.IPojoFactory.createComponentInstance(IPojoFactory
.java:235)
at
org.apache.felix.ipojo.InstanceCreator$ManagedInstance.create(InstanceCr
eator.java:360)
at
org.apache.felix.ipojo.InstanceCreator.addInstance(InstanceCreator.java:
89)
at org.apache.felix.ipojo.Extender.parse(Extender.java:269)
at
org.apache.felix.ipojo.Extender.startManagementFor(Extender.java:208)
at org.apache.felix.ipojo.Extender.access$600(Extender.java:52)
at
org.apache.felix.ipojo.Extender$CreatorThread.run(Extender.java:669)
at java.lang.Thread.run(Thread.java:619)
10:08:26,387 | ERROR | Thread-29 | SamePackage Two
| ? ? | [ERROR] SampleImplementation :
Cannot create a POJO instance, the POJO constructor invocation has
thrown an exception : null
10:08:26,388 | ERROR | Thread-29 | ipojo
| ? ? | [ERROR] iPOJO Instance Creator
: A matching factory was found for {component=SampleImplementation,
instance.name=SampleImplementationA}, but the instantiation failed : The
configuration is not correct for the type SampleImplementation : Cannot
create a POJO instance, the POJO constructor invocation has thrown an
exception : null
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@felix.apache.org
For additional commands, e-mail: users-h...@felix.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@felix.apache.org
For additional commands, e-mail: users-h...@felix.apache.org