-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4292637
By: sousa1981
IN Spring:
<bean id="userDetail" class="com.bci.bcioe.beans.UserDetail" scope="session"> </bean> IN Web.xml:
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<listener>
<listener-class>
org.springframework.web.context.request.RequestContextListener
</listener-class>
</listener>
IN my Java Class:
UserDetail userDetail = (UserDetail)SpringUtil.getBean("userDetail");
PROBLEM:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userDetail': 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.currentRequestA
ttributes(RequestContextHolder.java:102)
at org.springframework.web.context.request.SessionScope.get(SessionScope.java:8
8)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(Abstra
ctBeanFactory.java:288)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(Abstra
ctBeanFactory.java:163)
at org.springframework.context.support.AbstractApplicationContext.getBean(Abstr
actApplicationContext.java:683)
at org.zkoss.zkplus.spring.SpringUtil.getBean(SpringUtil.java:56)
at com.bci.bcioe.ui.Login.onLogin(Login.java:31)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39
)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at bsh.Reflect.invokeMethod(Unknown Source)
at bsh.Reflect.invokeObjectMethod(Unknown Source)
at bsh.Name.invokeMethod(Unknown Source)
at bsh.BSHMethodInvocation.eval(Unknown Source)
at bsh.BSHPrimaryExpression.eval(Unknown Source)
at bsh.BSHPrimaryExpression.eval(Unknown Source)
at bsh.Interpreter.eval(Unknown Source)
at bsh.Interpreter.eval(Unknown Source)
at org.zkoss.zk.scripting.bsh.BSHInterpreter.exec(BSHInterpreter.java:80)
at org.zkoss.zk.scripting.util.GenericInterpreter.interpret(GenericInterpreter.
java:205)
at org.zkoss.zk.ui.impl.PageImpl.interpret(PageImpl.java:696)
at org.zkoss.zk.ui.impl.EventProcessingThreadImpl.process1(EventProcessingThrea
dImpl.java:512)
at org.zkoss.zk.ui.impl.EventProcessingThreadImpl.process0(EventProcessingThrea
dImpl.java:492)
at org.zkoss.zk.ui.impl.EventProcessingThreadImpl.run(EventProcessingThreadImpl
.java:395)
Any help please?
Regards,
Marcos de Sousa
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4295136
By: sousa1981
No help? No answers?
Regards,
Marcos de Sousa
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4295356
By: zanyking
Can you post more detailed JAVA code?
And how you call it in zscript? thanks.
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4295435
By: sousa1981
ZUL FILE:
<window id="loginWnd" width="99%" onOK="loginWnd.onLogin()"
use="com.ui.Login">
<label value="Username:" />
<textbox id="txtUsername" />
<label value="Password:" />
<textbox id="txtPassword" />
<button label="Entrar" onClick="loginWnd.onLogin()" />
</window>
-----------------------------------------------------------------
SPRING:
<bean id="userDetail" class="com.beans.UserDetail" scope="session"> </bean>
-----------------------------------------------------------------
WEB.XML:
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<listener>
<listener-class>
org.springframework.web.context.request.RequestContextListener
</listener-class>
</listener>
-----------------------------------------------------------------
LOGIN.JAVA
package com.ui;
public class Login extends Window {
public void onLogin() {
log.info(this.getClass() + ".onLogin");
try {
UserDetail userDetail = (UserDetail)SpringUtil.getBean("userDetail");
} catch (Exception e) {
}
}
}
-----------------------------------------------------------------
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4295787
By: jumperchen
Did you use the <aop:scoped-proxy/> definition?
If you didn't you can read the tutorial with - http://static.springframework.org/spring/docs/2.0.x/reference/beans.html#beans-f
actory-scopes-other-web-configuration
Hope that this can help you.
Regards,
Jumper.
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4296336
By: sousa1981
No.
I will read the url or more about SPRING IoC.
Regards,
Marcos de Sousa
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4296389
By: sousa1981
NO SUCCESS.
Would you please provide an example like:
> One Simple Bean with spring configuration and scope = "sesssion"
> An complete web.xml configuration
> etc
I try
<filter>
<filter-name>requestContextFilter</filter-name>
<filter-class>org.springframework.web.filter.RequestContextFilter</filter-cl
ass>
</filter>
<filter-mapping>
<filter-name>requestContextFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
I try many things, but with no success.
I have used Spring session with JSF without any problem but with ZK there is problem, I thing is my problem with spring and NOT ZK.
Regards,
Marcos de Sousa
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4296649
By: jumperchen
Hi Marcos,
I found out the problem, which you define the scope with session(or other scope), and then use the code with SpringUtil.getBean("userDetail"); in the ZK Event Listener.
I survey the Spring source code detail and then find out the problem occurring when the RequestContextHolder.currentRequestAttributes() invokes RequestContextHolder. getRequestAttributes(), and then get a object of RequestAttributes. RequestAttributes always returns null when the code is invoked in ZK Event listener.
That seems an error in ThreadLocal object.
So,please post it to bug-list with your example code.
Thanks a lot,
Jumper
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=4296798
By: sousa1981
Submited to BUG-LIST with REQUEST ID: 1713353
Since ZK 2.2.1 I have been tried to use spring scope="session" with NO SUCCESS, my solution was using the pure SESSION to hold sessions beans.
One note is if same bean with scope="session" on pure LISTENER or FILTER I have no problem with spring, so in ZK with SpringUtils there is problem.
Regards,
Marcos de Sousa
Asked: 2007-05-03 08:16:52 +0800
Seen: 424 times
Last updated: May 05 '07