Hey guys I am beginner for the hibernate and I know there are so many similar questions here. I tried to solve from them but I could not. I also tried to change SYSTEM from PUBLIC in dtd but its not working. I googled for it but everywhere it showing for the dtd statement error.
This is my configuration file.
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="show_sql">true</property>
<property name="connection.driver_class">com.mysql.jdbc.Driver/property>
<property name="connection.url">jdbc:mysql://localhost:3306/hibernate</property>
<property name="username">root</property>
<property name="password"></property>
<property name="connection.pool_size">1</property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hbm2ddl.auto">update</property>
<mapping class="org.hibernate.src.userDetails" />
</session-factory>
</hibernate-configuration>
I tried to change the version 3.0 to 4.0 as I am using hibernate version 4.3.6 but still its not working. please help me out.
This is my userDetails class..
package org.hibernate.src;
@Entity
public class userDetails {
@Id
private int userId ;
private String userName;
@Embedded
private Address address;
public Address getAddress() {
return address;
}
public void setAddress(Address address) {
this.address = address;
}
public int getUserId() {
return userId;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public void setUserId(int userId) {
this.userId = userId;
}
}
These jar files I have added to my project:
lib\jpa\hibernate-entitymanager-4.3.6.Final.jar
lib\required\antlr-2.7.7.jar
lib\required\dom4j-1.6.1.jar
lib\required\hibernate-commons-annotations-4.0.5.Final.jar
lib\required\hibernate-core-4.3.6.Final.jar
lib\required\hibernate-jpa-2.1-api-1.0.0.Final.jar
lib\required\jandex-1.1.0.Final.jar
lib\required\javassist-3.18.1-GA.jar
lib\required\jboss-logging-3.1.3.GA.jar
lib\required\jboss-logging-annotations-1.2.0.Beta1.jar
lib\required\jboss-transaction-api_1.2_spec-1.0.0.Final.jar
This is what I am getting while running the application
Oct 13, 2014 4:24:47 PM
org.hibernate.annotations.common.reflection.java.JavaReflectionManager <clinit>
INFO: HCANN000001: Hibernate Commons Annotations {4.0.5.Final}
Oct 13, 2014 4:24:47 PM org.hibernate.Version logVersion
INFO: HHH000412: Hibernate Core {4.3.6.Final}
Oct 13, 2014 4:24:47 PM org.hibernate.cfg.Environment <clinit>
INFO: HHH000206: hibernate.properties not found
Oct 13, 2014 4:24:47 PM org.hibernate.cfg.Environment buildBytecodeProvider
INFO: HHH000021: Bytecode provider name : javassist
Oct 13, 2014 4:24:47 PM org.hibernate.cfg.Configuration configure
INFO: HHH000043: Configuring from resource: /hibernate.cfg.xml
Oct 13, 2014 4:24:47 PM org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: HHH000040: Configuration resource: /hibernate.cfg.xml
Exception in thread "main" org.hibernate.HibernateException: Could not parse
configuration: /hibernate.cfg.xml
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:2163)
at org.hibernate.cfg.Configuration.configure(Configuration.java:2075)
at org.hibernate.cfg.Configuration.configure(Configuration.java:2054)
at org.hibernate.test.userTest.main(userTest.java:18)
Caused by: org.dom4j.DocumentException: Error on line 4 of document : Content is not
allowed in prolog. Nested exception: Content is not allowed in prolog.
at org.dom4j.io.SAXReader.read(SAXReader.java:482)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:2155)
... 3 more