Hi Stephen,

In my understanding of spring MVC, view resolvers should be put in the main
application context xml rather than on springs portlet context xml (not
authority-portlet.xml in your case). The view resolver functions using
normal servlet dispatching mechanism and should be common to all portlets
and servlets in the webapp.

Solution: move the "velocityConfig" and "viewResolver" definitions to
"applicationContext.xml".

Regards,
Ruwan

----- Original Message ----- 
From: "Stephen Hitchner" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Friday, July 07, 2006 12:20 AM
Subject: Spring/Velocity Configuration Problems


> I seem to be having problems getting velocity and spring portlets working
> together.  I was wondering if by someone on this forum would inspect my
> configuration.  I tried the Spring forumk and no one could offer any
advice.
>
> All my vm files exist in the /WEB-INF/view directory.  Here are some of
the
> errors I'm getting and some sample config files
>
> Failed to load portlet org.springframework.web.portlet.DispatcherPortlet:
> org.springframework.beans.factory.BeanCreationException: Error creating
bean
> with name 'viewResolver' defined in PortletContext resource
> [/WEB-INF/authority-portlet.xml]: Initialization of bean failed; nested
> exception is java.lang.IllegalStateException: Cannot satisfy
> ServletContextAware for bean 'viewResolver' without ServletContext
>
>
> ERROR [org.springframework.web.portlet.DispatcherPortlet] - Context
> initialization failed
> org.springframework.beans.factory.BeanCreationException: Error creating
bean
> with name 'viewResolver' defined in PortletContext resource
> [/WEB-INF/authority-portlet.xml]: Initialization of bean failed; nested
> exception is java.lang.IllegalStateException: Cannot satisfy
> ServletContextAware for bean 'viewResolver' without ServletContext
> Caused by:
> java.lang.IllegalStateException: Cannot satisfy ServletContextAware for
bean
> 'viewResolver' without ServletContext
>         at
>
org.springframework.web.context.support.ServletContextAwareProcessor.postPro
cessBeforeInitialization
> (ServletContextAwareProcessor.java:80)
>         at
>
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory
.applyBeanPostProcessorsBeforeInitialization
> (AbstractAutowireCapableBeanFactory.java:267)
>         at
>
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory
.initializeBean
> (AbstractAutowireCapableBeanFactory.java:867)
>         at
>
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory
.createBean
> (AbstractAutowireCapableBeanFactory.java:393)
>         at
> org.springframework.beans.factory.support.AbstractBeanFactory.getBean(
> AbstractBeanFactory.java:256)
>         at
> org.springframework.beans.factory.support.AbstractBeanFactory.getBean(
> AbstractBeanFactory.java:167)
>         at
>
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInst
antiateSingletons
> (DefaultListableBeanFactory.java:253)
>         at
> org.springframework.context.support.AbstractApplicationContext.refresh(
> AbstractApplicationContext.java:332)
>         at
>
org.springframework.web.portlet.context.AbstractRefreshablePortletApplicatio
nContext.refresh
> (AbstractRefreshablePortletApplicationContext.java:162)
>
>
>
>
>     <bean id="velocityConfig" class="
> org.springframework.web.servlet.view.velocity.VelocityConfigurer">
>         <property name="resourceLoaderPath">
>             <value>/</value>
>         </property>
>     </bean>
>
>     <bean id="viewResolver" class="
> org.springframework.web.servlet.view.velocity.VelocityViewResolver">
>         <property name="prefix"><value>/WEB-INF/view/</value></property>
>         <property name="suffix"><value>.html</value></property>
>         <property
> name="exposeSpringMacroHelpers"><value>true</value></property>
>     </bean>
>
>
>
>
> <web-app>
>     <display-name>Tools</display-name>
>     <context-param>
>         <param-name>webAppRootKey</param-name>
>         <param-value>com.tools</param-value>
>     </context-param>
>     <context-param>
>         <param-name>log4jConfigLocation</param-name>
>         <param-value>/WEB-INF/classes/log4j.properties</param-value>
>     </context-param>
>     <listener>
>         <listener-class>org.springframework.web.util.WebAppRootListener
> </listener-class>
>     </listener>
>     <listener>
>         <listener-class>org.springframework.web.util.Log4jConfigListener
> </listener-class>
>     </listener>
>       <!--  Start of Portlet Configuration -->
>       <servlet>
>         <servlet-name>ViewRendererServlet</servlet-name>
>         <servlet-class>org.springframework.web.servlet.ViewRendererServlet
> </servlet-class>
>         <load-on-startup>1</load-on-startup>
>     </servlet>
>     <servlet-mapping>
>         <servlet-name>ViewRendererServlet</servlet-name>
>         <url-pattern>/WEB-INF/servlet/view</url-pattern>
>     </servlet-mapping>
> </web-app>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to