please help me in resolving this error.
org.hibernate.HibernateException: Could not parse configuration: hibernate.cfg.xml
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1494)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1428)
at org.jbpm.db.hibernate.HibernateHelper.createConfiguration (HibernateHelper.java:89)
at org.jbpm.persistence.db.DbPersistenceServiceFactory.getConfiguration (DbPersistenceServiceFactory.java:75)
at org.jbpm.persistence.db.DbPersistenceServiceFactory.getSessionFactory(DbPersistenceServiceFactory.java:104)
at org.jbpm.persistence.db.DbPersistenceService.getSessionFactory(DbPersistenceService.java:93)
at org.jbpm.persistence.jta.JtaDbPersistenceService.getTransactionManager(JtaDbPersistenceService.java:100)
at org.jbpm.persistence.jta.JtaDbPersistenceService.getTransactionStatus(JtaDbPersistenceService.java:88)
at org.jbpm.persistence.jta.JtaDbPersistenceService.<init>(JtaDbPersistenceService.java:50)
at org.jbpm.persistence.jta.JtaDbPersistenceServiceFactory.openService(JtaDbPersistenceServiceFactory.java:61)
at org.jbpm.svc.Services.getService(Services.java:160)
at org.jbpm.svc.Services.getPersistenceService(Services.java:197)
at org.jbpm.JbpmContext.getPersistenceService(JbpmContext.java:695)
at org.jbpm.JbpmContext.getJobSession(JbpmContext.java:639)
at org.jbpm.job.executor.LockMonitorThread.unlockOverdueJobs(LockMonitorThread.java:64)
at org.jbpm.job.executor.LockMonitorThread.run(LockMonitorThread.java:43)
Caused by: org.dom4j.DocumentException: Connection reset Nested exception: Connection reset
at org.dom4j.io.SAXReader.read(SAXReader.java:484)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1484)
... 15 more
I am new to hibernate and having difficulty in understanding what the error is. The jar files used for hibernate are as
hibernate-annotations.jar
hibernate-jpa-2.0-api-1.0.1.Final.jar
hibernate3.jar
my hibernate.cfg.xml file is as
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration SYSTEM
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.url">jdbc:mysql://localhost:3306/datacenter</property>
<property name="connection.username">root</property>
<property name="connection.password">admin</property>
<!-- <property name="hibernate.connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property>
-->
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="current_session_context_class">thread</property>
<property name="show_MySql">TRUE</property>
<property name="format_sql">TRUE</property>
<!-- <property name="jboss.as.jpa.providerModule">hibernate3- bundled</property> -->
<property name="hibernate.hbm2ddl.auto">update</property>
<property name="hibernate.cache.use_second_level_cache">true</property>
<!-- <property name="hibernate.query.factory_class">org.hibernate.hql.internal.classic.ClassicQueryTransla torFactory</property> -->
<!-- List of annotated classes-->
<!-- Associations -->
<!-- One to one -->
<!-- <mapping class="Emp_Timecard" />
<mapping class="maindoor" /> -->
<mapping class="model.serverroom" />
<mapping class="model.resourcelist" />
<mapping class="model.timesheet" />
<mapping class="model.maindoor" />
<!-- <mapping class="timesheet" />
<mapping class="Resource_list"/> -->
</session-factory>
</hibernate-configuration>
I think you are having an issue with connecting to the db properly. Are you sure the user name and password are correct? Or did you have an already a database called datacenter?
Also try changing the doctype as
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
See Can't parse hibernate.cfg.xml while offline
Depending on your hibernate version it might be that hibernate is trying to load the DTD from the internet and that the connection is reset in the meantime.
to run hibernate application offline use 'hibernate-core jar' file it will work..
no need to change your Hibernate configuration file .Avvappa,BEL.
change ur hiber configuration i.e
<hibernate-configuration
xmlns="http://www.hibernate.org/xsd/hibernate-configuration"
xsi:schemaLocation="http://www.hibernate.org/xsd/hibernate-configuration hibernate-configuration-4.0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
----------------------------to as below -------------------------------------
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.5//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
change your Hibernate configuration as follows;
<hibernate-configuration
xmlns="http://www.hibernate.org/xsd/hibernate-configuration"
xsi:schemaLocation="http://www.hibernate.org/xsd/hibernate-configuration hibernate-configuration-4.0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
----------------------------to as below -------------------------------------
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.5//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
Try Running the program while your system is connected to Internet
I was facing the same issue. And when i searched for the solution online found this thread regarding the same issue.
I went back and tried running the program again and it worked, the only changes made were connected to Internet Connection. I turned off the connection and again the program was giving the same error as you got.
My guess is the Hibernate configuration file is downloading the DTD from internet, and when it fails to do so it gives error while creating the SessionFactory object.
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
If the configuration file is not parsed, just check for the hibernate version. If it is hibernate 3 the DTD should be from Sourceforge website. if it is the later version the DTD should be
<!DOCTYPE hibernate-configuration SYSTEM
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
Related
I'm starting learing how to use IntelliJ, and I'm trying to link my persistence to my datasource.
I've read here on SO how to do that, and now I've binded my persistence to my datasource successfully: I can run queries on database, and i can browse my persistence.
This is the db (MSSQL):
This is the persistence:
And this is the assignment:
The problem is that I'm still getting error on my class, looks like is not able to link to the datasource, and is giving me the error "Cannot resolve column" (not only on ID column, but on all columns):
The application is running fine, so the problem is only related to some wrong intellij configuration, but I can't find where the problem is.
This is my hibernate.cfg.xml (there are more tables, I've left only the one in the example):
<?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 name="Artemide">
<property name="hibernate.bytecode.use_reflection_optimizer">false</property>
<property name="hibernate.connection.driver_class">com.microsoft.sqlserver.jdbc.SQLServerDriver</property>
<!-- Configurazione maven-->
<property name="hibernate.connection.password">${hibernate.password}</property>
<property name="hibernate.connection.username">${hibernate.username}</property>
<property name="hibernate.connection.url">${hibernate.connection.url}</property>
<property name="hibernate.default_catalog">${hibernate.default_catalog}</property>
<property name="hibernate.dialect">org.hibernate.dialect.SQLServer2008Dialect</property>
<property name="hibernate.search.autoregister_listeners">false</property>
<property name="hibernate.show_sql">false</property>
<property name="hibernate.format_sql">true</property>
<mapping class="xx.xx.xx.database.pojo.Categoria"/>
</session-factory>
</hibernate-configuration>
Thanks!
I'm making a new project with Hibernate.
I have some problems configure hibernate correctly in my Eclipse environment.
<?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">
<hibernate-configuration>
<session-factory name="">
<property name="hibernate.connection.driver_class">com.microsoft.jdbc.sqlserver.SQLServerDriver</property>
<property name="hibernate.connection.password">XXXXX</property>
<property name="hibernate.connection.url">jdbc:sqlserver://localhost/Framework</property>
<property name="hibernate.connection.username">sa</property>
<property name="hibernate.default_schema">Framework</property>
<property name="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</property>
<property name="hibernate.connection.pool_size">10</property>
<property name="show_sql">true</property>
</session-factory>
</hibernate-configuration>
My Eclipse environment only sees the master database instead of my Framework database. Can someone help me with this?
The database was not correctly configured. The user didn't have the correct permissions. After fixing this it works.
Here is my code in file named 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">
<hibernate-configuration>
<session-factory>
<!-- Database connection settings -->
<property name="connection.url">jdbc:mysql://localhost:3306/HeartJar</property>
<property name="connection.username">root</property>
<property name="connection.password">root</property>
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="show_sql">true</property>
<mapping resource="com/heartjar/bean/User.hbm.xml" />
</session-factory>
</hibernate-configuration>
There was a waining saying Stream not availableat line 2
Although warnings don't have bad influences to my project.But Understanding how to solve the problem is useful for me,a beginner in JavaWeb.Thank you for your answer
This is my configuration:
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-5.0.dtd">
<hibernate-configuration
xmlns="http://www.hibernate.org/xsd/hibernate-configuration"
xsi:schemaLocation="http://www.hibernate.org/xsd/hibernate-configuration hibernate-configuration-4.0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<session-factory>
<!-- Database connection settings -->
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.url">jdbc:mysql://localhost:3306/test</property>
<property name="connection.username">root</property>
<property name="connection.password"></property>
<!-- JDBC connection pool (use the built-in) -->
<property name="connection.pool_size">1</property>
<!-- SQL dialect -->
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<!-- Enable Hibernate's automatic session context management -->
<property name="current_session_context_class">thread</property>
<!-- Disable the second-level cache -->
<property name="cache.provider_class">org.hibernate.cache.internal.NoCacheProvider</property>
<!-- Echo all executed SQL to stdout -->
<property name="show_sql">true</property>
<!-- Drop and re-create the database schema on startup -->
<property name="hbm2ddl.auto">update</property>
<mapping resource="org/hibernate/tutorial/domain/Event.hbm.xml"/>
<mapping class="Mapping.AccountMap"
</session-factory>
</hibernate-configuration>
I read that i should change the "Doctype" and i did from other answers i have found, yet this error occurs:
Unable to perform unmarshalling at line number 8 and column 63 in RESOURCE hibernate.cfg.xml. Message: cvc-elt.1: Cannot find the declaration of element 'hibernate-configuration'.
Your dtd url is false ... seems like hibernate-configuration-5.0.dtd doesn't exist ... use this :
http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd
change the whole header :
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-5.0.dtd">
<hibernate-configuration
xmlns="http://www.hibernate.org/xsd/hibernate-configuration"
xsi:schemaLocation="http://www.hibernate.org/xsd/hibernate-configuration hibernate-configuration-4.0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
TO
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration
PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
Try to add this header block. It works for me and also check parse error in your XML file.
<?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">
Here i am posting some sample xml file may be it will help you.
<hibernate-configuration>
<session-factory>
<!-- Database connection settings -->
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.url">jdbc:mysql://localhost:3306/hibernate</property>
<property name="connection.username">root</property>
<property name="connection.password">root</property>
<!-- JDBC connection pool (use the built-in) -->
<property name="connection.pool_size">1</property>
<!-- SQL dialect -->
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<!-- Disable the second-level cache -->
<property name="cache.provider_class">org.hibernate.cache.internal.NoCacheProvider</property>
<!-- Echo all executed SQL to stdout -->
<property name="show_sql">true</property>
<!-- Drop and re-create the database schema on startup -->
<property name="hbm2ddl.auto">create</property>
<!-- Names the annotated entity class -->
<mapping class="org.java.dto.UserDetails"/>
</session-factory>
</hibernate-configuration>
I am stuck with hibernate configuration file exception, this is my hibernate.cfg.xml file:
<?xml version='1.0' encoding='utf-8'?>
<hibernate-configuration
xmlns="http://www.hibernate.org/xsd/hibernate-configuration"
xsi:schemaLocation="http://www.hibernate.org/xsd/hibernate-configuration hibernate-configuration-4.0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<session-factory>
<!-- Database connection settings -->
<property name="connection.driver_class">org.postgresql.Driver</property>
<property name="connection.url">jdbc:postgresql://localhost:5432/hibernatedb</property>
<property name="connection.username">postgresql</property>
<property name="connection.password">password</property>
<!-- JDBC connection pool (use the built-in) -->
<property name="connection.pool_size">1</property>
<!-- SQL dialect -->
<property name="dialect">org.hibernate.dialect.PostgresPlusDialect</property>
<!-- Enable Hibernate's automatic session context management -->
<property name="current_session_context_class">thread</property>
<!-- Disable the second-level cache -->
<property name="cache.provider_class">org.hibernate.cache.internal.NoCacheProvider</property>
<!-- Echo all executed SQL to stdout -->
<property name="show_sql">true</property>
<!-- Drop and re-create the database schema on startup -->
<property name="hbm2ddl.auto">update</property>
<mapping resource="org.person.PersonModel"/>
</session-factory>
</hibernate-configuration>
I am using hibernate-core-4.1.12.Final.jar, I am getting the following exception:
INFO: HHH000040: Configuration resource: /hibernate.cfg.xml
Exception in thread "main" org.hibernate.MappingException: invalid configuration
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:2022)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1939)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1918)
at org.person.PersonPersistance.main(PersonPersistance.java:14)
Caused by: org.xml.sax.SAXParseException; lineNumber: 3; columnNumber: 25; Document is invalid: no grammar found.
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
By seeing the respective exception I came to know that I have some mistake in my configuration file. I want to know what mistake I have done in my configuration file.
When I wrote same program in Eclipse Luno, it has got execute. Try this and see.
Add this before <hibernate-configuration> tag:
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
With Hibernate 4.x you should use the same DTD as 3.x:
<?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">
<hibernate-configuration>
<session-factory>