我在创建serviceRegistry时遇到错误。我将Hibernate 4.3.4与GWT和mySQL DB一起使用。包含了休眠jar,我在代码中没有任何错误,但是当我运行它时,我得到:
com.google.gwt.user.server.rpc.UnexpectedException: Service method 'public abstract java.lang.Long com.coma.comaexjobb.client.UserService.saveUser(com.coma.comaexjobb.shared.Users)' threw an unexpected exception: java.lang.NoClassDefFoundError: org/hibernate/service/ServiceRegistry
我的 HibernateUtil.java
package com.coma.comaexjobb.Util;
import org.hibernate.SessionFactory;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.cfg.Configuration;
import org.hibernate.service.ServiceRegistry;
public class HibernateUtil {
private static SessionFactory sessionFactory;
private static ServiceRegistry serviceRegistry;
public static SessionFactory getSessionFactory() {
Configuration configuration = new Configuration();
configuration.configure();
serviceRegistry = new StandardServiceRegistryBuilder().applySettings(
configuration.getProperties()).build();
sessionFactory = configuration.buildSessionFactory(serviceRegistry);
return sessionFactory;
}
}
任何人都知道该怎么办?谢谢
答案 0 :(得分:1)
我看起来问题出在import org.hibernate.service.ServiceRegistry;
,
也许WEB-INF中缺少 jar (请注意,GWT大部分时间都需要:Jars和源代码),然后GWT找不到类:org/hibernate/service/ServiceRegistry
。