PDA

View Full Version : OsgiBundleXmlWebApplicationContext problem


habuma
May 5th, 2008, 12:00 PM
I've had some small success with a simple Spring-DM application (using v1.1.0-m2), but now I'm trying to OSGi-ify a much larger application and am encountering problems with OsgiBundleXmlWebApplicationContext.

Specifically, I get this stack trace (abridged for readability's sake):

SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListe ner
java.lang.NullPointerException
at org.springframework.osgi.util.internal.MapBasedDic tionary.put(MapBasedDictionary.java:142)
at org.springframework.osgi.web.context.support.OsgiB undleXmlWebApplicationContext.customizeApplication ContextServiceProperties(OsgiBundleXmlWebApplicati onContext.java:176)
at org.springframework.osgi.context.support.AbstractO sgiBundleApplicationContext.publishContextAsOsgiSe rviceIfNecessary(AbstractOsgiBundleApplicationCont ext.java:283)
at org.springframework.osgi.context.support.AbstractD elegatedExecutionApplicationContext.finishRefresh( AbstractDelegatedExecutionApplicationContext.java: 307)
at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:384)
...

Upon inspecting the source code, I find that OsgiBundleXmlWebApplicationContext is trying to put a String known as "namespace" into a map. The problem is that the namespace String is null. So, my question: Why would the namespace be null and what can I do to make it not null?

habuma
May 5th, 2008, 12:06 PM
Okay...I just realized that the namespace String is set from the setNamespace() method which is ultimately specified by ConfigurableWebApplicationContext (duh)...

My question still remains: Why would the namespace be null? Any clues?

habuma
May 5th, 2008, 12:47 PM
And, in case it makes a difference...

I'm only using ContextLoaderListener to load my application context and do not have a DispatcherServlet configured. That's because I'm not using Spring MVC for the web layer (but still need a Spring context loaded for Wicket's sake).

Costin Leau
May 13th, 2008, 04:46 AM
Craig, you probably know by now but just for the record, the issue has been addressed in the TRUNK. See:
http://jira.springframework.org/browse/OSGI-476

mburbidg
May 26th, 2008, 02:50 PM
I'm getting this same exception. My war is Spring-MVC based, and does have a DispaterServlet configured. Am I leaving some configuration piece out? If not, is there a way to work around this without getting the fix in the source and building it myself?

Thanks,
Michael-

Costin Leau
May 26th, 2008, 03:01 PM
Sure - try one of the nightly builds (see the official home page for the Maven repo information).

mburbidg
May 26th, 2008, 06:17 PM
But this seems like a bug that would prevent anyone from using Spring-DM. Wouldn't it blocking even releasing the milestone build? Is there some configuration that I can add that will prevent this? I like using the tested/milestone builds.

Thanks,
Michael-

Costin Leau
May 27th, 2008, 02:18 AM
The bug appears if one is using the Spring-MVC integration w/o Spring-MVC, that is the application context w/o the DispatcherServlet. You can alleviate the problem by setting up the namespace property for OsgiBundleXmlWebApplicationContext.

mburbidg
May 27th, 2008, 12:08 PM
Thanks for all the help. I finally have a simple Spring-MVC web application working with equinox/catalina. Looking forward to making progress on our real app!