【问题标题】:Hibernate not connection from https domain休眠未从 https 域连接
【发布时间】:2018-07-12 14:12:42
【问题描述】:

在我的本地服务器上,我可以对我的服务器进行 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,这是我自己抛出的异常。

【问题讨论】:

    标签: java hibernate amazon-elastic-beanstalk


    【解决方案1】:

    NoClassDefFoundError 表示HibernateUtil 缺少一些依赖类。看起来,您在实时系统中缺少 org.hibernate.* 课程。

    【讨论】:

    • 那么我该如何上传我的依赖呢?
    • 有很多选择。例如,用 maven 将它们打包到单个 jar 中。我通常使用 spring boot maven 插件。您拥有什么样的应用程序,以及如何部署它?
    • 它是一个 struts2 应用程序,我使用 eclipse 导出为 war 文件,然后将其上传到亚马逊的弹性 beanstalk。
    • 尝试使用maven war插件:这里是简单的例子stackoverflow.com/questions/21173514/…
    • 谢谢,我试过这样但我仍然得到同样的错误
    【解决方案2】:

    我使用的是亚马逊的数据库,它需要一些配置才能从互联网访问。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-04-27
      • 1970-01-01
      • 1970-01-01
      • 2016-07-15
      • 2011-01-05
      • 2016-09-07
      • 1970-01-01
      相关资源
      最近更新 更多