Getting NullPointerException when forwarding to a JSP in a snap bundle [message #652048] |
Wed, 02 February 2011 14:10 |
|
Hi all,
I am using Snaps (self-built ca. 2010-11-01) on Virgo 2.1.0.RELEASE and everything works happily except for resolving a JSP view from a snaps-bundle. In my case I have created a JSP file in the WEB-INF/views-directory of my snap bundle. Then I created the following Spring config in this bundle:
<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/views/"/>
<property name="suffix" value=".jsp"/>
</bean>
The web.xml of this bundle looks like this:
<servlet>
<servlet-name>callback-controller</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/context/controller-servlet.xml
</param-value>
</init-param>
<init-param>
<param-name>contextClass</param-name>
<param-value>org.eclipse.virgo.web.dm.ServerOsgiBundleXmlWebApplicationContext</param-value>
</init-param>
<init-param>
<param-name>detectAllHandlerExceptionResolvers</param-name>
<param-value>false</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>callback-controller</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>jsp</servlet-name>
<url-pattern>/WEB-INF/views/*</url-pattern>
</servlet-mapping>
My host bundle's web.xml looks like this:
<filter>
<filter-name>host-filter</filter-name>
<filter-class>org.eclipse.virgo.snaps.core.SnapHostFilter</filter-class>
</filter>
<context-param>
<param-name>contextClass</param-name>
<param-value>org.eclipse.virgo.web.dm.ServerOsgiBundleXmlWebApplicationContext</param-value>
</context-param>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/context/global-context.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<filter-mapping>
<filter-name>host-filter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
<dispatcher>INCLUDE</dispatcher>
</filter-mapping>
I can happily interact with all my controllers in the snaps bundle, but when one of them returns a ModelAndView which should be resolved to a JSP inside the snaps bundle, I get the following exception:
java.lang.NullPointerException
org.eclipse.virgo.snaps.core.internal.webapp.container.ServletManager.findMatch(ServletManager.java:95)
org.eclipse.virgo.snaps.core.internal.webapp.container.StandardVirtualContainerRequestDispatcher.service(StandardVirtualContainerRequestDispatcher.java:89)
org.eclipse.virgo.snaps.core.internal.webapp.WebAppSnap.handleRequest(WebAppSnap.java:153)
org.eclipse.virgo.snaps.core.RequestRouter.service(RequestRouter.java:51)
org.eclipse.virgo.snaps.core.SnapHostFilter.doFilter(SnapHostFilter.java:62)
org.eclipse.virgo.snaps.core.RequestRouter.forward(RequestRouter.java:60)
org.eclipse.virgo.snaps.core.internal.webapp.container.SnapHttpServletRequest$1.forward(SnapHttpServletRequest.java:92)
org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:239)
org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:250)
org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1060)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:798)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:716)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:647)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:552)
javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.eclipse.virgo.snaps.core.internal.webapp.container.ImmutableFilterChain.doFilter(ImmutableFilterChain.java:47)
org.eclipse.virgo.snaps.core.internal.webapp.container.StandardVirtualContainerRequestDispatcher$1.doWithClassLoader(StandardVirtualContainerRequestDispatcher.java:104)
org.eclipse.virgo.snaps.core.internal.webapp.container.StandardVirtualContainerRequestDispatcher$1.doWithClassLoader(StandardVirtualContainerRequestDispatcher.java:1)
org.eclipse.virgo.snaps.core.internal.webapp.container.StandardVirtualContainerRequestDispatcher.doWithThreadContextClassLoader(StandardVirtualContainerRequestDispatcher.java:121)
org.eclipse.virgo.snaps.core.internal.webapp.container.StandardVirtualContainerRequestDispatcher.service(StandardVirtualContainerRequestDispatcher.java:101)
org.eclipse.virgo.snaps.core.internal.webapp.WebAppSnap.handleRequest(WebAppSnap.java:153)
org.eclipse.virgo.snaps.core.RequestRouter.service(RequestRouter.java:51)
org.eclipse.virgo.snaps.core.SnapHostFilter.doFilter(SnapHostFilter.java:62)
Is this a bug in the snaps implementation or did I do something wrong with my configuration? I tried building from trunk today but it won't work on my Virgo - I guess it requires 2.2.0M01 which I don't use atm.
Thanks and regards
Sven
|
|
|
|
|
Re: Getting NullPointerException when forwarding to a JSP in a snap bundle [message #652068 is a reply to message #652063] |
Wed, 02 February 2011 15:06 |
|
Hi,
Thank you for raising the bug, I've had a quick look over the configuration and it looks OK so I also suspect a bug. It might be worth playing with the dispatchers in the filter mapping but I'd need to look in to it further to find out what is happening. Just so we know when we come to look at the bug could you also tell us know the values of the Snap-Host and Snap-ContextPath headers in the snap manifest.
Thanks, Chris.
------------------------------------------------
Chris Frost, Twitter @cgfrost
Springsource, a divison of VMware.
|
|
|
|
Powered by
FUDForum. Page generated in 0.03162 seconds