Hi All,
I am working with spring batch and shiro. I save several user information
in shiro session. After login, i can execute several job before the
exception below happen. I don't think this is caused by session timeout
because i set session timeout up to 24 hours. *BusinessRuleEvaluator *is
just simple class that implements *MethodBeforeAdvice, AfterReturningAdvice
*, and call to UserUtil.getCurrentUser
*
* public synchronized static CoreUser getCurrentUser() {
Subject subject = SecurityUtils.getSubject();
Session session = (subject == null) ? null : subject.getSession();
if (session != null) {
CoreUser coreUser = (CoreUser)
session.getAttribute(Constants.CORE_USER);
return coreUser;
} else {
return null;
}
}
*
*
And this is my application config
*<aop:config>
<aop:advisor id="businessRule" advice-ref="businessRuleEvaluator"
pointcut="execution(* *..dao.*Dao.*(..))" order="1"/>
</aop:config>
*
And this is the exception message :
ERROR - AbstractJob.execute(318) | Encountered fatal error executing job
org.apache.shiro.session.UnknownSessionException: There is no session with
id [01e5744d-dd8d-4a3b-8508-5412dc38c618]
at
org.apache.shiro.session.mgt.eis.AbstractSessionDAO.readSession(AbstractSessionDAO.java:170)
at
org.apache.shiro.session.mgt.DefaultSessionManager.retrieveSessionFromDataSource(DefaultSessionManager.java:236)
at
org.apache.shiro.session.mgt.DefaultSessionManager.retrieveSession(DefaultSessionManager.java:222)
at
org.apache.shiro.session.mgt.AbstractValidatingSessionManager.doGetSession(AbstractValidatingSessionManager.java:118)
at
org.apache.shiro.session.mgt.AbstractNativeSessionManager.lookupSession(AbstractNativeSessionManager.java:105)
at
org.apache.shiro.session.mgt.AbstractNativeSessionManager.lookupRequiredSession(AbstractNativeSessionManager.java:109)
at
org.apache.shiro.session.mgt.AbstractNativeSessionManager.getAttribute(AbstractNativeSessionManager.java:206)
at
org.apache.shiro.session.mgt.DelegatingSession.getAttribute(DelegatingSession.java:141)
at
org.apache.shiro.session.ProxiedSession.getAttribute(ProxiedSession.java:121)
at com.anabatic.egl.util.UserUtil.getCurrentUser(UserUtil.java:49)
at
com.anabatic.egl.security.BusinessRuleEvaluator.afterReturning(BusinessRuleEvaluator.java:62)
at
org.springframework.aop.framework.adapter.AfterReturningAdviceInterceptor.invoke(AfterReturningAdviceInterceptor.java:51)
at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at
org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:50)
at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at
org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:90)
at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at
org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:622)
at
com.anabatic.egl.dao.impl.DataDefinitionDaoImpl$$EnhancerByCGLIB$$ee849b92.get(<generated>)
at sun.reflect.GeneratedMethodAccessor252.invoke(Unknown Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:318)
at
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:196)
at $Proxy75.get(Unknown Source)
at
com.anabatic.egl.batch.listener.LedgerTransactionStagingJobListener.beforeJob(LedgerTransactionStagingJobListener.java:36)
at
org.springframework.batch.core.listener.CompositeJobExecutionListener.beforeJob(CompositeJobExecutionListener.java:71)
at
org.springframework.batch.core.job.AbstractJob.execute(AbstractJob.java:290)
at
org.springframework.batch.core.launch.support.SimpleJobLauncher$1.run(SimpleJobLauncher.java:120)
at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
Does anyone have any idea about this is problem?. And FYI, this is not
happen if i restart tomcat before execute that job, and this is only
happen if *BusinessRuleEvaluator *is invoked. Another program
call*UserUtil.getCurrentUser
*without any problem
Thanks.
--
BR,
ab.annas