在本地服务器上,我可以对服务器进行api调用,并且可以看到这些值已保存到数据库中。
但是当上线并使用实际的域名地址时,出现以下错误:

java.lang.NoClassDefFoundError: Could not initialize class d.d.util.HibernateUtil


我的HibernateUtil.java是:

import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;


public class HibernateUtil {

    private static final SessionFactory sessionFactory = buildSessionFactory();



       private static SessionFactory buildSessionFactory() {
            try {
                // Create the SessionFactory from hibernate.cfg.xml
                return new Configuration().configure().buildSessionFactory();
            }
            catch (Throwable ex) {
                // Make sure you log the exception, as it might be swallowed
                System.err.println("Initial SessionFactory creation failed." + ex);
                throw new ExceptionInInitializerError(ex);
            }
        }

        public static SessionFactory getSessionFactory() {
            return sessionFactory;
        }

        public static void shutdown() {
            // Close caches and connection pools
            getSessionFactory().close();
        }

    }


来自亚马逊的日志向我展示了其他内容:

Exception occurred during processing request: uid is required
java.lang.Exception: uid is required
    at d.d.Pamper.action.GetUserProfileAction.execute(GetUserProfileAction.java:16) ~[classes/:?]


如果UID为null,这是我抛出的异常。

最佳答案

NoClassDefFoundError表示HibernateUtil缺少某些相关类。好像您在实时系统上缺少org.hibernate.*类。

09-26 02:14