Announcement Announcement Module

Spring Dynamic Modules forum decommissioned in favor of Eclipse Gemini Blueprint

With the official first release of Eclipse Gemini Blueprint shipped, the migration of the Spring Dynamic Modules code base to the Eclipse Foundation, as part of the Gemini project, has been completed.

As such, this forum has been decommissioned in favour of the Eclipse Gemini forums.
See more
See less
Problem using OsgiBundleXmlWebApplicationContext with Websphere 7 Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problem using OsgiBundleXmlWebApplicationContext with Websphere 7

    I am trying to use Spring DM within hte new IBM Websphere 7 environment along with the featurepack for OSGi. I am able to deploy my spring based web application within the OSGi env using the SpringFW jar bundles along with the dependency bundles.
    I want to use the spring DM based jar bundles also within my application and try to access the OSGi services using the declarative syntax. To do this I had include the spring dm bundles - minus the web extender bundle since its not required within thewebsphere environment. Also I made the change to the web xml to add the context param and listener.

    <param-value> .OsgiBundleXmlWebApplicationContext</param-value>

    <listener-class>org.springframework.web.context.ContextLoade rListener</listener-class>

    But when I try to deply this web bundle, I get the error
    "bundle context should be set before refreshing the application context"

    Looks like the bundle context is not being set even when the WAR is a WEB bundle. When checked on the IBM forums they said that
    "Access to the BundleContext from inside a WAB is as per section 128.6.1 of the OSGi 4.2 Enterprise Specification:

    BundleContext ctxt = (BundleContext) servletContext.getAttribute("osgi-bundlecontext");

    Can you let know why I am getting this error.

    Below is the stack trace if it helps.


    [5/17/10 13:26:54:943 EDT] 000000e3 webapp E notifyServletContextCreated SRVE0283E: Exception caught while initializing context: {0}
    java.lang.IllegalArgumentException: bundle context should be set before refreshing the application context
    at java.lang.Throwable.<init>(
    at org.springframework.util.Assert.notNull(Assert.jav a:111)
    at elegatedExecutionApplicationContext.normalRefresh( 163)
    at elegatedExecutionApplicationContext$NoDependencies WaitRefreshExecutor.refresh(AbstractDelegatedExecu
    at elegatedExecutionApplicationContext.refresh(Abstra
    at org.springframework.web.context.ContextLoader.crea teWebApplicationContext(
    at org.springframework.web.context.ContextLoader.init WebApplicationContext(
    at org.springframework.web.context.ContextLoaderListe ner.contextInitialized( 47)
    at tContextCreated(
    at lizationFinish(
    at ze(
    at Application(
    at ication(
    at cation(
    at .install(
    at closingApplication.start(VirtualEnclosingApplicati
    at ndle(
    at cessBundle(
    at dleChanged(
    at$Web BundleTrackerCustomizer.addingBundle(WebModuleExte
    at org.osgi.util.tracker.BundleTracker$Tracked.custom izerAdding(
    at org.osgi.util.tracker.AbstractTracked.trackAdding(
    at org.osgi.util.tracker.AbstractTracked.track(Abstra
    at org.osgi.util.tracker.BundleTracker$Tracked.bundle Changed(
    at org.eclipse.osgi.framework.internal.core.BundleCon textImpl.dispatchEvent(
    at org.eclipse.osgi.framework.eventmgr.EventManager.d ispatchEvent(
    at org.eclipse.osgi.framework.eventmgr.ListenerQueue. dispatchEventSynchronous(
    at org.eclipse.osgi.framework.internal.core.Framework .publishBundleEventPrivileged(
    at org.eclipse.osgi.framework.internal.core.Framework .publishBundleEvent(
    at org.eclipse.osgi.framework.internal.core.BundleHos t.startWorker(
    at org.eclipse.osgi.framework.internal.core.AbstractB undle.start(
    at ndAndStartBundles(
    at stall(
    at ntHandler.handleEvent(AriesApplicationEventHandler .java:140)
    at er.handleEvent(
    at ispatcher.invoke(
    at onousEvent(
    at vent(
    at sgiEvent(
    at t(
    at tartApplication(
    at startApplication(
    at rtApplication(
    at ation(
    at Helper.invokeControlOperationHandler(ControlOperat
    at Helper.execControlOpOnLocalServer(ControlOperation
    at olOpDispatcher.dispatchCompUnitControlOpToTarget(C
    at olOpDispatcher.dispatch(CompUnitControlOpDispatche
    at te(
    at cute(
    at peration._doPhaseExecute( 2)
    at peration.doExecute(
    at peration.execute(

  • #2
    possible Spring DM-2.0.0.M1 issue

    I am using the Spring DM 2.0.0.M1 release version.

    I think I have found a problem in the Spring DM bundle


    This class is gets the bundle context from the servlet context and is looking for the following attribute name
    BUNDLE_CONTEXT_ATTRIBUTE = "org.springframework.osgi.web."
    + BundleContext.class.getName();

    Since Spring DM version 2.0.0.M1 is supposed to also support blueprint standards, it should be additionally looking for the attribute name "osgi-bundlecontext" in the servlet context.

    I have temporarily overcome this problem by creating a fragment bundle containing my own class thats extending the above OsgiBundleXmlWebApplicationContext class and using the same which uses the standard attribute name.

    I think this needs to be fixed in the regular Spring DM release.

    -Deepak Panchal