-->
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.  [ 2 posts ] 
Author Message
 Post subject: Could not parse mapping document from resource
PostPosted: Tue Jul 24, 2007 6:49 am 
Newbie

Joined: Mon Jul 23, 2007 9:36 am
Posts: 2
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:3.0

Mapping documents:profile.hbm.xml

Code between sessionFactory.openSession() and session.close():

Code:
Session session = null;
      
       try{
         
         SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
          session =sessionFactory.openSession();
          
          
          Transaction t = session.beginTransaction();
          System.out.println("Inserting Record");
           Profile regUser = new Profile();
           String temp=getUserName();          
           regUser.setUserName(temp);          
           regUser.setPassword(getPassword());
           regUser.setDOB(getDOB());
           regUser.setAddress(getAddress());
           regUser.setEmailId(getEmailId());
           regUser.setNickname(getNickname());
           regUser.setUserStatus("active");          
          
           session.save(regUser);
           t.commit();
           System.out.println("Done");          
          
       }
       catch(Exception e)
       {
         System.out.println(e.getMessage());
       }
       finally
       {
         // Actual contact insertion will happen at this step
         session.flush();
         session.close();
        
       }[/b]

[b]Full stack trace of any exception that occurs:could not parse mapping document from resource profile.hbm.xml


Name and version of the database you are using:MySQL 5.0

The generated SQL (show_sql=true):its not getting generated.Before opening session it is giving this exception

POJO class is :

Code:
package buddylist;

import java.util.Date;

public class Profile {
   
   private long userId;
   private String userName;
   private Date DOB;
   private String address;
   private String emailId;
   private String nickname;
   private String userStatus;
   private String password;
   
   
   public String getAddress() {
      return address;
   }
   public void setAddress(String address) {
      this.address = address;
   }
   public Date getDOB() {
      return DOB;
   }
   public void setDOB(Date dob) {
      DOB = dob;
   }
   public String getEmailId() {
      return emailId;
   }
   public void setEmailId(String emailId) {
      this.emailId = emailId;
   }
   public String getNickname() {
      return nickname;
   }
   public void setNickname(String nickname) {
      this.nickname = nickname;
   }
   public String getPassword() {
      return password;
   }
   public void setPassword(String password) {
      this.password = password;
   }
   public long getUserId() {
      return userId;
   }
   public void setUserId(long userId) {
      this.userId = userId;
   }
   public String getUserName() {
      return userName;
   }
   public void setUserName(String userName) {
      this.userName = userName;
   }
   public String getUserStatus() {
      return userStatus;
   }
   public void setUserStatus(String userStatus) {
      this.userStatus = userStatus;
   }
   

}


profile.hbm.xml

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

<hibernate-mapping>
  <class name="buddylist.Profile" table="profile">
   <id name="userId" type="long" column="UserId" >
   <generator class="increment"/>
  </id>

  <property name="username" column="UserName"/>

  <property name="password" column="Password"/>
 
  <property name="DOB" type="timestamp" column="DOB"/>

  <property name="address" column="Address"/>

  <property name="emailId" column="Email_id"/>
 
  <property name="nickname" column="Nickname"/>
 
  <property name="userStatus" column="User_status"/>
 
</class>
</hibernate-mapping>

i cant find any mistake. Plz help me.


[/i]


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 10, 2007 1:48 pm 
Newbie

Joined: Wed Jun 27, 2007 2:09 pm
Posts: 2
* Have you check the hibernate3.jar dependencies?

* Are you sure Hibernate can find the mapping file? Hibernate uses the ContextClassLoader of the current thread to find such resources. Unless you have implemented you custom classloader, your mapping file should be in the classpath.

* Wich is the maximal mapping file that hibernate can parse?

Please send the stacktrace and the maximal mapping file that hibernate can parse (just simply remove tags one by one until you get no error in hibernate).


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.