<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <title>Using different View resolvers in Spring</title>
  <link rel="self" href="https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=9186981" />
  <subtitle>Using different View resolvers in Spring</subtitle>
  <id>https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=9186981</id>
  <updated>2026-06-11T16:23:28Z</updated>
  <dc:date>2026-06-11T16:23:28Z</dc:date>
  <entry>
    <title>RE: Using different View resolvers in Spring</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=9211421" />
    <author>
      <name>David H Nebinger</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=9211421</id>
    <updated>2011-06-07T14:46:52Z</updated>
    <published>2011-06-07T14:46:52Z</published>
    <summary type="html">&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;&lt;div class="quote-title"&gt;SZ khan:&lt;/div&gt;&lt;blockquote&gt;&lt;pre&gt;&lt;code&gt;&amp;lt;bean id="viewResolver" class="org.springframework.web.servlet.view.ResourceBundleViewResolver"&amp;gt;
	 &amp;lt;property name="basename" value="views" /&amp;gt;  
	  &amp;lt;property name="order" value="1" /&amp;gt;  
	 &amp;lt;/bean&amp;gt;&lt;/code&gt;&lt;/pre&gt;&lt;br&gt;&lt;br&gt;It gives the following error&lt;br&gt;&lt;br&gt;&lt;em&gt; 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!&lt;/em&gt;&lt;br&gt;&lt;/blockquote&gt;&lt;br&gt;&lt;br&gt;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.&lt;br&gt;&lt;br&gt;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.&lt;/body&gt;&lt;/html&gt;</summary>
    <dc:creator>David H Nebinger</dc:creator>
    <dc:date>2011-06-07T14:46:52Z</dc:date>
  </entry>
  <entry>
    <title>Using different View resolvers in Spring</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=9186980" />
    <author>
      <name>SZ khan</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=9186980</id>
    <updated>2011-06-06T18:58:59Z</updated>
    <published>2011-06-06T18:58:59Z</published>
    <summary type="html">&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;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. &lt;br&gt;&lt;br&gt;For e.g. if I use this in my *-portlet.xml &lt;br&gt;&lt;br&gt;&lt;pre&gt;&lt;code&gt;&amp;lt;bean id="viewResolver" class="org.springframework.web.servlet.view.ResourceBundleViewResolver"&amp;gt;
	 &amp;lt;property name="basename" value="views" /&amp;gt;  
	  &amp;lt;property name="order" value="1" /&amp;gt;  
	 &amp;lt;/bean&amp;gt;&lt;/code&gt;&lt;/pre&gt;&lt;br&gt;&lt;br&gt;It gives the following error&lt;br&gt;&lt;br&gt;&lt;em&gt; 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!&lt;/em&gt;&lt;br&gt;&lt;br&gt;If I add the following in my web.xml&lt;br&gt;&lt;br&gt;&lt;pre&gt;&lt;code&gt;&amp;lt;context-param&amp;gt;
               &amp;lt;param-name&amp;gt;contextConfigLocation&amp;lt;/param-name&amp;gt;
               &amp;lt;param-value&amp;gt;/WEB-INF/context-test/*-portlet.xml&amp;lt;/param-value&amp;gt;
       &amp;lt;/context-param&amp;gt;
       &amp;lt;listener&amp;gt;
               &amp;lt;listener-class&amp;gt;org.springframework.web.context.ContextLoaderListener&amp;lt;/listener-class&amp;gt;
       &amp;lt;/listener&amp;gt;&lt;/code&gt;&lt;/pre&gt;&lt;br&gt;&lt;br&gt;then I get the following error.&lt;br&gt;&lt;br&gt;&lt;em&gt;Cannot initialize context because there is already a root application context present - check whether you have multiple ContextLoader* definitions in your web.xml!&lt;/em&gt;&lt;br&gt;I am using Service Builder in my portlet.&lt;br&gt;&lt;br&gt;Any ideas?...&lt;br&gt;Thanks&lt;/body&gt;&lt;/html&gt;</summary>
    <dc:creator>SZ khan</dc:creator>
    <dc:date>2011-06-06T18:58:59Z</dc:date>
  </entry>
</feed>
