Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem in mapping hibernate class

 
sachin yadav
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,

i am getting " org.hibernate.MappingException: Could not read mappings from resource: src/emp.hbm.xml" error. below i am pasting .CFG as well as .hbm files. can somebody please help me out.



I have a class as Emp.java which is used for getter and setter and emp_loaded.java where i am creating a session and making transactions.
can somebody figure out what's the error.
 
Ghulam Rashid
Ranch Hand
Posts: 278
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Somehow, hibernate is not reading emp.hbm.xml file. Make sure emp.hbm.xml is in src folder and if you are running standalone then be sure that src folder is in the path env. You have to make src folder available at runtime.
 
sachin yadav
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

Thanks for your suggestion. I am using eclipse and i have checked everything is in place, but still i am facing the same issue. any other reason?
 
Ghulam Rashid
Ranch Hand
Posts: 278
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
May be this thread would be helpful -http://www.javaranch.com
 
sachin yadav
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello mr. Rashid,

I link provided by you was pretty useful and not my problem is resolved but now i am facing another error. i am not been able to connect to my MYSQL database. I think there is some problem in registering the driver. the error i got is:

Exception in thread "main" java.lang.NoClassDefFoundError: org/aspectj/lang/Signature
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:164)
at org.hibernate.connection.DriverManagerConnectionProvider.configure(DriverManagerConnectionProvider.java:57)
at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:124)
at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:56)
at org.hibernate.cfg.SettingsFactory.createConnectionProvider(SettingsFactory.java:366)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:60)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1881)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1174)
at src.Emp_loader.main(Emp_loader.java:21)


my cfg file is as follows:-



i have also tried to put 'mysql-connector-java-3.1.11' in my 'C:\eclipse\plugins' folder as well as i tried to include this as a jar in build path lib. but nothing positive comes out. can you suggest me something?
 
sachin yadav
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry for spell mistakes -- take "I link provided by you was pretty useful and not my problem is resolved but now i am facing another error" as "The link provided by you was pretty useful and now my problem is resolved but now i am facing another error"
 
Ghulam Rashid
Ranch Hand
Posts: 278
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No need to copy your jar under C:\eclipse\plugins folder. You have to add it in your eclipse project location. Java Build Path -> Libraries Tab Page -> Add External Jar and then provide the location of your jar ... thats all, you are all set.
 
sachin yadav
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
still the same error, what might be not in place?
 
Joy Mookerji
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pls see my post on Hibernate Configuration I have given my entire Code sample and Configuration file
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic