-->
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: NoSuchMethodError: AnnotationConfiguration.getReflectionMana
PostPosted: Sat Sep 29, 2007 5:25 am 
Beginner
Beginner

Joined: Tue May 11, 2004 12:20 am
Posts: 33
Hi,

I'm trying to use Hibernate throught the JPA standard (EntityManager).
It's a very basic example - using Java SE , default mapping, no relationships.

I get the following exception:
Code:
Exception in thread "main" java.lang.NoSuchMethodError: org.hibernate.cfg.AnnotationConfiguration.getReflectionManager()Lorg/hibernate/annotations/common/reflection/ReflectionManager;
   at org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:152)
   at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:888)
   at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:186)
   at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:246)
   at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:120)
   at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:51)
   at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:33)
   at company.EmpTest1.main(EmpTest1.java:27)



I tried running "javap" on your jar classes, and if I'm not mistaken the problem might be that method AnnotationConfiguration.getReflectionManager() actually return a result of type "org.hibernate.reflection.ReflectionManager", while EventListenerConfigurator.configure() assumes it returns "org.hibernate.annotations.common.reflection.ReflectionManager".

Could you please tell how to solve this?
Thanks very much :)

Additional details, just in case:

1. My classpath contains the following (downloaded today from your site):
Code:
- hibernate-3.2.5.ga  (main jar + all jars from the 'lib' directory of your zipped distribution)
- hibernate-annotations-3.2.1.GA (ditto)
- hibernate-entitymanager-3.3.1.GA (ditto)


2. My "META-INF/persistence.xml":
Code:
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
   version="1.0">
   <persistence-unit name="unit1" transaction-type="RESOURCE_LOCAL">
      <provider>org.hibernate.ejb.HibernatePersistence</provider>
       <class>company.Employee</class>
       <properties>
           <property name="hibernate.connection.driver_class"    value="com.mysql.jdbc.Driver"/>
           <property name="hibernate.connection.url"             value="mysql://localhost:3306/test"/>
           <property name="hibernate.connection.username"        value="myUser"/>
           <property name="hibernate.connection.password"        value=""/>
           <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5Dialect"/>
           <property name="hibernate.max_fetch_depth" value="3"/>
       </properties>       
   </persistence-unit>
</persistence>



3. My code:
Code:

// The entity:
package company;
@Entity
public class Employee {
    @Id
    private int id;
    private String name;
    ...
}

// The main method:
public static void main(Stringp[] args) throws Exception{
   EntityManagerFactory emf= Persistence.createEntityManagerFactor("unit1");
   EntityManager em= emFact.createEntityManager();
   Employee emp=new Employee(22, "john");
   em.getTransaction().begin();
   em.persist(emp);
   em.getTransaction().commit();
}




Thanks.


Top
 Profile  
 
 Post subject: Sorry, problem solved: required newer annotations jar
PostPosted: Sat Sep 29, 2007 5:40 am 
Beginner
Beginner

Joined: Tue May 11, 2004 12:20 am
Posts: 33
Sorry, I've just noticed the 'Compatibility Matrix' in your download page,
which helped solve the problem.
Turns out I needed to upgrate to a newer version of hibernate annotations (3.3.0 GA).

Thanks anyway.
I'm hoping at least this might help others who happen to run into a similar problem.


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.