Announcement Announcement Module
No announcement yet.
accessing http session object from a different thread Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • accessing http session object from a different thread

    I am using spring-framework-2.0-m3. I am getting a NullPointerException when I try to access a object defined with scope session from a polling thread. My user case is as follows : I have the following bean defination

    <bean id="configDataSource" class="" singleton="true">
    <aop:scope type="session" />
    <bean id="configPoller" class="" singleton="true" destroy-method="stopPoller">
    <aop:scope type="session" />
    <property name="timePeriod" value="15" />
    <property name="dataSource" ref="configDataSource" />

    VersionPoller has a ScheduledExecutorService whose task need to access the datasource.

    This is not working and throwing the following exception:

    at org.springframework.web.context.scope.ServletReque stAttributes.setAttribute(ServletRequestAttributes .java:67)
    at org.springframework.web.context.scope.SessionScope Map.put(
    at ource.getTarget(
    at org.springframework.aop.framework.Cglib2AopProxy$D ynamicAdvisedInterceptor.getTarget(Cglib2AopProxy. java:669)
    at org.springframework.aop.framework.Cglib2AopProxy$D ynamicAdvisedInterceptor.intercept(Cglib2AopProxy. java:620)
    at$$Enhan cerByCGLIB$$8216b117.refresh(<generated>)

    Is there a way I can get around this problem: