创建serviceRegistry时出现错误。我正在将Hibernate 4.3.4与GWT和mySQL DB一起使用。包含了休眠罐,我在代码中没有任何错误,但是当我运行它时,我得到了:

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;
    }
 }


有人知道该怎么办吗?谢谢

最佳答案

我看起来问题出在import org.hibernate.service.ServiceRegistry;
也许您的项目中的WEB-INF中缺少jar(请注意,大多数时候GWT都需要:jar和源代码),那么GWT找不到类:org/hibernate/service/ServiceRegistry

10-06 13:46