RPC error using GWTHandler for Spring

128 views
Skip to first unread message

dablackgoku

unread,
Sep 19, 2007, 7:30:55 PM9/19/07
to Google Web Toolkit
Hi all,

After upgrade to GWT 1.4.60, my old GWTServiceExporter no longer
works. The ancient code I had is now replaced with a nice jar, GWT-
SL.

After going thru the article, it looked pretty easy to use. Here is
what I've done...

Web.XML
<servlet>
<servlet-name>RPCService</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<load-on-startup>3</load-on-startup>
</servlet>

<servlet-mapping>
<servlet-name>RPCService</servlet-name>
<url-pattern>*.rpc</url-pattern>
</servlet-mapping>

RPCService-servlet.XML
<bean id="urlMapping"
class="org.gwtwidgets.server.spring.GWTHandler"
scope="prototype">
<property name="mapping">
<map>
<entry key="/LeadsDataInterface.rpc"
value-ref="leadsDataInterfaceService" />
</map>
</property>
</bean>

applicationContext.XML
<bean id="leadsDataInterfaceService"
class="com.jumptools.gwt.server.LeadsDataInterfaceImpl"
scope="prototype">
<property name="userSessionBean">
<ref bean="userSessionBean" />
</property>
</bean>

NOTE: that userSessionBean is session scoped. Thus,
leadsDataInterfaceService and urlMapping are prototype scope.

The error I am getting on startup is...

org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'urlMapping' defined in ServletContext
resource [/WEB-INF/RPCService-servlet.xml]: Cannot resolve reference
to bean 'leadsDataInterfaceService' while setting bean property
'mapping' with key [TypedStringValue: value [/LeadsDataInterface.rpc],
target type [null]]; nested exception is
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'leadsDataInterfaceService' defined in
ServletContext resource [/WEB-INF/applicationContext.xml]: Cannot
resolve reference to bean 'userSessionBean' while setting bean
property 'userSessionBean'; nested exception is
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'userSessionBean': Scope 'session' is not
active for the current thread; consider defining a scoped proxy for
this bean if you intend to refer to it from a singleton; nested
exception is java.lang.IllegalStateException: No thread-bound request
found: Are you referring to request attributes outside of an actual
web request? If you are actually operating within a web request and
still receive this message,your code is probably running outside of
DispatcherServlet/DispatcherPortlet: In this case, use
RequestContextListener or RequestContextFilter to expose the current
request.
Caused by:
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'leadsDataInterfaceService' defined in
ServletContext resource [/WEB-INF/applicationContext.xml]: Cannot
resolve reference to bean 'userSessionBean' while setting bean
property 'userSessionBean'; nested exception is
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'userSessionBean': Scope 'session' is not
active for the current thread; consider defining a scoped proxy for
this bean if you intend to refer to it from a singleton; nested
exception is java.lang.IllegalStateException: No thread-bound request
found: Are you referring to request attributes outside of an actual
web request? If you are actually operating within a web request and
still receive this message,your code is probably running outside of
DispatcherServlet/DispatcherPortlet: In this case, use
RequestContextListener or RequestContextFilter to expose the current
request.
Caused by:
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'userSessionBean': Scope 'session' is not
active for the current thread; consider defining a scoped proxy for
this bean if you intend to refer to it from a singleton; nested
exception is java.lang.IllegalStateException: No thread-bound request
found: Are you referring to request attributes outside of an actual
web request? If you are actually operating within a web request and
still receive this message,your code is probably running outside of
DispatcherServlet/DispatcherPortlet: In this case, use
RequestContextListener or RequestContextFilter to expose the current
request.
Caused by:
java.lang.IllegalStateException: No thread-bound request found: Are
you referring to request attributes outside of an actual web request?
If you are actually operating within a web request and still receive
this message,your code is probably running outside of
DispatcherServlet/DispatcherPortlet: In this case, use
RequestContextListener or RequestContextFilter to expose the current
request.
at
org.springframework.web.context.request.RequestContextHolder.currentRequestAttributes(RequestContextHolder.java:
102)
at
org.springframework.web.context.request.SessionScope.get(SessionScope.java:
88)
at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:
288)
at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:
163)

George Georgovassilis

unread,
Sep 20, 2007, 3:25:40 AM9/20/07
to Google Web Toolkit
Scopes define the lifecycle of an object and I think what is going on
here is:

userSessionBean is as you said session scoped, meaning it lives only
in as long as a certain user http session is alive.
leadsDataInterfaceService is a prototype, meaning it will go alive
whenever requested, but all its dependencies have to be instantiated
as well, including userSessionBean.

urlMapping is defined as a prototype, which is bad idea, it should be
a singleton. Among the many reasons for having it defined as a
singleton is that the spring servlet context is scanned immediately
for request resolvers and the like - the GWTHandler is such a resolver
and is immediately instantiated, along with all dependencies:
leadsDataInterfaceService is instantiated and then userSessionBean,
which fails, since it is viable only in a user session context, which
does not exist at startup.

Reply all
Reply to author
Forward
0 new messages