I am working on JBOSS application and I am facing issue for loggin sessionTimeout event
I want to make JTA transaction once the session is expire.
My code is as follow
spring.xml
...
<bean
class="org.springframework.orm.hibernate3.HibernateTransactionManager"
id="transactionManager">
<property name="sessionFactory" >
<ref local="sessionFactory" />
</property>
</bean>
<bean id="msg" class="com.Message">
....
</bean>
...
web.xml
...
<listener>
<listener-class>
com.demo.MySessionListener
</listener-class>
</listener>
...
Class File
public class MySessionListener implements HttpSessionListener{
public void sessionCreated(HttpSessionEvent event) {
}
public void sessionDestroyed(HttpSessionEvent event) {
HttpSession session = event.getSession();
ApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(session.getServletContext());
Message msg = (Message)ctx.getBean("msg");
msg.save(); // throws error org.springframework.transaction.CannotCreateTransactionException
}
}
I found that All the JTA operation must be done in session, But in this case how can I achieve this ? Because I want to perform JTA transaction because of the session expiration event.
Let me know if anyone have solve this problem even before.
Thanks
Aucun commentaire:
Enregistrer un commentaire