Dear all
In my web application , I write a hibernate transaction filter as below
Code:
public class HibernateSessionRequestFilter implements Filter {
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
Transaction tx = null;
try {
logger.warn(HibernateServiceImpl.getCurrentSession());
tx = HibernateServiceImpl.getCurrentSession().getTransaction();
if (!(tx != null && tx.isActive())) {
tx.begin();
}
chain.doFilter(request, response);
if (tx != null && tx.isActive()) {
tx.commit();
}
} catch (Exception e) {
try {
if (tx != null && tx.isActive()) {
tx.rollback();
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
There is a frame in the jsp page as below
Code:
<frameset cols="40%,60%" id="myframe" frameborder="no" border="0" framespacing="0">
<frame src="${pageContext.request.contextPath}/left.do?act=showdata" name="leftFrame" id="leftFrame" scrolling="yes">
<frame src="${pageContext.request.contextPath}/right.do?act=queryUserData&default=yes" name="rightFrame" id="rightFrame" scrolling="yes">
</frameset>
When client enter into the jsp page.
The server side receives leftFrame http request and rightFrame http request almost simultaneously.But one request will be stuck in the tx.begin(); until the anther request had been completed and commited. But I think both request should proceed simultaneously.
Can someone tell me why the phenomenon occur?
I deploy the web application on Tomcat. My hibernate setting as below
Code:
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</prop>
<prop key="hibernate.show_sql">false</prop>
<prop key="hibernate.current_session_context_class">thread</prop>
<prop key="hibernate.jdbc.batch_size">100</prop>
</props>
</property>