gpt4 book ai didi

java - org.dom4j.DocumentException : Connection timed out: connect and Nested exception: Connection Nested exception

转载 作者:行者123 更新时间:2023-11-30 03:50:42 33 4
gpt4 key购买 nike

我更换了电脑,并重新安装了所有版本:tomcat 8 和 6、netbeans 8、jdk 1.7、hibernate 4.3.4,但是当我运行 Web 应用程序时,出现此错误。过去使用我的旧电脑时,我没有出现此错误,但代码和库是相同的,当我尝试从数据库获取数据时会发生此错误

SEVERE: Servlet.service() for servlet Controller threw exception
org.dom4j.DocumentException: Connection timed out: connect Nested exception: Connection timed out: connect
at org.dom4j.io.SAXReader.read(SAXReader.java:484)
..cut..
Nested exception:
java.net.ConnectException: Connection timed out: connect
at java.net.DualStackPlainSocketImpl.connect0(Native Method)
..cut..
SEVERE: Servlet.service() for servlet Controller threw exception
java.lang.NoClassDefFoundError: Could not initialize class ..cut..HibernateUtil
at my.package.data.DataAccess.getUser(DataAccess.java:38)

这是 HibernateUtil.java:

package my.package;

import org.hibernate.SessionFactory;
import org.hibernate.service.*;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.cfg.Configuration;

public class HibernateUtil {

private static final SessionFactory sessionFactory = buildSessionFactory1();

private static SessionFactory buildSessionFactory1()
{
Configuration configuration = new Configuration().configure();
StandardServiceRegistryBuilder serviceRegistryBuilder = new StandardServiceRegistryBuilder();
serviceRegistryBuilder.applySettings(configuration.getProperties());
ServiceRegistry serviceRegistry = serviceRegistryBuilder.build();
return configuration.buildSessionFactory(serviceRegistry);
}

public static SessionFactory getSessionFactory() {
return sessionFactory;
}

public static void shutdown() {
getSessionFactory().close();
}
}

最佳答案

我发现问题:我已经将 hibernate 3 和 hibernate 4 添加到项目中,可能存在一些冲突。现在我只有 hibernate 4 并且没有问题

关于java - org.dom4j.DocumentException : Connection timed out: connect and Nested exception: Connection Nested exception,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24528263/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com