[英]Hibernate Exception while deploying on VPS server
I am using VPS server first time to deploy my application. 我第一次使用VPS服务器来部署我的应用程序。 I have created a Hibernate Project.
我创建了一个Hibernate项目。 After Deploying it is giving me following error
部署后,它给了我以下错误
org.hibernate.HibernateException: Could not parse configuration: /hibernate.cfg.xml org.hibernate.cfg.Configuration.doConfigure(Configuration.java:2246) org.hibernate.cfg.AnnotationConfiguration.doConfigure(AnnotationConfiguration.java:230) org.hibernate.cfg.AnnotationConfiguration.doConfigure(AnnotationConfiguration.java:71) org.hibernate.cfg.Configuration.configure(Configuration.java:2158) org.hibernate.cfg.AnnotationConfiguration.configure(AnnotationConfiguration.java:212) org.hibernate.cfg.AnnotationConfiguration.configure(AnnotationConfiguration.java:71) org.hibernate.cfg.Configuration.configure(Configuration.java:2137) org.hibernate.cfg.AnnotationConfiguration.configure(AnnotationConfiguration.java:206) util.HibernateUtil.(HibernateUtil.java:26) services.HibernateServices.(HibernateServices.java:41) servlet.GetShopProfile.processRequest(GetShopProfile.java:42) servlet.GetShopProfile.doGet(GetShopProfile.java:77) javax.servlet.http.HttpServlet.service(HttpServlet.java:621) javax.s
org.hibernate.HibernateException:无法解析配置:/hibernate.cfg.xml org.hibernate.cfg.Configuration.doConfigure(Configuration.java:2246)org.hibernate.cfg.AnnotationConfiguration.doConfigure(AnnotationConfiguration.java:230)org .hibernate.cfg.AnnotationConfiguration.doConfigure(AnnotationConfiguration.java:71)org.hibernate.cfg.Configuration.configure(Configuration.java:2158)org.hibernate.cfg.AnnotationConfiguration.configure(AnnotationConfiguration.java:212)org.hibernate .cfg.AnnotationConfiguration.configure(AnnotationConfiguration.java:71)org.hibernate.cfg.Configuration.configure(Configuration.java:2137)org.hibernate.cfg.AnnotationConfiguration.configure(AnnotationConfiguration.java:206)util.HibernateUtil。( HibernateUtil.java:26)services.HibernateServices。(HibernateServices.java:41)servlet.GetShopProfile.processRequest(GetShopProfile.java:42)servlet.GetShopProfile.doGet(GetShopProfile.java:77)javax.servlet.http.HttpServlet.service (HttpServlet.java:621)javax.s ervlet.http.HttpServlet.service(HttpServlet.java:728)
ervlet.http.HttpServlet.service(HttpServlet.java:728)
To test if my database is working fine, I created a normal database connection class and it was working fine. 为了测试我的数据库是否正常工作,我创建了一个普通的数据库连接类,它工作正常。
hibernate.cfg.xml 的hibernate.cfg.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/test</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password">root</property>
<property name="hibernate.show_sql">true</property>
<property name="hibernate.connection.pool_size">1</property>
<property name="hibernate.current_session_context_class">thread</property>
<!--<property name="hibernate.query.factory_class">org.hibernate.hql.internal.classic.ClassicQueryTranslatorFactory</property>-->
<property name="hibernate.query.factory_class">org.hibernate.hql.classic.ClassicQueryTranslatorFactory</property>
<mapping class="pojo.TestClass"/>
</session-factory>
</hibernate-configuration>
Directory Structure 目录结构
WEB-INF
classes
pojo
TestClass.class
services
HibernateService.class
servlet
TestServlet.class
util
HibernateUtil.class
hibernate.cfg.xml
We have Tomcat 7.0 installed. 我们安装了Tomcat 7.0。 Kindly help!!!
请帮助!!!
I solved the problem by reinstalling the tomcat on my server. 我通过在我的服务器上重新安装tomcat解决了这个问题。 Any ways this issue can be solved by changing the DTD as suggested in questions: here
通过更改问题中建议的DTD可以解决此问题的任何方法: 此处
I tried multiple solutions in my case but at last when nothing worked I reinstalled the tomcat and every thing was fine 我在我的情况下尝试了多种解决方案,但最后什么都没有用,我重新安装了tomcat,一切都很好
Thanks every one for their inputs and time. 感谢每一个人的投入和时间。
Can you try adding space in your commented lines? 你可以尝试在注释行中添加空格吗?
<!--<property name="hibernate.query.factory_class">org.hibernate.hql.internal.classic.ClassicQueryTranslatorFactory</property>-->
Replace above line with 替换上面的行
<!-- <property name="hibernate.query.factory_class">org.hibernate.hql.internal.classic.ClassicQueryTranslatorFactory</property> -->
I think starting tag < after your comment start section is causing xml parsing issue. 我认为在你的评论开始部分之后开始标记<导致xml解析问题。
Change the hibernate.cfg.xml as 将hibernate.cfg.xml更改为
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.