struts+hibernate做个网上购物系统.因为我首页要从数据库读取数据,所以在JSP页面里嵌入了JAVA代码.但在运行的时候提示如下异常:java.lang.ExceptionInInitializerError
com.donghua.bookstore.dao.BaseDAO.<clinit>(BaseDAO.java:15)
com.donghua.bookstore.service.impl.BookServiceImpl.<init>(BookServiceImpl.java:12)
com.donghua.bookstore.service.impl.BookStoreImpl.getBookService(BookStoreImpl.java:26)
org.apache.jsp.pages.index_jsp._jspService(org.apache.jsp.pages.index_jsp:181)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:325)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:302)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:246)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
//这是hibernate的相关类public class HibernateSessionFactory { private static String CONFIG_FILE_LOCATION = "com/donghua/bookstore/config/hibernate.cfg.xml"; private static final ThreadLocal threadLocal = new ThreadLocal(); private static final SessionFactory sessionFactory = new Configuration()
.configure(CONFIG_FILE_LOCATION).buildSessionFactory(); private HibernateSessionFactory() {
}
public static Session getCurrentSession() {
Session session = (Session) threadLocal.get();
if (session == null || !session.isOpen()) {
session = sessionFactory.openSession();
threadLocal.set(session);
}
return session;
} public static void closeSession() {
Session session = (Session) threadLocal.get();
threadLocal.set(null);
if (session != null)
session.close();
}
}我怀疑是这个类出了问题,但不确定.大家帮我分析一下吧!!