Announcement Announcement Module
Collapse
No announcement yet.
accessing http session object from a different thread Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • 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="com.nc.datamodel.ConfigDataSource" singleton="true">
    <aop:scope type="session" />
    </bean>
    <bean id="configPoller" class="com.nc.datamodel.VersionPoller" singleton="true" destroy-method="stopPoller">
    <aop:scope type="session" />
    <property name="timePeriod" value="15" />
    <property name="dataSource" ref="configDataSource" />
    </bean>

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

    This is not working and throwing the following exception:

    java.lang.NullPointerException
    at org.springframework.web.context.scope.ServletReque stAttributes.setAttribute(ServletRequestAttributes .java:67)
    at org.springframework.web.context.scope.SessionScope Map.put(SessionScopeMap.java:74)
    at org.springframework.aop.target.scope.ScopedTargetS ource.getTarget(ScopedTargetSource.java:97)
    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 com.nc.datamodel.config.DOMConfigDataSource$$Enhan cerByCGLIB$$8216b117.refresh(<generated>)
    at com.nc.datamodel.VersionPoller.notifyChange(Versio nPoller.java:91)

    Is there a way I can get around this problem:
Working...
X