Planned maintenance is scheduled for the week of June 15th - the exact date and time will be announced soon.
See More Details
Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
Using different View resolvers in Spring
I have a question. I am using Spring Portlet MVC and it works with InternalResourceViewResolver and BeanNameViewResolver but doesn't work with ResourceBundleViewResolver and XmlViewResolver in a Spring MVC Portlet.
For e.g. if I use this in my *-portlet.xml
It gives the following error
java.lang.IllegalStateException: WebApplicationObjectSupport instance [org.springframework.web.servlet.view.ResourceBundleViewResolver@1164deb] does not run within a ServletContext. Make sure the object is fully configured!
If I add the following in my web.xml
then I get the following error.
Cannot initialize context because there is already a root application context present - check whether you have multiple ContextLoader* definitions in your web.xml!
I am using Service Builder in my portlet.
Any ideas?...
Thanks
For e.g. if I use this in my *-portlet.xml
<bean id="viewResolver" class="org.springframework.web.servlet.view.ResourceBundleViewResolver">
<property name="basename" value="views" />
<property name="order" value="1" />
</bean>It gives the following error
java.lang.IllegalStateException: WebApplicationObjectSupport instance [org.springframework.web.servlet.view.ResourceBundleViewResolver@1164deb] does not run within a ServletContext. Make sure the object is fully configured!
If I add the following in my web.xml
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/context-test/*-portlet.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>then I get the following error.
Cannot initialize context because there is already a root application context present - check whether you have multiple ContextLoader* definitions in your web.xml!
I am using Service Builder in my portlet.
Any ideas?...
Thanks
SZ khan:
<bean id="viewResolver" class="org.springframework.web.servlet.view.ResourceBundleViewResolver"> <property name="basename" value="views" /> <property name="order" value="1" /> </bean>
It gives the following error
java.lang.IllegalStateException: WebApplicationObjectSupport instance [org.springframework.web.servlet.view.ResourceBundleViewResolver@1164deb] does not run within a ServletContext. Make sure the object is fully configured!
The error is accurate. You're trying to use a servlet (see the package for the ResourceBundleViewResolver?) within the scope of a portlet. In a portlet there is no ServletContext, there is a PortletContext.
The good news is that you can override the ResourceBundleViewResolver to make it PortletContext-capable. Most of the time when the ServletContext is being referenced, you can replace that with PortletContext, but without digging into the code I really can't tell you how much work you're going to be doing to adapt it correctly.
Community
Company
Feedback