不正常的sessionfactory创建失败 [英] Irregular sessionfactory creation failure

查看:81
本文介绍了不正常的sessionfactory创建失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Initial SessionFactory creation failed.org.hibernate.HibernateException: Could not parse configuration: hibernate-annotation.cfg.xml





这是我得到的错误。除了应用程序抛出此错误的2个事件外,应用程序始终正常运行。



我的主要猜测是java / hibernate无法与mysql服务器连接。我也在调查。但不完全确定发生了什么。这是好奇心灵的配置文件



This is the error I am getting. Application runs properly all the time except for 2 incidents when application was throwing this error.

My primary guess is some how java/hibernate was failing to connect with mysql server. Which I am also investigating. But Not exactly sure what is happening. Here is configuration file for curious mind

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
		"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
		"http://hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
	<session-factory>
		<!-- Database connection properties - Driver, URL, user, password -->
		<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
		<property name="hibernate.connection.url">${mysql_url}</property>
		<property name="hibernate.connection.username">${mysql_user}</property>
		<property name="hibernate.connection.password">${mysql_pass}</property>

		<!-- org.hibernate.HibernateException: No CurrentSessionContext configured! -->
		<property name="hibernate.current_session_context_class">thread</property>
		<!-- <property name="hibernate.show_sql">true</property> -->
		<!-- <property name="hibernate.format_sql">true</property> -->
		<property name="connection.autocommit">true</property>

		<!-- Mapping with model class containing annotations -->
		<mapping class="*.hibernatemodel.*" />
	</session-factory>
</hibernate-configuration>





我尝试过:



我查看了日志,它没有提供任何帮助。如果这是一个一致的错误,我想我会知道的。期待听到人们的经历。如果您需要任何进一步的信息,请告诉我。





- 进一步的调查结果 -

hibernate在运行时访问url http://hibernate.org/dtd/hibernate-configuration-3.0.dtd 。如果由于应用程序无法与Internet连接的原因,我的应用程序将失败。如果我一起删除Doctype,则应用程序将失败。我不喜欢我的批处理每分钟访问(我的批处理每分钟运行)。



有谁知道任何潜在的解决方案?当然除了摆脱Hibernate。



What I have tried:

I went through logs, it offers nothing much. If it was a consistent error, I would have known, I guess. Expecting to hear peoples experience. If you need any further information, please let me know.


--further findings--
hibernate access the url http://hibernate.org/dtd/hibernate-configuration-3.0.dtd in runtime. If for whatever the reason application fail to connect with internet my application will fail. If I remove the Doctype all together, application fails. And I do not like my batch accessing every minute(my batch runs every minute).

Does anyone know any potential solution? Besides getting rid off Hibernate of course.

推荐答案

{mysql_url}< / property>
< property name =hibernate.connection.username>
{mysql_url}</property> <property name="hibernate.connection.username">


{mysql_user}< / property>
< property name =hibernate.connection.password>
{mysql_user}</property> <property name="hibernate.connection.password">


{mysql_pass}< / property>

<! - org.hibernate.HibernateException:没有配置CurrentSessionContext! - >
< property name =hibernate.current_session_context_class> thread< / property>
<! - < property name =hibernate.show_sql> true< / property> - >
<! - < property name =hibernate.format_sql> true< / property> - >
< property name =connection.autocommit> true< / property>

<! - 使用包含注释的模型类进行映射 - >
< mapping class =*。hibernatemodel。*/>
< / session-factory>
< / hibernate-configuration>
{mysql_pass}</property> <!-- org.hibernate.HibernateException: No CurrentSessionContext configured! --> <property name="hibernate.current_session_context_class">thread</property> <!-- <property name="hibernate.show_sql">true</property> --> <!-- <property name="hibernate.format_sql">true</property> --> <property name="connection.autocommit">true</property> <!-- Mapping with model class containing annotations --> <mapping class="*.hibernatemodel.*" /> </session-factory> </hibernate-configuration>





我尝试过:



我查看了日志,它没有提供任何帮助。如果这是一个一致的错误,我想我会知道的。期待听到人们的经历。如果您需要任何进一步的信息,请告诉我。





- 进一步的调查结果 -

hibernate在运行时访问url http://hibernate.org/dtd/hibernate-configuration-3.0.dtd 。如果由于应用程序无法与Internet连接的原因,我的应用程序将失败。如果我一起删除Doctype,则应用程序将失败。我不喜欢我的批处理每分钟访问(我的批处理每分钟运行)。



有谁知道任何潜在的解决方案?当然除了摆脱Hibernate。



What I have tried:

I went through logs, it offers nothing much. If it was a consistent error, I would have known, I guess. Expecting to hear peoples experience. If you need any further information, please let me know.


--further findings--
hibernate access the url http://hibernate.org/dtd/hibernate-configuration-3.0.dtd in runtime. If for whatever the reason application fail to connect with internet my application will fail. If I remove the Doctype all together, application fails. And I do not like my batch accessing every minute(my batch runs every minute).

Does anyone know any potential solution? Besides getting rid off Hibernate of course.


这篇关于不正常的sessionfactory创建失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆