Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Virgo » virgo 2.1, snaps and tiles 2
virgo 2.1, snaps and tiles 2 [message #665044] Wed, 13 April 2011 03:25 Go to next message
Jan Fetyko is currently offline Jan FetykoFriend
Messages: 28
Registered: April 2011
Junior Member
I have snaps installed into virgo 2.1 and have a web root and a snap. Both of them use tiles 2. The problem is that the tiles in root work fine as long as the snap is not deployed. Once I deploy the snap, the tiles somehow looses the tiles container. I get this error:

Tiles container is not initialized. Have you added a TilesConfigurer to your web application context?

Tiles are being configured together with spring 3.0.5.

Is there anything in virgo that would cause this ?
Does anybody has experience doing this and getting it working ?

Please advice.

Thank you.

Jan

[Updated on: Wed, 13 April 2011 03:27]

Report message to a moderator

Re: virgo 2.1, snaps and tiles 2 [message #665116 is a reply to message #665044] Wed, 13 April 2011 10:49 Go to previous messageGo to next message
Dmitry Sklyut is currently offline Dmitry SklyutFriend
Messages: 279
Registered: January 2010
Senior Member
Can you post your web.xml for the snap?
Re: virgo 2.1, snaps and tiles 2 [message #665214 is a reply to message #665116] Wed, 13 April 2011 17:34 Go to previous messageGo to next message
Jan Fetyko is currently offline Jan FetykoFriend
Messages: 28
Registered: April 2011
Junior Member
Dmitry,

here is for snap:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

	<!-- The definition of the Root Spring Container shared by all Servlets 
		and Filters -->
	<!--
	<context-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/spring/context.xml 
		/WEB-INF/spring/osgi-context.xml</param-value> </context-param>
		--> 
	<context-param>
		<param-name>contextClass</param-name>
		<param-value>org.eclipse.virgo.web.dm.ServerOsgiBundleXmlWebApplicationContext</param-value>
	</context-param>

	<!-- Processes application requests -->
	<servlet>
		<servlet-name>helloServlet</servlet-name>
		<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
		<init-param>
			<param-name>contextConfigLocation</param-name>
			<param-value>/WEB-INF/spring/appServlet/servlet-context.xml /WEB-INF/spring/context.xml /WEB-INF/spring/osgi-context.xml</param-value>
		</init-param>
		<init-param>
			<param-name>contextClass</param-name>
			<param-value>org.eclipse.virgo.web.dm.ServerOsgiBundleXmlWebApplicationContext</param-value>
		</init-param>
		<load-on-startup>1</load-on-startup>
	</servlet>
	<servlet-mapping>
		<servlet-name>helloServlet</servlet-name>
		<url-pattern>/</url-pattern>
	</servlet-mapping>
</web-app>


Do you perhaps also need to see the tiles definition or the web.xml from the root ?

One note: as you can see on top I had to move the spring configs from the context params to the servlet, for some reason it was not loaded before the DispatcherServlet, so the spring wiring was failing.

Thank you for looking into this.

Jan
Re: virgo 2.1, snaps and tiles 2 [message #665216 is a reply to message #665214] Wed, 13 April 2011 17:40 Go to previous messageGo to next message
Dmitry Sklyut is currently offline Dmitry SklyutFriend
Messages: 279
Registered: January 2010
Senior Member
Seeing the config would help.
If you could also explain your use case and the expected behavior - that will help a lot to debug the snap.
A simplified example would be very handy also - so I can just debug through it.

As for the root.webapp config - snap binds to the root web-app. So they share Servlet Context. That is the reason why you would need to scope bean definitions to the servlet in the snap.

Regards,
Dmitry
Re: virgo 2.1, snaps and tiles 2 [message #665234 is a reply to message #665216] Wed, 13 April 2011 19:51 Go to previous messageGo to next message
Jan Fetyko is currently offline Jan FetykoFriend
Messages: 28
Registered: April 2011
Junior Member
Dmitry,

I discovered that the Tiles container vanishes only if I redeploy the snap, which is annoying but perhaps less severe. Before I create a simplified example which will take me little bit of time, I decided to post some other configurations:

web.xml from root
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
	xmlns:c="http://java.sun.com/jsp/jstl/core">

	<!-- The definition of the Root Spring Container shared by all Servlets and Filters -->
	<context-param>
		<param-name>contextConfigLocation</param-name>
		<param-value>/WEB-INF/spring/root-context.xml /WEB-INF/spring/root-osgi-context.xml</param-value>
	</context-param>
	
	<context-param>
		<param-name>contextClass</param-name>
		<param-value>org.eclipse.virgo.web.dm.ServerOsgiBundleXmlWebApplicationContext</param-value>
	</context-param>

	<!-- Creates the Spring Container shared by all Servlets and Filters -->
	<listener>
		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
	</listener>

	<!--  SPANS HOST FILTER -->
	<filter>
    	<filter-name>host-filter</filter-name>
    	<filter-class>org.eclipse.virgo.snaps.core.SnapHostFilter</filter-class>    	
    </filter>
    <filter-mapping>
        <filter-name>host-filter</filter-name>
        <url-pattern>/*</url-pattern>        
    </filter-mapping>
	
	<!-- Processes application requests -->
	<servlet>
		<servlet-name>appServlet</servlet-name>
		<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
		<init-param>
			<param-name>contextConfigLocation</param-name>
			<param-value>/WEB-INF/spring/appServlet/servlet-context.xml</param-value>
		</init-param>
		<init-param>
			<param-name>contextClass</param-name>
			<param-value>org.eclipse.virgo.web.dm.ServerOsgiBundleXmlWebApplicationContext</param-value>
		</init-param>
		<load-on-startup>1</load-on-startup>
	</servlet>
	<servlet-mapping>
		<servlet-name>appServlet</servlet-name>
		<url-pattern>/</url-pattern>
	</servlet-mapping>

	<!-- Disables Servlet Container welcome file handling. Needed for compatibility with Servlet 3.0 and Tomcat 7.0 -->
	<welcome-file-list>
		<welcome-file></welcome-file>
	</welcome-file-list>
</web-app>



servlet context xml for root
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc"
	xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">

	<!-- DispatcherServlet Context: defines this servlet's request-processing infrastructure -->

	<!-- Enables the Spring MVC @Controller programming model -->
	<mvc:annotation-driven conversion-service="conversionService" />
	
	<!-- TODO - will restore namespace tag once its been brought up to date - using full bean definitions for now -->
 	<bean class="org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter" />

	<bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
		<property name="mappings">
            <props>
                <prop key="/resources/**">resourceHandler</prop>
                <prop key="/*">fileNameViewController</prop>
            </props>
        </property>
	</bean>

	<bean id="resourceHandler" class="org.springframework.web.servlet.resource.ResourceHttpRequestHandler">
		<property name="locations">
			<list>
				<value>/resources/*</value>
			</list>
		</property>
	</bean>
 
	<!-- END TODO -->

	<!-- imports user-defined @Controller beans that process client requests -->
	<import resource="controllers.xml" />

	<!-- Only needed because we install custom converters to support the examples in the org.springframewok.samples.mvc.convert package -->
	<bean id="conversionService" class="com.dummy.convert.CustomConversionServiceFactoryBean" />

	<!-- bootstrap the JSR 303 bean validators -->
	<bean id="validator" class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean" />

	<!--  a reloadable message source that should contain all text messages, labels, and errors -->
	<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
		<property name="basenames">
			<list>
				<value>/WEB-INF/i18n/messages</value>
				<value>/WEB-INF/i18n/formMessages</value>
				<value>/WEB-INF/i18n/validationMessages</value>
			</list>
		</property>
		<property name="useCodeAsDefaultMessage" value="true" />
	</bean>

	<!-- setup the Tiles configurer  -->
	<bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">
		<property name="definitions">
			<list>
				<value>/WEB-INF/tiles-defs/tiles-defs.xml</value>
				<value>/WEB-INF/tiles-defs/security-defs.xml</value>
			</list>
		</property>
	</bean>

	<!-- setup the view resolver for Tiles and all AJAX based requests -->
	<bean id="tilesViewResolver" class="org.springframework.js.ajax.AjaxUrlBasedViewResolver">
		<property name="viewClass" value="com.cme.star.mvc.js.ajax.tiles2.AjaxTilesView"/>
		<property name="prefix" value="/WEB-INF/views/"/>
        <property name="suffix" value=".jsp"/>
	</bean>

	<!-- a simple controller that handles all url's simplifying their names  (e.g. "/home.htm" => "home", "/user/list.htm" => "user/list", etc.) -->
	<bean id="fileNameViewController" class="org.springframework.web.servlet.mvc.UrlFilenameViewController"/>

</beans>


the servlet context xml for the snap is the same, just has different tiles definitions.

Notes:
* It is strange to me that when I see the logs or exceptions in the snap, I don't see a stack trace that includes the spring dispatcher servlet. For example I receive this error when trying to access a controller in the snap:
java.io.FileNotFoundException: C:\virgo\web\work\osgi\configuration\org.eclipse.osgi\bundles\36\data\store\org.eclipse.osgi\bundles\99\2\bundlefile\ (The system cannot find the path specified)
	java.io.FileInputStream.open(Native Method)
	java.io.FileInputStream.<init>(FileInputStream.java:106)
	org.eclipse.osgi.framework.util.SecureAction.getFileInputStream(SecureAction.java:123)
	org.eclipse.osgi.baseadaptor.bundlefile.FileBundleEntry.getInputStream(FileBundleEntry.java:56)
	org.eclipse.osgi.framework.internal.core.BundleURLConnection.connect(BundleURLConnection.java:53)
	org.eclipse.osgi.framework.internal.core.BundleURLConnection.getInputStream(BundleURLConnection.java:99)
	java.net.URL.openStream(URL.java:1010)
	org.eclipse.virgo.snaps.core.internal.webapp.StaticResourceServlet.doGet(StaticResourceServlet.java:62)
	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)

BTW the above path does exists, so I'm not sure what is the problem, but as you can see, the Dispatcher servlet is not in the path, so how does this work ?

* Another behavior I experienced is that static content is available in the snap, so a text file for example is displayed just fine.
* Looks like now the problem evolved into tiles not working correctly in the snap which upon redeploy breaking the root's tiles.

I know I dumped a lot of info here, so I'm going to stop now and see if there is any advice you can give me.

In the mean time, I continue digging.

Thank you.

Jan
Re: virgo 2.1, snaps and tiles 2 [message #665774 is a reply to message #665234] Fri, 15 April 2011 20:35 Go to previous messageGo to next message
Jan Fetyko is currently offline Jan FetykoFriend
Messages: 28
Registered: April 2011
Junior Member
Hello,

I spent considerable time on this issue. It boils down to the problem, that when the snap is redeployed, the root loses the tiles container from the servlet context somehow. I cannot find where or how this can be corrected.

Is there something in snaps that is doing something with the servlet context when a snap is deployed ? Can I get hold of it from the root somehow ?

Thank you.

Jan
Re: virgo 2.1, snaps and tiles 2 [message #669545 is a reply to message #665774] Tue, 10 May 2011 16:58 Go to previous message
Jan Fetyko is currently offline Jan FetykoFriend
Messages: 28
Registered: April 2011
Junior Member
It has been a while since I posted to this topic, but I wanted to provide a short description of our solution.

To get the snap + host working upon redeployment, we had to extend "org.springframework.web.servlet.view.tiles2.TilesConfigurer " and override the "destroy()" method to prevent the tiles definitions being removed.

It works, it is not perfect solution perhaps, but right now we're not seeing any drawbacks, not yet at least.

public class TilesConfigurer extends org.springframework.web.servlet.view.tiles2.TilesConfigurer {

  @Override
  public void destroy() throws TilesException {
    // super.destroy();
    logger.info("skipping the destroy of tiles on redeployment of a child snap");
  }
}


used like this

  <bean id="tilesConfigurer" class="TilesConfigurer">
    <property name="definitions">
      <list>
        <!-- add your local tiles defs files here -->
        <value>/WEB-INF/tiles-defs/host-defs.xml</value>
      </list>
    </property>
  </bean>
Previous Topic:EBR is getting woefully out of date
Next Topic:Expanding Environment Variables For Watch Folders
Goto Forum:
  


Current Time: Mon Dec 09 07:35:28 GMT 2024

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

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

Back to the top