I have an application which contains a webservice that use Spring and hibernate in order to retrieve data from database. Other applications invoke this webservice in their application.
The flow of webservice :
Webservice class method (calls manager class method) --> Manager class method ---> that calls DAO method )
Webservice class :
public List getXXX(){
managerClass.getXX();
}
manager Class:
@Transactional(readOnly=true)
Public List getXX(){
DAOClass.getX();
}
DAO class(It is using hibernate and logic to retrieve data) :
public List getX(){
Criteria query
=getSessionFactory().getCurrentSession()
.createCriteria(dataObject.class);
query.add(Restrictions.eq(dataObject.type, systemId));
query.addOrder(Order.asc(dataObject.TYPE));
query.addOrder(Order.asc(dataObject.code));
return query.list();
}
This Webservice method(by calling manager and DAO classes) giving the list from database. It is working fine all the time except sometimes.
I am not updating or inserting any data,I am just getting the data
(The flow is : Webservice --> manager Class--> DAO --> hibernate)
One client is accessing this method to get the List in their application.he is getting the data properly all the time.But sometimes he is getting this Exception :
javax.xml.ws.soap.SOAPFaultException: Could not roll back Hibernate transaction; nested exception is org.hibernate.TransactionException: JDBC rollback failed
at org.apache.axis2.jaxws.marshaller.impl.alt.MethodMarshallerUtils.createSystemException(MethodMarshallerUtils.java:1346)
at org.apache.axis2.jaxws.marshaller.impl.alt.MethodMarshallerUtils.demarshalFaultResponse(MethodMarshallerUtils.java:1072)
at org.apache.axis2.jaxws.marshaller.impl.alt.DocLitWrappedMethodMarshaller.demarshalFaultResponse(DocLitWrappedMethodMarshaller.java:593)
at org.apache.axis2.jaxws.client.proxy.JAXWSProxyHandler.getFaultResponse(JAXWSProxyHandler.java:559)
at org.apache.axis2.jaxws.client.proxy.JAXWSProxyHandler.createResponse(JAXWSProxyHandler.java:497)
at org.apache.axis2.jaxws.client.proxy.JAXWSProxyHandler.invokeSEIMethod(JAXWSProxyHandler.java:404)
at org.apache.axis2.jaxws.client.proxy.JAXWSProxyHandler.invoke(JAXWSProxyHandler.java:208)
According to Spring default behavior, whenever the exception is thrown, it tries to roll back.That is what it is trying, but somehow could not rollback. As it is declarative transaction by using annotations, How can I track exact reason for this exception? based on the exception, I definitely know the DAO class method is throwing exception.but I am not able to track the exact reason(whether connection closed issue or any other thing).i just want to use exception handling in DAO class in order to know the exact reason.Can I use try/catch block in DAO class method to have stack trace that prints the exact reason? I just want to remind once again, it is working fine all the time, but sometimes it is not working because of this exception.
I hope I clearly explained my problem.Please do the needful by giving solution.