aspose file tools*
The moose likes Spring and the fly likes BeanDefinitionParsingException : NamespaceHandler Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "BeanDefinitionParsingException : NamespaceHandler" Watch "BeanDefinitionParsingException : NamespaceHandler" New topic
Author

BeanDefinitionParsingException : NamespaceHandler

Ranen Das
Greenhorn

Joined: May 31, 2012
Posts: 4
Hello,

I am trying to deploy a portlet war file with Spring 3.1 in Jboss 7.0.2 - Liferay6.1, but when I deploy, I get following error, what could be the reason, anyone knows? Please help me.

Spring 3.1.1+LR6.1+JBoss7.0.2 and I put all my spring jars in Jboss-7.o.2/modules

This is the error stack trace:-

14:46:09,504 ERROR [org.springframework.web.portlet.DispatcherPortlet] (MSC service thread 1-2) Context initialization failed: org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/context]
Offending resource: PortletContext resource [/WEB-INF/oneprmpendinguserrequests-portlet.xml]


at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:68) [org.springframework.beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:85) [org.springframework.beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:80) [org.springframework.beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.error(BeanDefinitionParserDelegate.java:316) [org.springframework.beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1416) [org.springframework.beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1409) [org.springframework.beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:184) [org.springframework.beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.doRegisterBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:140) [org.springframework.beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:111) [org.springframework.beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:493) [org.springframework.beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:390) [org.springframework.beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334) [org.springframework.beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302) [org.springframework.beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:174) [org.springframework.beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:209) [org.springframework.beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:180) [org.springframework.beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.web.portlet.context.XmlPortletApplicationContext.loadBeanDefinitions(XmlPortletApplicationContext.java:125) [org.springframework.web.portlet-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.web.portlet.context.XmlPortletApplicationContext.loadBeanDefinitions(XmlPortletApplicationContext.java:93) [org.springframework.web.portlet-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:131) [org.springframework.context-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:522) [org.springframework.context-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:436) [org.springframework.context-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.web.portlet.FrameworkPortlet.createPortletApplicationContext(FrameworkPortlet.java:356) [org.springframework.web.portlet-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.web.portlet.FrameworkPortlet.initPortletApplicationContext(FrameworkPortlet.java:294) [org.springframework.web.portlet-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.web.portlet.FrameworkPortlet.initPortletBean(FrameworkPortlet.java:268) [org.springframework.web.portlet-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at org.springframework.web.portlet.GenericPortletBean.init(GenericPortletBean.java:120) [org.springframework.web.portlet-3.1.1.RELEASE.jar:3.1.1.RELEASE]
at javax.portlet.GenericPortlet.init(GenericPortlet.java:107) [portlet.jar:private-2011/04/13-23:33:42]
at com.liferay.portlet.InvokerPortletImpl.init(InvokerPortletImpl.java:246)
at com.liferay.portlet.PortletInstanceFactoryImpl.init(PortletInstanceFactoryImpl.java:216)
at com.liferay.portlet.PortletInstanceFactoryImpl.create(PortletInstanceFactoryImpl.java:139)
at com.liferay.portlet.PortletInstanceFactoryUtil.create(PortletInstanceFactoryUtil.java:40) [portal-service.jar:private-2011/04/13-23:33:42]
at com.liferay.portlet.PortletBagFactory.create(PortletBagFactory.java:310)
at com.liferay.portal.deploy.hot.PortletHotDeployListener.initPortlet(PortletHotDeployListener.java:524)
at com.liferay.portal.deploy.hot.PortletHotDeployListener.doInvokeDeploy(PortletHotDeployListener.java:302)
at com.liferay.portal.deploy.hot.PortletHotDeployListener.invokeDeploy(PortletHotDeployListener.java:115)
at com.liferay.portal.kernel.deploy.hot.HotDeployUtil._doFireDeployEvent(HotDeployUtil.java:111) [portal-service.jar:private-2011/04/13-23:33:42]
at com.liferay.portal.kernel.deploy.hot.HotDeployUtil._fireDeployEvent(HotDeployUtil.java:188) [portal-service.jar:private-2011/04/13-23:33:42]
at com.liferay.portal.kernel.deploy.hot.HotDeployUtil.fireDeployEvent(HotDeployUtil.java:40) [portal-service.jar:private-2011/04/13-23:33:42]
at com.liferay.portal.kernel.servlet.PortletContextListener.doPortalInit(PortletContextListener.java:101) [portal-service.jar:private-2011/04/13-23:33:42]
at com.liferay.portal.kernel.util.BasePortalLifecycle.portalInit(BasePortalLifecycle.java:42) [portal-service.jar:private-2011/04/13-23:33:42]
at com.liferay.portal.kernel.util.PortalLifecycleUtil.flushInits(PortalLifecycleUtil.java:45) [portal-service.jar:private-2011/04/13-23:33:42]
at com.liferay.portal.servlet.MainServlet.initPlugins(MainServlet.java:833)



This is my oneprmpendinguserrequests-portlet.xml file:-

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
">

<context:component-scan base-package="com.se.oneprm" />
<mvc:annotation-driven />


<!-- Resolves view names to protected .jsp resources within the /WEB-INF/views directory -->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/view/"/>
<property name="suffix" value=".jsp"/>
</bean>
</beans>
Bill Gorder
Bartender

Joined: Mar 07, 2010
Posts: 1648
    
    7

What does your POM look like?


[How To Ask Questions][Read before you PM me]
Ranen Das
Greenhorn

Joined: May 31, 2012
Posts: 4
I do not have pom, I put all the spring jars in "Liferay-6.1.0\jboss-7.0.2\modules\org\spring" and then put in individual folders like asm goes ...\asm folder, created module.xml file , compile time error told me to required dependcy jars, so once I removed all dependency error, I am getting the above exception, I created my .war using Eclipse indigo. Let me know what do you think, thanks for your reply...RD
Ranen Das
Greenhorn

Joined: May 31, 2012
Posts: 4
Ok, one more development, if I put commenting in component scan and mvc annotation and use spring old settings, it works fine

this .xml works fine


<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
">

<bean id="SePendingUserPortletController" class="com.se.oneprm.controller.SePendingUserPortletController"/>

<bean id="portletModeHandlerMapping" class = "org.springframework.web.portlet.handler.PortletModeHandlerMapping">
<property name="portletModeMap">
<map>
<entry key="view">
<ref bean="SePendingUserPortletController"/>
</entry>
</map>
</property>
</bean>


<!-- <context:component-scan base-package="com.se.oneprm" /> -->
<!-- <mvc:annotation-driven /> -->


<!-- Resolves view names to protected .jsp resources within the /WEB-INF/views directory -->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/view/"/>
<property name="suffix" value=".jsp"/>
</bean>
</beans>

So, what could be the reason?
Bill Gorder
Bartender

Joined: Mar 07, 2010
Posts: 1648
    
    7

Is there a reason you are not using maven to handle your dependency management?

Taking the spring-context.jar for example (since you are Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/context] )

If you open that jar with 7zip or a similar program there are 2 files to pay attention to :

META-INF/spring.handlers
META-INF/spring.schemas

This is what is referenced. If you open the file spring.schemas you will often see the path (within the same jar) to the actual XSD's in case you need to validate against them offline.

So the dilemma is this. If you are just copying dependencies into your METAINF directory your are copying the spring.handlers and spring.schemas from each jar and they are overwriting one another. So perhaps the one that is there is from spring-beans.jar and that is why it is working. If you are going to do things this way you are going to have to append the contents of each jars spring.handlers and spring.schemas files together into one file so everything it is looking for can be found.

Unless there is a good reason for doing things this way I would consider using Maven.
Ranen Das
Greenhorn

Joined: May 31, 2012
Posts: 4
Hi Bill, thanks for your suggestion, now I understand the problem. See, my application is already developed quite a lot, so now if we go for maven, I don't know my manager will allow me to do or not, but certainly a good suggestion, even I also thought that way initially.

Now come to your suggestion - what I did - I created those 2 files inside my one particular portlet's META-INF, but still same error.

Now my question to you is which META-INF I should put those 2 files. I created 2 new files(.handler and .schemas) and put all the spring jars information inside 2 files and it has got all the settings for all spring jars.

Now my question you is which location I should put these 2 files, becauseputting individual portlets META-INF does not work, plus its not a decent idea, becausewe will have lot of portlets
Bill Gorder
Bartender

Joined: Mar 07, 2010
Posts: 1648
    
    7

Ranen,

Honestly I have never tried what you are doing. It is similar to what was done back when there was a Spring uber jar.

You can try to create a META-INF directory in your resources directory (same place you keep your application-context.xml) and create both the 2 files (its spring.handlers and spring.schemas not .handlers and .schemas) then you will need to go through every single spring jar in your project and concatenate the contents of each within those 2 files.

plus its not a decent idea, becausewe will have lot of portlets


I agree this is why you should probably use maven.

If your manager will not buy into using maven for your project (save you lots of time and headaches later) then you can look at using maven with the Maven Shade Plugin and try to build your own spring Uber jar (like they used to provide) that contains all of the needed dependencies and let the plugin do the concatenation of those files.

You will have to configure a transformer for concatenating those files something like below:




see also http://maven.apache.org/plugins/maven-shade-plugin/examples/resource-transformers.html
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: BeanDefinitionParsingException : NamespaceHandler