Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Virgo » Getting NullPointerException when forwarding to a JSP in a snap bundle
Getting NullPointerException when forwarding to a JSP in a snap bundle [message #652048] Wed, 02 February 2011 14:10 Go to next message
Sven Panko is currently offline Sven PankoFriend
Messages: 13
Registered: February 2011
Location: Germany
Junior Member
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 #652052 is a reply to message #652048] Wed, 02 February 2011 14:20 Go to previous messageGo to next message
Glyn Normington is currently offline Glyn NormingtonFriend
Messages: 1222
Registered: July 2009
Senior Member
A NullPointerException in Virgo code is almost always a bug, so please would you raise a bugzilla to capture this.
Re: Getting NullPointerException when forwarding to a JSP in a snap bundle [message #652063 is a reply to message #652052] Wed, 02 February 2011 14:57 Go to previous messageGo to next message
Sven Panko is currently offline Sven PankoFriend
Messages: 13
Registered: February 2011
Location: Germany
Junior Member
Hello Glyn,

thanks for the quick reply. I just filed a bug report for this: https://bugs.eclipse.org/bugs/show_bug.cgi?id=336072

I also saw that my Snaps build was from September, not November and I also mentioned the fact that this happens when an ExceptionResolver kicked in (the JSP I want to display is an error page). I haven't tried it in a "regular" non-error scenario since I don't have to display anything in this case (I will only perform redirects to other services then).

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 Go to previous messageGo to next message
Chris Frost is currently offline Chris FrostFriend
Messages: 230
Registered: January 2010
Location: Southampton, England
Senior Member

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.
Re: Getting NullPointerException when forwarding to a JSP in a snap bundle [message #652825 is a reply to message #652068] Mon, 07 February 2011 08:46 Go to previous message
Sven Panko is currently offline Sven PankoFriend
Messages: 13
Registered: February 2011
Location: Germany
Junior Member
Hi Chris,

sorry for the delay; I added the information you requested to the Bugzilla issue.

- Sven
Previous Topic:Bundle-ClassPath header not recognized by tool
Next Topic:Virgo (Spring DM Server) Clustering
Goto Forum:
  


Current Time: Mon Dec 22 13:46:03 GMT 2014

Powered by FUDForum. Page generated in 0.01638 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software