我已经更换了我的电脑,我重新安装了所有:tomcat 8和6,netbeans 8,jdk 1.7,hibernate 4.3.4,但是当我运行网络应用程序时,我有这个错误。 在过去用我的旧电脑我没有这个错误,但代码和lib是相同的,当我尝试从数据库中获取数据时会发生此错误
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();
}
}
答案 0 :(得分:2)
我发现了问题:我已经在项目中添加了hibernate 3和hibernate 4,概率存在一些冲突。现在我只有hibernate 4并且没有问题
答案 1 :(得分:0)
我们发现端口不可访问。在防火墙级别未打开端口80。请使用来自服务器的wget命令同时使用https和http。对于http,我们正在等待时间。因此,我们在防火墙级别添加了80端口,然后重新启动了jboss。它开始工作
答案 2 :(得分:0)
如果您使用 .hbm.xml
文件升级 Hibernate 版本,请不要忘记升级您的 DTD
例如http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd
=> http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd
控制台中的错误是ERROR org.hibernate.util.DTDEntityResolver Don't use old DTDs, read the Hibernate 3.x Migration Guide!