Bundle not started correctly when blueprint XML depends on CXF namespace
smithleej Jun 20, 2012 6:43 AMI have been looking into OSGi on JBoss 7 using bundles that rely on blueprint to wire the services of the bundles together. I have had some success with the release of 7.1.0.Final thanks to the replies to my previous post https://community.jboss.org/thread/175431. I have now upgraded to JBoss 7.1.1.Final and I am now having an issue when i add CXF into the equation. I have an API bundle and a core services bundle that depends on the API bundle. In the core bundle I have modified the working blueprint XML by including the CXF namespace that would allow me to modify the CXF bus. The new blueprint XML now looks like the following with the CXF namespace and CXF bus configuration:
{code:xml}
<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:cxf="http://cxf.apache.org/blueprint/core"
xsi:schemaLocation="
http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
http://cxf.apache.org/blueprint/core http://cxf.apache.org/schemas/blueprint/core.xsd"
default-activation="eager">
<cxf:bus>
<cxf:features>
<cxf:logging />
</cxf:features>
<cxf:properties>
<entry key="schema-validation-enabled" value="true" />
<entry key="mtom-enabled" value="true" />
</cxf:properties>
<cxf:outInterceptors>
<bean class="org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor">
<!--<argument ref="wsSecurityConfig" />-->
</bean>
</cxf:outInterceptors>
</cxf:bus>
<!-- declare our veryUsefulService bean as an OSGi service -->
<service ref="veryUsefulService" interface="com.efstech.demo.osgi.core.services.VeryUsefulService"/>
<!-- setup our bundle activator -->
<bean id="coreServicesActivator" class="com.efstech.demo.osgi.core.CoreServicesActivator" init-method="start" destroy-method="stop"/>
<!-- create our VeryUsefulService as a bean so we can use to for the OSGi service-->
<bean id="veryUsefulService" class="com.efstech.demo.osgi.core.services.VeryUsefulServiceImpl"/>
</blueprint>
{code}
I have also enabled blueprint and added the CXF module as a dependency with the following OSGi subsytem configuration in the standalone.xml:
{code:xml}
<subsystem xmlns="urn:jboss:domain:osgi:1.2" activation="eager">
<properties>
<property name="org.jboss.osgi.system.modules.extra">
org.apache.log4j,org.apache.cxf
</property>
<property name="org.osgi.framework.startlevel.beginning">
3
</property>
<property name="org.osgi.framework.system.packages.extra">
org.apache.log4j;version=1.2
</property>
</properties>
<capabilities>
<capability name="javax.servlet.api:v25"/>
<capability name="javax.transaction.api"/>
<capability name="org.apache.felix.log" startlevel="1"/>
<capability name="org.jboss.osgi.logging" startlevel="1"/>
<capability name="org.apache.felix.configadmin" startlevel="1"/>
<capability name="org.jboss.as.osgi.configadmin" startlevel="1"/>
<capability name="org.apache.aries:org.apache.aries.util:0.4" startlevel="2"/>
<capability name="org.apache.aries.proxy:org.apache.aries.proxy:0.4" startlevel="2"/>
<capability name="org.apache.aries.blueprint:org.apache.aries.blueprint:0.4" startlevel="2"/>
<capability name="org.apache.cxf" startlevel="3"/>
</capabilities>
</subsystem>
{code}
Now when i deploy my API bundle followed by my core bundle I see this logging:
{code}
2012-06-20 10:53:06 DEBUG [org.jboss.as.osgi] (MSC service thread 1-6) Add module spec to loader: deployment.core:1.0.0.SNAPSHOT
2012-06-20 10:53:06 DEBUG [org.jboss.modules] (MSC service thread 1-6) Module deployment.core:1.0.0.SNAPSHOT defined by Service Module Loader
2012-06-20 10:53:06 DEBUG [org.jboss.osgi.framework.internal.AbstractBundleService] (MSC service thread 1-21) Starting: service jbosgi.bundle.13.core."1.0.0.SNAPSHOT".RESOLVED in mode ACTIVE
2012-06-20 10:53:06 DEBUG [org.apache.aries.blueprint.container.BlueprintExtender] (MSC service thread 1-6) Scanning bundle core for blueprint application
2012-06-20 10:53:06 DEBUG [org.apache.aries.blueprint.container.BlueprintExtender] (MSC service thread 1-6) Found blueprint application in bundle core with paths: [bundle://core-13-0-0/OSGI-INF/blueprint/blueprint.xml]
2012-06-20 10:53:06 DEBUG [org.apache.aries.blueprint.container.BlueprintExtender] (MSC service thread 1-6) Scheduling creation of blueprint bundle core asynchronously
2012-06-20 10:53:06 DEBUG [org.apache.aries.blueprint.container.BlueprintContainerImpl] (Blueprint Extender: 1) Running blueprint container for bundle core in state Unknown
2012-06-20 10:53:06 DEBUG [org.jboss.osgi.framework.internal.AbstractBundleService] (MSC service thread 1-20) Starting: service jbosgi.bundle.13.core."1.0.0.SNAPSHOT".ACTIVE in mode ACTIVE
2012-06-20 10:53:06 INFO [org.jboss.osgi.framework.internal.HostBundleState] (MSC service thread 1-6) Bundle started: core:1.0.0.SNAPSHOT
2012-06-20 10:53:06 DEBUG [org.apache.aries.blueprint.container.BlueprintEventDispatcher] (Blueprint Extender: 1) Sending blueprint container event BlueprintEvent[type=CREATING] for bundle core
2012-06-20 10:53:06 INFO [org.apache.aries.blueprint.container.BlueprintContainerImpl] (Blueprint Extender: 1) Bundle core is waiting for namespace handlers [http://cxf.apache.org/blueprint/core]
2012-06-20 10:53:06 DEBUG [org.apache.aries.blueprint.container.BlueprintEventDispatcher] (Blueprint Extender: 1) Sending blueprint container event BlueprintEvent[type=GRACE_PERIOD, dependencies=[(&(objectClass=org.apache.aries.blueprint.NamespaceHandler)(osgi.service.blueprint.namespace=http://cxf.apache.org/blueprint/core))]] for bundle core
2012-06-20 10:53:06 INFO [org.jboss.as.server] (DeploymentScanner-threads - 1) JBAS018559: Deployed "core-1.0-SNAPSHOT.jar"
{code}
When I remove the CXF namespace and bus configuration from the blueprint XML of the core bundle and redeploy I get the following logging i.e. the service is registered in OSGi:
{code}
2012-06-20 11:20:43 DEBUG [org.jboss.as.osgi] (MSC service thread 1-4) Add module spec to loader: deployment.core:1.0.0.SNAPSHOT
2012-06-20 11:20:43 DEBUG [org.jboss.modules] (MSC service thread 1-4) Module deployment.core:1.0.0.SNAPSHOT defined by Service Module Loader
2012-06-20 11:20:43 DEBUG [org.jboss.osgi.framework.internal.AbstractBundleService] (MSC service thread 1-2) Starting: service jbosgi.bundle.13.core."1.0.0.SNAPSHOT".RESOLVED in mode ACTIVE
2012-06-20 11:20:43 DEBUG [org.apache.aries.blueprint.container.BlueprintExtender] (MSC service thread 1-4) Scanning bundle core for blueprint application
2012-06-20 11:20:43 DEBUG [org.apache.aries.blueprint.container.BlueprintExtender] (MSC service thread 1-4) Found blueprint application in bundle core with paths: [bundle://core-13-0-0/OSGI-INF/blueprint/blueprint.xml]
2012-06-20 11:20:43 DEBUG [org.apache.aries.blueprint.container.BlueprintExtender] (MSC service thread 1-4) Scheduling creation of blueprint bundle core asynchronously
2012-06-20 11:20:43 DEBUG [org.apache.aries.blueprint.container.BlueprintContainerImpl] (Blueprint Extender: 3) Running blueprint container for bundle core in state Unknown
2012-06-20 11:20:43 DEBUG [org.jboss.osgi.framework.internal.AbstractBundleService] (MSC service thread 1-16) Starting: service jbosgi.bundle.13.core."1.0.0.SNAPSHOT".ACTIVE in mode ACTIVE
2012-06-20 11:20:43 INFO [org.jboss.osgi.framework.internal.HostBundleState] (MSC service thread 1-4) Bundle started: core:1.0.0.SNAPSHOT
2012-06-20 11:20:43 DEBUG [org.apache.aries.blueprint.container.BlueprintEventDispatcher] (Blueprint Extender: 3) Sending blueprint container event BlueprintEvent[type=CREATING] for bundle core
2012-06-20 11:20:43 INFO [org.jboss.as.server] (DeploymentScanner-threads - 1) JBAS018559: Deployed "core-1.0-SNAPSHOT.jar"
2012-06-20 11:20:43 DEBUG [org.apache.aries.blueprint.container.BlueprintContainerImpl] (Blueprint Extender: 3) Tracking service references: []
2012-06-20 11:20:43 DEBUG [org.apache.aries.blueprint.container.ServiceRecipe] (Blueprint Extender: 3) Registering service .component-1 with interfaces [com.efstech.demo.osgi.core.services.VeryUsefulService] and properties {osgi.service.blueprint.compname=veryUsefulService}
2012-06-20 11:20:43 DEBUG [org.jboss.osgi.framework.internal.ServiceManagerPlugin] (Blueprint Extender: 3) Register service: ServiceState{service.id=28, osgi.service.blueprint.compname=veryUsefulService, objectClass=[com.efstech.demo.osgi.core.services.VeryUsefulService]}
2012-06-20 11:20:43 DEBUG [org.apache.aries.blueprint.container.BlueprintContainerImpl] (Blueprint Extender: 3) Instantiating components: [blueprintContainer, blueprintBundle, blueprintBundleContext, blueprintConverter, .component-1, coreServicesActivator, veryUsefulService]
2012-06-20 11:20:43 DEBUG [org.apache.aries.blueprint.container.ServiceRecipe] (Blueprint Extender: 3) Retrieving service for bundle null and service registration null
2012-06-20 11:20:43 DEBUG [org.apache.aries.blueprint.container.ServiceRecipe] (Blueprint Extender: 3) Creating service instance
2012-06-20 11:20:43 DEBUG [org.apache.aries.blueprint.container.ServiceRecipe] (Blueprint Extender: 3) Service created: com.efstech.demo.osgi.core.services.VeryUsefulServiceImpl@199ec67
2012-06-20 11:20:43 DEBUG [org.apache.aries.blueprint.container.ServiceRecipe] (Blueprint Extender: 3) Creating listeners
2012-06-20 11:20:43 DEBUG [org.apache.aries.blueprint.container.ServiceRecipe] (Blueprint Extender: 3) Listeners created: []
2012-06-20 11:20:43 DEBUG [org.apache.aries.blueprint.container.ServiceRecipe] (Blueprint Extender: 3) Calling listeners for initial service registration
2012-06-20 11:20:43 INFO [com.efstech.demo.osgi.core.CoreServicesActivator] (Blueprint Extender: 3) Started Core Services Bundle
2012-06-20 11:20:43 DEBUG [org.jboss.osgi.framework.internal.ServiceManagerPlugin] (Blueprint Extender: 3) Register service: ServiceState{service.id=29, objectClass=[org.osgi.service.blueprint.container.BlueprintContainer], osgi.blueprint.container.version=1.0.0.SNAPSHOT, osgi.blueprint.container.symbolicname=core}
2012-06-20 11:20:43 DEBUG [org.apache.aries.blueprint.container.BlueprintEventDispatcher] (Blueprint Extender: 3) Sending blueprint container event BlueprintEvent[type=CREATED] for bundle core
{code}
So the presence of the CXF namespace appears to stop the beans in the core blueprint XML from being created and the services from being registered, suggested by the logging: Bundle core is waiting for namespace handlers [http://cxf.apache.org/blueprint/core]
I have checked the CXF jar (cxf-rt-core-2.4.6.jar, found under JBOSS_HOME/modules/org/apache/cxf/main) which contains that CXF namespace, and it contains a cxf-core.xml under OSGI-INF/blueprint that from what I understand should make the namespace "http://cxf.apache.org/blueprint/core" available.
I wonder if I am missing some configuration to make this namespace available to my bundle, or if maybe it won't work due to the way I am including the CXF module as an OSGi bundle in the standalone.xml configuration.
Any help would be greatly appreciated. I will attach the updated source and binaries that I am using.
-
OSGiDemo_Blueprint.zip 246.1 KB