roninken
Mar 3rd, 2008, 03:21 PM
Hi
I am developing a J2EE application with Spring MVC, ZK, and ACEGI, and I have next problem:
I need inject a Session bean (new Spring Scope) in other bean that is not session, (maybe singleton), the applicationContext.xml source is:
<bean id="testBean" class="scope.TestBean" scope="session">
<aop:scoped-proxy/>
</bean>
<bean id="testBean2" class="scope.TestBean2">
<property name="testBean" ref="testBean"/>
</bean>
I set the web.xml file and i put the correspondig listener:
<listener>
<listener-class>
org.springframework.web.context.request.RequestCon textListener
</listener-class>
</listener>
The previous code i think is ok, even, the tomcat server running well, but, when I create the bean Instance whit zk Event:
private ITestBean2 testBean2 = (ITestBean2) SpringUtil.getBean("testBean2");
private ITestBean testBean = testBean2.getTestBean();
public void TestBean()
{
testBean2.setId(1);
testBean.setId(1);
System.out.println("["+testBean2.getClass().getName()+"] Id: "+testBean2.getId());
System.out.println("["+testBean.getClass().getName()+"] Id: "+testBean.getId());
}
the application shows the next error:
3/03/2008 04:16:09 PM org.zkoss.zk.ui.impl.UiEngineImpl handleError:764
GRAVE: >>org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'scopedTarget.testBean': 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.
>>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.RequestCon textHolder.currentRequestAttributes(RequestContext Holder.java:102)
>> at org.springframework.web.context.request.SessionSco pe.get(SessionScope.java:88)
>> at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:285)
>> at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:160)
>> at org.springframework.aop.target.SimpleBeanTargetSou rce.getTarget(SimpleBeanTargetSource.java:33)
>>...
What happen?
Ahh, my english is wrong, excuse me plase.
I am developing a J2EE application with Spring MVC, ZK, and ACEGI, and I have next problem:
I need inject a Session bean (new Spring Scope) in other bean that is not session, (maybe singleton), the applicationContext.xml source is:
<bean id="testBean" class="scope.TestBean" scope="session">
<aop:scoped-proxy/>
</bean>
<bean id="testBean2" class="scope.TestBean2">
<property name="testBean" ref="testBean"/>
</bean>
I set the web.xml file and i put the correspondig listener:
<listener>
<listener-class>
org.springframework.web.context.request.RequestCon textListener
</listener-class>
</listener>
The previous code i think is ok, even, the tomcat server running well, but, when I create the bean Instance whit zk Event:
private ITestBean2 testBean2 = (ITestBean2) SpringUtil.getBean("testBean2");
private ITestBean testBean = testBean2.getTestBean();
public void TestBean()
{
testBean2.setId(1);
testBean.setId(1);
System.out.println("["+testBean2.getClass().getName()+"] Id: "+testBean2.getId());
System.out.println("["+testBean.getClass().getName()+"] Id: "+testBean.getId());
}
the application shows the next error:
3/03/2008 04:16:09 PM org.zkoss.zk.ui.impl.UiEngineImpl handleError:764
GRAVE: >>org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'scopedTarget.testBean': 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.
>>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.RequestCon textHolder.currentRequestAttributes(RequestContext Holder.java:102)
>> at org.springframework.web.context.request.SessionSco pe.get(SessionScope.java:88)
>> at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:285)
>> at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:160)
>> at org.springframework.aop.target.SimpleBeanTargetSou rce.getTarget(SimpleBeanTargetSource.java:33)
>>...
What happen?
Ahh, my english is wrong, excuse me plase.