Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Virgo » How to develop Spring Session Scope Beans
How to develop Spring Session Scope Beans [message #768584] Tue, 20 December 2011 07:12 Go to next message
Carlos Salinas is currently offline Carlos Salinas
Messages: 32
Registered: March 2011
Location: Avd. de la Argentina 132,...
Member
Hi community,

I didnt find any tutorial about how to develop Spring Session Scope beans in OSGi. Because the 'normal' way doesnt work.


web.xml

....
 <listener>
    <description>Spring listener</description>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
 <listener>
  <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
  </listener>
....


bundle-context.xml
.....

 <context:annotation-config />

 <bean id="workbench" class="com.thingtrack.konekti.view.workbench.Workbench"
		scope="session" >
		<property name="workbenchWindow" ref="workbenchWindow" />
		<aop:scoped-proxy/>
  </bean>

   <!-- OSGi configuration for the Load Time Weaver -->
	<context:load-time-weaver aspectj-weaving="on" />
	<!-- Enable the aspect annotations and choose CGLIB as Code Generation Library -->
	<aop:aspectj-autoproxy proxy-target-class="true" />

.....




What would i put in the web.xml instead from i putted above? So i could deploy the WAB and not receive the following error:


javax.servlet.ServletException: java.lang.IllegalStateException: No Scope registered for scope 'session'
	com.vaadin.terminal.gwt.server.AbstractApplicationServlet.handleServiceException(AbstractApplicationServlet.java:1004)
	com.vaadin.terminal.gwt.server.AbstractApplicationServlet.service(AbstractApplicationServlet.java:548)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
	org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:83)
	org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)




thanks.
Re: How to develop Spring Session Scope Beans [message #771241 is a reply to message #768584] Mon, 26 December 2011 13:46 Go to previous messageGo to next message
Chris Frost is currently offline Chris Frost
Messages: 230
Registered: January 2010
Location: Southampton, England
Senior Member

Hi,

Have you defined a,

<context-param>
<param-name>contextClass</param-name>
<param-value>org.eclipse.virgo.web.dm.ServerOsgiBundleXmlWebApplicationContext</param-value>
</context-param>


Also, where in you WAB is your bundle-context.xml file placed? I want to make sure it is being found and the 'workbench' bean is actually being created.

Chris


------------------------------------------------
Chris Frost, Twitter @cgfrost
Springsource, a divison of VMware.
Re: How to develop Spring Session Scope Beans [message #771464 is a reply to message #768584] Tue, 27 December 2011 05:29 Go to previous messageGo to next message
Florian Waibel is currently offline Florian Waibel
Messages: 94
Registered: June 2010
Member
Hi,

from the stack trace you provide I see you use Vaadin. We encountered a similar problem when using RAP on Virgo.

There is a sandbox project named "com.codeaffine.mvc.demo.virgo/" at GitHUB /fappel/RWT_SPRING where you can find a working example using session scoped beans.

Florian
Re: How to develop Spring Session Scope Beans [message #776793 is a reply to message #768584] Mon, 09 January 2012 04:30 Go to previous message
Carlos Salinas is currently offline Carlos Salinas
Messages: 32
Registered: March 2011
Location: Avd. de la Argentina 132,...
Member
Hi guys,

I cannot work in this issue until today. Firstly thank to Floridian for your github project. I finally were able to resolve the problem. But in my conclusion if i want to use Scope Session Beans i cannot use Spring DM to create the Application Context for me, so i have to move the spring descriptors to another place different from the spring dir in the META-INF, making them not enable to Spring DM and load them through the web descriptor as follow:



<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
	id="WebApp_ID" version="2.5">
	<display-name>Vaadin Web Application</display-name>

	<context-param>
		<description>Vaadin production mode</description>
		<param-name>productionMode</param-name>
		<param-value>false</param-value>
	</context-param>

	<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/spring/*.xml</param-value>
	</context-param>

	<listener>
		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
	</listener>

	<listener>
		<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
	</listener>

	<servlet>
		<servlet-name>Vaadin Application Servlet</servlet-name>
		<servlet-class>com.vaadin.terminal.gwt.server.SpringApplicationOSGiServlet</servlet-class>
		<init-param>
			<description>Vaadin application class to start</description>
			<param-name>application</param-name>
			<param-value>com.thingtrack.beansession.test.MyVaadinApplication</param-value>
		</init-param>
<!-- 		<init-param> -->
<!-- 			<description>Application widgetset</description> -->
<!-- 			<param-name>widgetset</param-name> -->
<!-- 			<param-value>com.thingtrack.konekti.view.component.gwt.KonektiWidgetSet</param-value> -->
<!-- 		</init-param> -->
		<init-param>
			<description>Spring bean</description>
			<param-name>bean</param-name>
			<param-value>myVaadinApplication</param-value>
		</init-param>
		<init-param>
			<description>Vaadin application bundle version</description>
			<param-name>version</param-name>
			<param-value>0.0.1.SNAPSHOT</param-value>
		</init-param>
	</servlet>

	<servlet-mapping>
		<servlet-name>Vaadin Application Servlet</servlet-name>
		<url-pattern>/*</url-pattern>
	</servlet-mapping>
</web-app>






Previous Topic:Using Virgo Snaps and Spring Interceptors
Next Topic:Questions regarding Regions/Subsystems, p2/OBR
Goto Forum:
  


Current Time: Mon Sep 01 07:29:56 EDT 2014

Powered by FUDForum. Page generated in 0.02059 seconds