PDA

View Full Version : OSGIBundleXmlWebApplicationContext -Refresh error



fcm4409
May 8th, 2008, 01:18 PM
Hi,

I have a simple MVC web bundle and I'm trying to start it in Spring DM and I am getting the following error:

28062 [Timer-1] ERROR org.springframework.osgi.web.context.support.OsgiB undleXml
WebApplicationContext - Refresh error
java.lang.NullPointerException
at org.springframework.osgi.util.internal.MapBasedDic tionary.put(MapBase
dDictionary.java:142)
at org.springframework.osgi.web.context.support.OsgiB undleXmlWebApplicat
ionContext.customizeApplicationContextServicePrope rties(OsgiBundleXmlWebApplicat
ionContext.java:176)

----
I'm following the instructions on the Reference Docs for the web.xml file. It contains the following definitions (per Ref Docs)
<context-param>
<param-name>contextClass</param-name>
<param-value>org.springframework.osgi.web.context.support.OsgiB undleXmlWebApplicationContext</param-value>
</context-param>

<listener>
<listener-class>org.springframework.web.context.ContextLoaderListe ner</listener-class>
</listener>

<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextClass</param-name>
<param-value>org.springframework.osgi.web.context.support.OsgiB undleXmlWebApplicationContext</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
----------
I'm also importing the following packages:
mport-Package: org.osgi.framework;version="1.3.0",
javax.servlet,
javax.servlet.http,
javax.servlet.resources,
javax.xml.parsers;resolution:=optional,
org.apache.commons.logging,
org.springframework.context.support,
org.springframework.ui,
org.springframework.web.context,
org.springframework.web.context.support,
org.springframework.web.servlet,
org.springframework.web.servlet.mvc,
org.springframework.web.servlet.mvc.support,
org.springframework.web.servlet.view,
org.springframework.osgi.web.context.support,
org.w3c.dom,
org.xml.sax;resolution:=optional,
org.xml.sax.helpers;resolution:=optional


Am I missing something not mentioned in the Ref Docs? Any suggestions are welcomed. Thanks.

Costin Leau
May 12th, 2008, 02:27 AM
This is a bug that will be fixed shortly:
http://jira.springframework.org/browse/OSGI-476
If you're interested, please follow the issue.

jackzhuo
Jul 17th, 2010, 11:48 PM
hi costin,

I am reading the book named <Modular java> now, and testing the samples in the book.

when i run the "web bundle" example and found the following error:
[Timer-2] DEBUG org.springframework.osgi.extender.internal.support .NamespacePlugins - Trying to resolving namespace handler for http://www.springframework.org/schema/context
[Timer-2] DEBUG org.springframework.osgi.extender.internal.support .NamespacePlugins - Namespace handler for http://www.springframework.org/schema/context found inside Spring Context (org.springframework.context)
[Timer-2] DEBUG org.springframework.osgi.web.context.support.OsgiB undleXmlWebApplicationContext - Refresh error
org.springframework.beans.factory.BeanDefinitionSt oreException: Unexpected exception parsing XML document from URL [bundleentry://53.fwk22068557/WEB-INF/dude-servlet.xml]; nested exception is java.lang.NullPointerException
at org.springframework.beans.factory.xml.XmlBeanDefin itionReader.doLoadBeanDefinitions(XmlBeanDefinitio nReader.java:420)
at org.springframework.beans.factory.xml.XmlBeanDefin itionReader.loadBeanDefinitions(XmlBeanDefinitionR eader.java:342)
at org.springframework.beans.factory.xml.XmlBeanDefin itionReader.loadBeanDefinitions(XmlBeanDefinitionR eader.java:310)
at org.springframework.beans.factory.support.Abstract BeanDefinitionReader.loadBeanDefinitions(AbstractB eanDefinitionReader.java:143)
at org.springframework.beans.factory.support.Abstract BeanDefinitionReader.loadBeanDefinitions(AbstractB eanDefinitionReader.java:178)
at org.springframework.beans.factory.support.Abstract BeanDefinitionReader.loadBeanDefinitions(AbstractB eanDefinitionReader.java:149)
at org.springframework.osgi.context.support.OsgiBundl eXmlApplicationContext.loadBeanDefinitions(OsgiBun dleXmlApplicationContext.java:176)
at org.springframework.osgi.context.support.OsgiBundl eXmlApplicationContext.loadBeanDefinitions(OsgiBun dleXmlApplicationContext.java:142)
at org.springframework.context.support.AbstractRefres hableApplicationContext.refreshBeanFactory(Abstrac tRefreshableApplicationContext.java:123)
at org.springframework.context.support.AbstractApplic ationContext.obtainFreshBeanFactory(AbstractApplic ationContext.java:422)
at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:352)
at org.springframework.osgi.context.support.AbstractD elegatedExecutionApplicationContext.access$301(Abs tractDelegatedExecutionApplicationContext.java:69)
...........
Caused by: java.lang.NullPointerException
at org.eclipse.osgi.framework.util.KeyedHashSet.hash( KeyedHashSet.java:376)
at org.eclipse.osgi.framework.util.KeyedHashSet.add(K eyedHashSet.java:83)
at org.eclipse.osgi.internal.loader.BundleLoader.find RequiredSource(BundleLoader.java:1103)
at org.eclipse.osgi.internal.loader.BundleLoader.find Source(BundleLoader.java:1042)
at org.eclipse.osgi.internal.loader.BundleLoader.getP ackageSource(BundleLoader.java:1114)
at org.eclipse.osgi.framework.internal.core.ExportedP ackageImpl.getImportingBundles(ExportedPackageImpl .java:70)
at org.springframework.osgi.io.internal.resolver.Pack ageAdminResolver.getImportedBundles(PackageAdminRe solver.java:112)
at org.springframework.osgi.io.OsgiBundleResourcePatt ernResolver.findClassPathMatchingResources(OsgiBun dleResourcePatternResolver.java:229)

and I have checked the jira issue you metioned, but I can not solve my problem. Can you help me?

my web.xml file:
<context-param>
<param-name>contextClass</param-name>
<param-value>org.springframework.osgi.web.context.support.OsgiB undleXmlWebApplicationContext</param-value>
</context-param>

<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/dude-osgi.xml</param-value>
</context-param>

<listener>
<listener-class>org.springframework.web.context.ContextLoaderListe ner</listener-class>
</listener>

<servlet>
<servlet-name>dude</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextClass</param-name>
<param-value>org.springframework.osgi.web.context.support.OsgiB undleXmlWebApplicationContext</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
<servlet-name>dude</servlet-name>
<url-pattern>*.htm</url-pattern>
</servlet-mapping>

---------------------------------------------------------------------
osgi.bnd file as following:
Bundle-ClassPath: .,WEB-INF/classes

Import-Package: *,\
org.springframework.osgi.web.context.support,\
org.springframework.web.servlet,\
org.springframework.web.servlet.handler,\
org.springframework.web.servlet.mvc,\
org.springframework.web.servlet.view,\
dwmj.domain,\
org.springframework.web.servlet.mvc.annotation,\
org.springframework.web.context, \
javax.servlet.http, \
javax.servlet.resources, \
javax.xml.parsers;resolution:=optional, \
org.w3c.dom, \
org.xml.sax;resolution:=optional, \
org.xml.sax.helpers;resolution:=optional
Require-Bundle: org.springframework.osgi.jstl.osgi
Web-ContextPath: dude

jackzhuo
Jul 17th, 2010, 11:52 PM
oh sorry, I forgot to write my spring-dm verion,

spring-dm: 1.2.0
spring-core : 2.5.6.A

By the way, could you explain to me what difference between 2.5.6 and 2.5.6, because I use maven to import dependencies about spring-dm, it may import 2.5.6.A and 2.5.6 all, but it can confilct.

jackzhuo
Jul 25th, 2010, 12:43 AM
I solved this problem, and it is not the problem of Spring-dm and Spring mvc, the reason is some version conflicted.

the step that I solved this problem is as following:
(1) at first, in my dependencies list, there are two versions, spring 2.5.6 and 2.5.6.A, So i changed the spring to one version 2.5.6.A that is the spring-dm 1.2.0 related.
(2) for the problem about this issue, I referenced web-console sample in spring-dm 1.2.0, and compared this sample's dependency and my project, and elimated all unused dependencies in my project. the NullPointerException problem generated by some spring version missed,following is the last bundles:

id State Bundle
0 ACTIVE org.eclipse.osgi_3.5.1.R35x_v20090827
1 ACTIVE org.springframework.core_2.5.6.A
2 ACTIVE org.springframework.aop_2.5.6.A
3 ACTIVE org.springframework.beans_2.5.6.A
4 ACTIVE org.springframework.context_2.5.6.A
5 ACTIVE org.springframework.context.support_2.5.6.A
6 ACTIVE org.springframework.transaction_2.5.6.A
7 ACTIVE org.springframework.test_2.5.6.A
8 ACTIVE com.springsource.org.aopalliance_1.0.0
9 ACTIVE com.springsource.net.sf.cglib_2.1.3
10 ACTIVE com.springsource.javax.servlet.jsp.jstl_1.1.2
11 ACTIVE com.springsource.javax.servlet.jsp_2.1.0
12 ACTIVE com.springsource.javax.el_1.0.0
13 ACTIVE com.springsource.org.apache.xmlcommons_1.3.3
14 ACTIVE com.springsource.org.apache.taglibs.standard_1.1.2
15 ACTIVE com.springsource.org.apache.commons.el_1.0.0
16 ACTIVE com.springsource.slf4j.org.apache.commons.logging_ 1.5.0
17 ACTIVE com.springsource.slf4j.api_1.5.0
Fragments=18
18 RESOLVED com.springsource.slf4j.log4j_1.5.0
Master=17
19 ACTIVE org.springframework.osgi.log4j.osgi_1.2.15.SNAPSHO T
Fragments=50
20 ACTIVE org.springframework.osgi.core_1.2.0
21 ACTIVE org.springframework.osgi.io_1.2.0
22 ACTIVE org.springframework.osgi.web_1.2.0
23 ACTIVE org.springframework.osgi.web.extender_1.2.0
24 ACTIVE org.springframework.osgi.extender_1.2.0
25 ACTIVE org.springframework.web_2.5.6.A
26 ACTIVE org.springframework.web.servlet_2.5.6.A
27 ACTIVE org.springframework.osgi.jasper.osgi_5.5.23.SNAPSH OT
28 ACTIVE org.springframework.osgi.jstl.osgi_1.1.2.SNAPSHOT
29 ACTIVE com.springsource.org.apache.catalina_6.0.24
Fragments=37, 51
30 ACTIVE com.springsource.javax.annotation_1.0.0
31 ACTIVE com.springsource.javax.ejb_3.0.0
32 ACTIVE com.springsource.javax.mail_1.4.0
33 ACTIVE com.springsource.javax.persistence_1.0.0
34 ACTIVE com.springsource.javax.servlet_2.5.0
35 ACTIVE com.springsource.javax.xml.ws_2.1.1
36 ACTIVE com.springsource.org.apache.juli.extras_6.0.24
37 RESOLVED com.springsource.org.apache.coyote_6.0.24
Master=29
38 ACTIVE com.springsource.javax.xml.rpc_1.1.0
39 ACTIVE com.springsource.javax.activation_1.1.0
40 ACTIVE com.springsource.javax.xml.bind_2.0.0
41 ACTIVE com.springsource.javax.xml.soap_1.3.0
42 ACTIVE com.springsource.javax.xml.stream_1.0.1
43 ACTIVE org.springframework.osgi.catalina.start.osgi_1.0.0
44 ACTIVE org.compass-project.compass_2.2.0
45 ACTIVE com.dudewheresmyjar.domain_1.0.0.SNAPSHOT
46 ACTIVE com.dudewheresmyjar.index_1.0.0.SNAPSHOT
47 ACTIVE com.dudewheresmyjar.spider_1.0.0.SNAPSHOT
48 ACTIVE com.dudewheresmyjar.web_1.0.0.SNAPSHOT
49 ACTIVE org.springframework.osgi.servlet-api.osgi_2.5.0.SNAPSHOT
50 RESOLVED com.dudewheresmyjar.logging.cfg_0.0.0
Master=19
51 RESOLVED com.dudewheresmyjar.catalina.cfg_0.0.0
Master=29

I borrowed the two configuration project for logging and catalina.

In these steps, there are a problem like this:
* ServletException: Could not get RequestDispatcher .....
* DigesterFactory] - Could not get url for /javax/servlet/resources/j2ee_1_4.xsd
, and this reason of these problems is the catalina's configuration is missed.