As part of my investigation into OSGI on JBoss AS 7 I have created four OSGi bundles that are configured using blueprint.
Here is a brief description of each of the bundles
- an API bundle that contains an interface named Job that has a single method named getName() which retruns a String.
- an example job bundle that contains a class named ExampleJob that implements the Job interface.
- a core services bundle that exports an OSGi service which is used by the ExampleJob class
- and finally a job repository bundle that contains a blueprint reference-list element that should be populated with every service that implements the Job interface. The reference-list also contains a reference-listener that intercepts jobs being added to the list and calls the getName() method of the Job and logs out the result.
The idea is that i would be able to deploy the API, Core, and Repository bundles, and then deploy many Job bundles which would have their Jobs (exported as services) automatically added to the list of Jobs in the Repository bundle.
Unfortunately this does not work, the logging from the reference-listener does not get output, instead I see this log line:
WARN [org.jboss.osgi.framework.internal.ServiceState] (pool-7-thread-3) The service's classloader has no visibility of the requested class: com.efstech.demo.osgi.api.model.Job
Incidentally when I deploy the bundles in this order:
API -> Core -> Example Job -> Repository
The Job correctly gets added to the list, the reference-listener logs the name of the Job and I do not see the warning from the ServiceState class.
I have also written the bundles as plain OSGi bundles without any blueprint configuration, just relying only on the bundle activators to glue the bundles together and it works as desired i.e. being able to deploy the bundles in the following order:
API -> Core -> Repository-> Example Job
I have been using the Sun JDK on Ubuntu:
java version "1.6.0_26"
Java(TM) SE Runtime Environment (build 1.6.0_26-b03)
Java HotSpot(TM) 64-Bit Server VM (build 20.1-b02, mixed mode)
I have been testing the OSGi/blueprint bundles on JBoss AS 7.0.2 with both the jbosgi-framework-core-1.0.8.CR8.jar that comes with JBoss AS 7.0.2 and jbosgi-framework-core-1.0.1.jar that I downloaded from from the jboss repository. I also tested the bundles with JBoss 7.1.0.Beta1 (which comes with jbosgi-framework-core-1.1.0.jar) but all with the same result.
I will attach the compiled bundles and the source code. Any help would be much appreciated!