aspose file tools*
The moose likes Object Relational Mapping and the fly likes hibernate-annotations error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "hibernate-annotations error" Watch "hibernate-annotations error" New topic
Author

hibernate-annotations error

Ra Carter
Ranch Hand

Joined: Jul 30, 2005
Posts: 96
I am trying to get started with hibernate-annotations but I keep getting this error:

Initial SessionFactory creation failed.java.lang.NoSuchMethodError: org.hibernate.cfg.Mappings.<init>(Ljava/util/Map;Ljava/util/Map;Ljava/util/Map;Ljava/util/Map;Ljava/util/Map;Ljava/util/Map;Ljava/util/Map;Ljava/util/List;Ljava/util/List;Lorg/hibernate/cfg/NamingStrategy;Ljava/util/Map;Ljava/util/Map;Ljava/util/Map;Ljava/util/List V

Does anyone know what it means? I'm using hibernate rc3 and hibernate-annotations 3.1 beta 5 by the way.
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17260
    
    6

"Racarter"-
Welcome to the JavaRanch! Please adjust your displayed name to meet the

JavaRanch Naming Policy.

You can change it

here.

Thanks! and welcome to the JavaRanch!

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17260
    
    6

I thought a NoSuchMethodError occurs when reflection tries to find a method but it isn't there, or like that.

I think it might be in your mappings file, can you post your mapping file for everyone to see.

Mark
Peter Laurinec
Ranch Hand

Joined: Sep 13, 2004
Posts: 52
Originally posted by racarter:
[QB]I am trying to get started with hibernate-annotations but I keep getting this error:

Initial SessionFactory creation failed.java.lang.NoSuchMethodError: org.hibernate.cfg.Mappings.<init>(Ljava/util/Map;Ljava/util/Map;Ljava/util/Map;Ljava/util/Map;Ljava/util/Map;Ljava/util/Map;Ljava/util/Map;Ljava/util/List;Ljava/util/List;Lorg/hibernate/cfg/NamingStrategy;Ljava/util/Map;Ljava/util/Map;Ljava/util/Map;Ljava/util/List V

Hmm, I thing that your annotations are wrong. Can you post here more information, first about your annotations and second about the error you are getting?


SCJP 1.5 (done, at last)<br /> <br />"If everything seems to be going well you have obviously overlooked something."
Fane Preda
Greenhorn

Joined: Dec 06, 2005
Posts: 5
Same error here. I'm using hibernate-3.1rc3, hibernate-entitymanager-3.1beta4, hibernate-annotations-3.1beta6 and getting the same error. I suspect there is some version mismatch since I traced this in the debugger and the explanation for the NoSuchMethodError is this:

AnnotationConfiguration calls ExtendedMappings's constructor, which calls



which is a 14 arguments constructor.

super in this case is Mappings which only has this constructor:


which takes 16 arguments, not 14! Since the versions I use are the latest available for download on hibernate.org I'm really out of ideas what to do about this.
[ December 06, 2005: Message edited by: Mike Wazowski ]
chris peacock
Greenhorn

Joined: Dec 06, 2005
Posts: 1
RC3 and annotations 5, 6 etc are not compatable,. You need to use hibernate RC2 which is compatable.
Joel McNary
Bartender

Joined: Aug 20, 2001
Posts: 1824

Mike Wazowski,
welcome to JavaRanch!

We're a friendly bunch here, but we do have one rule that we take seriously -- the JavaRanch Naming Policy

Basically we require display names to be two words: your first name, a space, then your last name. While we prefer you use your real name, we of corse cannot enforce it. However, obviously fictitious names are not allowed.

Please edit your profile and correct your display name.


Piscis Babelis est parvus, flavus, et hiridicus, et est probabiliter insolitissima raritas in toto mundo.
Fane Preda
Greenhorn

Joined: Dec 06, 2005
Posts: 5
Thanks Chris!
Dave Brosius
Greenhorn

Joined: Jan 10, 2006
Posts: 1
I am having a seemingly similar problem. Sorry if this is a hijack, but i think it's related. I get the error:

Caused by: java.lang.NoSuchFieldError: auxiliaryDatabaseObjects
at org.hibernate.cfg.AnnotationConfiguration.createExtendedMappings(AnnotationConfiguration.java:129)
at org.hibernate.cfg.AnnotationConfiguration.addPackage(AnnotationConfiguration.java:119)
at com.mebigfatguy.poolbook.common.HibernateUtil.<clinit>(HibernateUtil.java:19)

when getting the session. I just downloaded hibernate 3.1 and hibernate-annotations 3.1-beta 7, copied over all the jars, and copied the HibernateUtil class as shown in the docs. I added one entity bean, and specified it in the buildSessionFactory preamble.

Anyone have any hints?
Michael Kahn
Greenhorn

Joined: Feb 28, 2006
Posts: 2
I'm having the same issue,

I'm using:

- Hibernate core 3.1.1
- Annotations 3.1beta6
- manually configured AnnotationConfiguration with addAnnotatedClass calls

And the following stack trace:

(hibernate.HibernateUtil 46 ) Initial SessionFactory creation failed.
java.lang.NoSuchMethodError: org.hibernate.cfg.Mappings.<init>(Ljava/util/Map;Ljava/util/Map;Ljava/util/Map;Ljava/util/Map;Ljava/util/Map;Ljava/util/Map;Ljava/util/Map;Ljava/util/List;Ljava/util/List;Lorg/hibernate/cfg/NamingStrategy;Ljava/util/Map;Ljava/util/Map;Ljava/util/Map;Ljava/util/List V
at org.hibernate.cfg.ExtendedMappings.<init>(ExtendedMappings.java:50)
at org.hibernate.cfg.AnnotationConfiguration.createExtendedMappings(AnnotationConfiguration.java:126)
at org.hibernate.cfg.AnnotationConfiguration.processArtifactsOfType(AnnotationConfiguration.java:253)
at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:191)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1156)
at ca.yorkvilleu.registrar.persistence.hibernate.HibernateUtil.getSessionFactory(HibernateUtil.java:42)
at ca.yorkvilleu.registrar.persistence.hibernate.HibernateUtil.currentSession(HibernateUtil.java:59)
at ca.yorkvilleu.registrar.persistence.hibernate.HibernateEntityManagerProxy.getSession(HibernateEntityManagerProxy.java:30)
at ca.yorkvilleu.registrar.persistence.hibernate.HibernateEntityManagerProxy.persist(HibernateEntityManagerProxy.java:66)
at ca.yorkvilleu.registrar.dao.AbstractManager.save(AbstractManager.java:88)

... and so on ...

The hibernate JIRA doesn't seem to be much help - I could only find one bug report and a sort-of-surly response suggested it was a version mismatch with core - but in my case I'm using the combo suggested in the docs.

???
Michael Kahn
Greenhorn

Joined: Feb 28, 2006
Posts: 2
Never mind, 3.1.1 + 3.1beta8 works.
Eric Jo
Greenhorn

Joined: Apr 09, 2005
Posts: 4
I think this issue is addressed at http://forum.hibernate.org/viewtopic.php?p=2245097&sid=57ef81f69c29ed7484680f2bbab9752f

HTH
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: hibernate-annotations error