-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: Invalid mapping document. No grammar found
PostPosted: Mon May 11, 2009 4:48 pm 
Newbie

Joined: Fri May 08, 2009 6:32 am
Posts: 5
Who knows what could be the problem with this mapping file?

Code:
<?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="test.Message" table="messages">
      <id name="id" column="id" type="long">
         <generator class="native"/>
      </id>
      <property name="text" type="string" />
   </class>
</hibernate-mapping>


There are no problems with config file. Here it is:
Code:
<?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.connection.username">root</property>
    <property name="hibernate.connection.password">free</property>
    <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
    <property name="hibernate.connection.url">jdbc:mysql://localhost/test</property>
    <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
    <property name="hibernate.show_sql">true</property>
    <mapping resource="test/Message.hbm.xml"/>
  </session-factory>
</hibernate-configuration>


And there is my class (in the same package with mapping file):
Code:
package test;

public class Message {

   private int id;
   private String text;

   public Message() {
   }

   public int getId() {
      return id;
   }

   public void setId(int id) {
      this.id = id;
   }

   public String getText() {
      return text;
   }

   public void setText(String text) {
      this.text = text;
   }
}


So, when i try to run a public static void main() and just to create a SessionFactory, i get next error:
Code:
SEVERE: Error parsing XML: XML InputStream(3) Document is invalid: no grammar found.


Top
 Profile  
 
 Post subject: Re: Invalid mapping document. No grammar found
PostPosted: Tue May 12, 2009 4:53 am 
Newbie

Joined: Tue May 12, 2009 2:53 am
Posts: 8
try by replacing the
<?xml version="1.0" encoding="UTF-8"?>
with the
<?xml version='1.0' encoding='UTF-8'?>
in the config file..

but i'm not sure..


Top
 Profile  
 
 Post subject: Re: Invalid mapping document. No grammar found
PostPosted: Tue May 12, 2009 7:13 am 
Newbie

Joined: Fri May 08, 2009 6:32 am
Posts: 5
Woow, thanks! It seems to work now. But, what are double quotes a problem? As well, as i know they are not restricted in XML syntax. Is it an issue of Hibernate?


Top
 Profile  
 
 Post subject: Re: Invalid mapping document. No grammar found
PostPosted: Tue May 12, 2009 9:24 am 
Newbie

Joined: Tue May 12, 2009 2:53 am
Posts: 8
i don't know the reason. but i faced this problem and i found that this is the work around for the problem.
If you found the reason , let me know.


Top
 Profile  
 
 Post subject: Re: Invalid mapping document. No grammar found
PostPosted: Tue May 12, 2009 9:24 am 
Newbie

Joined: Tue May 12, 2009 2:53 am
Posts: 8
i don't know the reason. but i faced this problem and i found that this is the work around for the problem.
If you found the reason , let me know.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.