Hibernate 创建SessionFactory失败,怎么回事?
public class HibernateUtil {
private static final SessionFactory sessionFactory;
static {
try {
Configuration config = new Configuration().configure();
sessionFactory = config.buildSessionFactory();// 执行到这步就出错了
} catch (Throwable ex) {
ex.printStackTrace();
throw new ExceptionInInitializerError(ex);
}
}
public static final ThreadLocal session = new ThreadLocal();
public static Session currentSession() throws HibernateException {
Session s = (Session) session.get();
// Open a new Session, if this Thread has none yet
if (s == null||!s.isOpen()) {
s = sessionFactory.openSession();
session.set(s);
}
return s;
}
public static void closeSession() throws HibernateException {
Session s = (Session) session.get();
session.set(null);
if (s != null)
s.close();
}
}
该怎么解决?
[解决办法]
信息: validateJarFile(D:\Program Files\Tomcat 5.5\webapps\studentInfo\WEB-INF\lib\servlet.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class
servlet.jar删了
然后把你web.xml帖出来看看。
[解决办法]
<property name= "hibernate.connection.url "> jdbc:mysql:///ff </property>
这是什么啊?