Results 1 to 2 of 2

Thread: Problem using OsgiBundleXmlWebApplicationContext with Websphere 7

  1. #1
    Join Date
    Aug 2005
    Location
    New Jersey, USA
    Posts
    5

    Default Problem using OsgiBundleXmlWebApplicationContext with Websphere 7

    Hi,
    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.

    <context-param>
    <param-name>contextClass</param-name>
    <param-value>org.springframework.osgi.web.context.support .OsgiBundleXmlWebApplicationContext</param-value>
    </context-param>

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

    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.
    Thanks.

    Below is the stack trace if it helps.

    Deepak

    [5/17/10 13:26:54:943 EDT] 000000e3 webapp E com.ibm.ws.webcontainer.webapp.WebApp 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>(Throwable.java:67)
    at org.springframework.util.Assert.notNull(Assert.jav a:111)
    at org.springframework.osgi.context.support.AbstractD elegatedExecutionApplicationContext.normalRefresh( AbstractDelegatedExecutionApplicationContext.java: 163)
    at org.springframework.osgi.context.support.AbstractD elegatedExecutionApplicationContext$NoDependencies WaitRefreshExecutor.refresh(AbstractDelegatedExecu tionApplicationContext.java:80)
    at org.springframework.osgi.context.support.AbstractD elegatedExecutionApplicationContext.refresh(Abstra ctDelegatedExecutionApplicationContext.java:159)
    at org.springframework.web.context.ContextLoader.crea teWebApplicationContext(ContextLoader.java:270)
    at org.springframework.web.context.ContextLoader.init WebApplicationContext(ContextLoader.java:197)
    at org.springframework.web.context.ContextLoaderListe ner.contextInitialized(ContextLoaderListener.java: 47)
    at com.ibm.ws.webcontainer.webapp.WebApp.notifyServle tContextCreated(WebApp.java:1667)
    at com.ibm.ws.webcontainer.webapp.WebApp.commonInitia lizationFinish(WebApp.java:368)
    at com.ibm.ws.webcontainer.webapp.WebAppImpl.initiali ze(WebAppImpl.java:294)
    at com.ibm.ws.webcontainer.webapp.WebGroupImpl.addWeb Application(WebGroupImpl.java:100)
    at com.ibm.ws.webcontainer.VirtualHostImpl.addWebAppl ication(VirtualHostImpl.java:166)
    at com.ibm.ws.webcontainer.WSWebContainer.addWebApp(W SWebContainer.java:731)
    at com.ibm.ws.webcontainer.WSWebContainer.addWebAppli cation(WSWebContainer.java:616)
    at com.ibm.ws.webcontainer.component.WebContainerImpl .install(WebContainerImpl.java:376)
    at com.ibm.ws.osgi.web.extender.application.VirtualEn closingApplication.start(VirtualEnclosingApplicati on.java:493)
    at com.ibm.ws.osgi.web.extender.BundleHandler.startBu ndle(BundleHandler.java:623)
    at com.ibm.ws.osgi.web.extender.WebModuleExtender.pro cessBundle(WebModuleExtender.java:128)
    at com.ibm.ws.osgi.web.extender.WebModuleExtender.bun dleChanged(WebModuleExtender.java:166)
    at com.ibm.ws.osgi.web.extender.WebModuleExtender$Web BundleTrackerCustomizer.addingBundle(WebModuleExte nder.java:194)
    at org.osgi.util.tracker.BundleTracker$Tracked.custom izerAdding(BundleTracker.java:440)
    at org.osgi.util.tracker.AbstractTracked.trackAdding( AbstractTracked.java:261)
    at org.osgi.util.tracker.AbstractTracked.track(Abstra ctTracked.java:233)
    at org.osgi.util.tracker.BundleTracker$Tracked.bundle Changed(BundleTracker.java:413)
    at org.eclipse.osgi.framework.internal.core.BundleCon textImpl.dispatchEvent(BundleContextImpl.java:919)
    at org.eclipse.osgi.framework.eventmgr.EventManager.d ispatchEvent(EventManager.java:227)
    at org.eclipse.osgi.framework.eventmgr.ListenerQueue. dispatchEventSynchronous(ListenerQueue.java:149)
    at org.eclipse.osgi.framework.internal.core.Framework .publishBundleEventPrivileged(Framework.java:1350)
    at org.eclipse.osgi.framework.internal.core.Framework .publishBundleEvent(Framework.java:1301)
    at org.eclipse.osgi.framework.internal.core.BundleHos t.startWorker(BundleHost.java:338)
    at org.eclipse.osgi.framework.internal.core.AbstractB undle.start(AbstractBundle.java:280)
    at com.ibm.ws.app.container.aries.AriesApplication.fi ndAndStartBundles(AriesApplication.java:741)
    at com.ibm.ws.app.container.aries.AriesApplication.in stall(AriesApplication.java:433)
    at com.ibm.ws.app.container.aries.AriesApplicationEve ntHandler.handleEvent(AriesApplicationEventHandler .java:140)
    at com.ibm.ws.event.internal.adapter.OSGiHandlerAdapt er.handleEvent(OSGiHandlerAdapter.java:27)
    at com.ibm.ws.event.internal.dispatcher.DefaultEventD ispatcher.invoke(DefaultEventDispatcher.java:28)
    at com.ibm.ws.event.internal.HandlerHolder.fireSynchr onousEvent(HandlerHolder.java:323)
    at com.ibm.ws.event.internal.EventEngineImpl.publishE vent(EventEngineImpl.java:250)
    at com.ibm.ws.event.internal.EventEngineImpl.publishO sgiEvent(EventEngineImpl.java:193)
    at com.ibm.ws.event.internal.EventEngineImpl.sendEven t(EventEngineImpl.java:162)
    at com.ibm.ws.eba.app.framework.fep.EBAAppFramework.s tartApplication(EBAAppFramework.java:501)
    at com.ibm.ws.eba.internal.framework.EBALauncherImpl. startApplication(EBALauncherImpl.java:507)
    at com.ibm.ws.eba.external.framework.LauncherImpl.sta rtApplication(LauncherImpl.java:619)
    at com.ibm.ws.eba.bla.EbaOperationHandler.executeOper ation(EbaOperationHandler.java:94)
    at com.ibm.ws.management.bla.runtime.ControlOperation Helper.invokeControlOperationHandler(ControlOperat ionHelper.java:791)
    at com.ibm.ws.management.bla.runtime.ControlOperation Helper.execControlOpOnLocalServer(ControlOperation Helper.java:694)
    at com.ibm.wsspi.management.bla.runtime.CompUnitContr olOpDispatcher.dispatchCompUnitControlOpToTarget(C ompUnitControlOpDispatcher.java:257)
    at com.ibm.wsspi.management.bla.runtime.CompUnitContr olOpDispatcher.dispatch(CompUnitControlOpDispatche r.java:180)
    at com.ibm.ws.management.bla.steps.StepStartBLA.execu te(StepStartBLA.java:157)
    at com.ibm.wsspi.management.bla.op.compound.Phase.exe cute(Phase.java:151)
    at com.ibm.wsspi.management.bla.op.compound.CompoundO peration._doPhaseExecute(CompoundOperation.java:10 2)
    at com.ibm.wsspi.management.bla.op.compound.CompoundO peration.doExecute(CompoundOperation.java:85)
    at com.ibm.wsspi.management.bla.op.Operation.execute( Operation.java:158)
    at com.ibm.wsspi.management.bla.op.compound.CompoundO peration.execute(CompoundOperation.java:68)
    at com.ibm.ws.management.bla.commands.ADTCommand$Oper ationScheduler.run(ADTCommand.java:524)
    at java.lang.Thread.run(Thread.java:736)

  2. #2
    Join Date
    Aug 2005
    Location
    New Jersey, USA
    Posts
    5

    Default possible Spring DM-2.0.0.M1 issue

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

    I think I have found a problem in the Spring DM bundle
    spring-osgi-web-2.0.0.M1.jar

    class: OsgiBundleXmlWebApplicationContext.java

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •