Home » Eclipse Projects » Virgo » ClassNotFoundException: org.springframework.context.config.ContextNamespaceHandler(WAB unable to locate spring context handlers)
ClassNotFoundException: org.springframework.context.config.ContextNamespaceHandler [message #910806] |
Mon, 10 September 2012 12:23 |
Seth Helstrip Messages: 22 Registered: September 2012 |
Junior Member |
|
|
Really hoping someone can help me with this, it's had me stumped for days now...
I have a very simple, Spring MVC OSGi bundle. The MANIFEST.MF for this bundle looks like this;-
Manifest-Version: 1.0
Export-Package: com.learning-osgi.test.external;version="0.0.1.SNAPSHOT"
Bundle-ClassPath: .,WEB-INF/classes
Built-By: JJB
Tool: Bnd-1.50.0
Bundle-Name: spring-mvc-bundle
Created-By: Apache Maven Bundle Plugin
Build-Jdk: 1.7.0_05
Bundle-Version: 0.0.1.SNAPSHOT
Bnd-LastModified: 1347278431206
Bundle-ManifestVersion: 2
Import-Package: com.learning-osgi.test.external,javax.servlet.http,org.eclip
se.virgo.web.dm,org.springframework.context;version="[3.0,4)",org.spr
ingframework.stereotype;version="[3.0,4)",org.springframework.validat
ion;version="[3.0,4)",org.springframework.web.bind.annotation;version
="[3.0,4)",org.springframework.web.servlet;version="[3.0,4)"
Bundle-SymbolicName: com.learning-osgi.test.spring-mvc-bundle
Archiver-Version: Plexus Archiver
I'm deploying this bundle to the Eclipse Virgo server, and as such have included the org.eclipse.virgo.web.dm.ServerOsgiBundleXmlWebApplicationContext , within my web.xml, rather than the standard Spring XmlWebApplicationContext.
web.xml;-
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="necessary xsds">
<servlet>
<servlet-name>mvc-dispatcher</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<load-on-startup>2</load-on-startup>
<init-param>
<param-name>contextClass</param-name>
<param-value>org.eclipse.virgo.web.dm.ServerOsgiBundleXmlWebApplicationContext</param-value>
<!-- org.eclipse.virgo.web.dm.ServerOsgiBundleXmlWebApplicationContext -->
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
<context-param>
<param-name>contextClass</param-name>
<param-value>org.eclipse.virgo.web.dm.ServerOsgiBundleXmlWebApplicationContext</param-value>
</context-param>
<servlet-mapping>
<servlet-name>mvc-dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
The bundle deploys successfully. However, when I try to hit the dispatcher servlet, I get the following exception;-
org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from ServletContext resource [/WEB-INF/mvc-dispatcher-servlet.xml]; nested exception is org.springframework.beans.FatalBeanException: NamespaceHandler class [org.springframework.context.config.ContextNamespaceHandler] for namespace [www.springframework.org/schema/context] not found; nested exception is java.lang.ClassNotFoundException: org.springframework.context.config.ContextNamespaceHandler not found from bundle [com.learning-osgi.test.spring-mvc-bundle]
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:412)
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:143)
org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:178)
org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:149)
org.eclipse.gemini.blueprint.context.support.OsgiBundleXmlApplicationContext.loadBeanDefinitions(OsgiBundleXmlApplicationContext.java:170)
org.eclipse.gemini.blueprint.context.support.OsgiBundleXmlApplicationContext.loadBeanDefinitions(OsgiBundleXmlApplicationContext.java:140)
org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:130)
org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:467)...
Looking back at the MANIFEST.MF, there is an Import-Package to include the bundle,
org.springframework.context;version="[3.0,4)"
and checking on the Virgo server, this bundle exists. If I do a jar -tf on the jar, which contains this bundle, the missing class is there.
With all of this in mind, I'm completely stuck, to the point of having to consider walking away from OSGi for this project - which seems insane. I've searched around, and seen many other people having similar issues to this, but they're normally resolved by providing the necessary imports, etc.
I've attached my complete Maven3 project, in the hope that some kind soul will build it and tell me what's not right. I'm building the war this generates, and deploying it to a VANILLA install of Virgo Tomcat (3.5.0.RC1).
Can someone please help?
[Updated on: Mon, 10 September 2012 15:24] Report message to a moderator
|
|
|
Re: ClassNotFoundException: org.springframework.context.config.ContextNamespaceHandler [message #911775 is a reply to message #910806] |
Wed, 12 September 2012 09:47 |
Seth Helstrip Messages: 22 Registered: September 2012 |
Junior Member |
|
|
Thought I'd post a reply on how I solved this, in the hope that it stops others making the same mistake.
The problem lies in the Import-Package being generated by the maven-bundle-plugin. Essentially what this plugin does is to scan the bundle classpath, identifying all classes used within the bundle, cross referencing this with the maven dependencies and generating the relavent Import-Package statement.
Because in this case, the jar was in fact a war, and as such contained XML that wasn't deemed as being on the classpath, the bundle plugin wasn't picking up the required dependencies. This went for both level 1 and transitive dependencies (I spotted the level 1 requirement).
The way I overcame this was to provide a dummy import for the 'missing' class within one of my Java files, and to see what the bundle plugin was adding to the import statement. I'd then run the war again, and a new classNotFoundException for a level 2 class was produced. Again, imported and used this within a java class, and eventually by following this pattern, was able to get the full Import-Package required, and as such add the necessary forced imports to the configuration of the bundle plugin.
For anyone having the same problem, and wanting to try a quick fix, this is what was added (to the plugin config - not the MANIFEST.MF).
<Import-Package>*,org.eclipse.virgo.web.dm,
org.springframework.context,
org.springframework.context.support,
org.springframework.context.config,
org.springframework.web.servlet.config,
org.springframework.web.servlet.view,
org.springframework.web.servlet.view.xml
</Import-Package>
I'm going to be publishing the much needed Maven 3 archetypes for Spring MVC bundles shortly, will update this thread with the location.
Hope this helps someone.
[Updated on: Wed, 12 September 2012 09:47] Report message to a moderator
|
|
| | | |
Goto Forum:
Current Time: Fri Apr 26 20:19:10 GMT 2024
Powered by FUDForum. Page generated in 0.03490 seconds
|