怎么会找不到方法呢?请各位高人指教,谢谢了.
报错信息:
javax.servlet.ServletException: Filter execution threw an exception
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:368)
root cause
java.lang.NoSuchMethodError: org.hibernate.SessionFactory.getCurrentSession()Lorg/hibernate/classic/Session;
util.TransactionFilter.doFilter(TransactionFilter.java:38)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:368)
但是我在导入的jar包里可以找到SessionFactory类的getCurrentSession()方法,写的类里也没有报错啊.
源代码:
public class TransactionFilter implements Filter{
/** Creates a new instance of TransactionFilter */
public TransactionFilter() {
}
public void init(FilterConfig filterConfig) throws
ServletException {
}
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws
IOException, ServletException {
System.out.println( "Transaction starting... ");
// Session session=null;
try{
HibernateUtil.getSessionFactory().getCurrentSession().beginTransaction();
chain.doFilter(request,response);
HibernateUtil.getSessionFactory().getCurrentSession().getTransaction().commit();
System.out.println( "end transaction... ");
} catch(Exception e){
e.printStackTrace();
HibernateUtil.getSessionFactory().getCurrentSession().getTransaction().rollback();
}
}
public class HibernateUtil {
private static SessionFac