0

I am getting error while creating simple hibernate application using oracle 10g

ERROR:- 
log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
Exception in thread "main" org.hibernate.HibernateException: Could not parse configuration: hibernate.cfg.xml
    at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1491)
    at org.hibernate.cfg.Configuration.configure(Configuration.java:1425)
    at hibernate.StoreData.main(StoreData.java:13)
Caused by: org.dom4j.DocumentException: Error on line 1 of document  : The processing instruction target matching "[xX][mM][lL]" is not allowed. Nested exception: The processing instruction target matching "[xX][mM][lL]" is not allowed.
    at org.dom4j.io.SAXReader.read(SAXReader.java:482)
    at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1481)
    ... 2 more

Mapping File:-

<?xml version='1.0' encoding='UTF-8'?>  
<!DOCTYPE hibernate-mapping PUBLIC  
 "-//Hibernate/Hibernate Mapping DTD 3.0//EN"  
 "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">  

 <hibernate-mapping>  
  <class name="hibernate.Employee" table="emp1000">  
    <id name="id">  
     <generator class="assigned"></generator>  
    </id>  

    <property name="firstName"></property>  
    <property name="lastName"></property>  

  </class>  

 </hibernate-mapping>  

Configuration file:-

<?xml version='1.0' encoding='UTF-8'?>  

<hibernate-configuration>  

    <session-factory>  
        <property name="hbm2ddl.auto">update</property>  
        <property name="dialect">org.hibernate.dialect.Oracle10gDialect</property>  
        <property name="connection.url">jdbc:oracle:thin:@localhost:1521:xe</property>  
        <property name="connection.username">hr</property>  
        <property name="connection.password">hr</property>  
        <property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>  

    <mapping resource="employee.hbm.xml"/>  
    </session-factory>  

</hibernate-configuration>  
azurefrog
  • 10,785
  • 7
  • 42
  • 56

1 Answers1

1

Could you check if there are there any blank spaces before in your xml config files?

see: Error: The processing instruction target matching "[xX][mM][lL]" is not allowed

Hope this helps,

Alberto

Community
  • 1
  • 1
Alberto Saito
  • 271
  • 1
  • 6
  • hii Alberto, Thanks for your suggestion but after googling i came to know this was happened due to hibernate mising jar files...after adding jar files its working fine now.. – Abhishek Singh Oct 07 '15 at 06:48