-->
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: Using AnnotationConfiguration results in NoSuchMethodError
PostPosted: Sun Nov 26, 2006 3:18 pm 
Newbie

Joined: Sun Sep 11, 2005 3:28 am
Posts: 8
I'm failing miserablly to get hiberate to work with EJB3 annotations. When I attempt to create the session factory, I get a NoSuchMethodError. I've searched and searched, but can't find a solution. Some users have reported a similar problem using incompatible RC jars, but in this case I'm using 3.2.0ga for both hibernate.jar and hibernate-annotations.jar.

Any help greatly appreciated.

Test Case
Code:
public void testAnnotationConfigurationProblem()
{
   Configuration cfg = new AnnotationConfiguration()
      .addAnnotatedClass(com.myapp.domain.Test.class)
      .setProperty("hibernate.dialect", "org.hibernate.dialect.HSQLDialect")
      .setProperty("hibernate.connection.driver_class", "org.hsqldb.jdbcDriver")
      .setProperty("hibernate.connection.url", "jdbc:hsqldb:TestDb");
               
   SessionFactory sf = cfg.buildSessionFactory();
}


Entity
Code:
package com.myapp.domain;

import java.io.Serializable;

import javax.persistence.Entity;
import javax.persistence.Id;

@Entity
public class Test implements Serializable {
   
    private static final long serialVersionUID = 1L;
   
    Long id;

    @Id
    public Long getId() { return id; }

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


Stack Trace
Code:
java.lang.NoSuchMethodError: org.objectweb.asm.ClassVisitor.visit(ILjava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;)V
   at net.sf.cglib.core.ClassEmitter.begin_class(ClassEmitter.java:101)
   at net.sf.cglib.core.KeyFactory$Generator.generateClass(KeyFactory.java:205)
   at net.sf.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:63)
   at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:190)
   at net.sf.cglib.core.KeyFactory$Generator.create(KeyFactory.java:177)
   at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:149)
   at net.sf.cglib.proxy.Enhancer.<clinit>(Enhancer.java:96)
   at org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.getProxyFactory(CGLIBLazyInitializer.java:111)
   at org.hibernate.proxy.pojo.cglib.CGLIBProxyFactory.postInstantiate(CGLIBProxyFactory.java:43)
   at org.hibernate.tuple.entity.PojoEntityTuplizer.buildProxyFactory(PojoEntityTuplizer.java:162)
   at org.hibernate.tuple.entity.AbstractEntityTuplizer.<init>(AbstractEntityTuplizer.java:135)
   at org.hibernate.tuple.entity.PojoEntityTuplizer.<init>(PojoEntityTuplizer.java:55)
   at org.hibernate.tuple.entity.EntityEntityModeToTuplizerMapping.<init>(EntityEntityModeToTuplizerMapping.java:56)
   at org.hibernate.tuple.entity.EntityMetamodel.<init>(EntityMetamodel.java:269)
   at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:425)
   at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:109)
   at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55)
   at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:226)
   at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1218)
   at com.myapp.domain.EntityTest.testAnnotationConfigurationProblem(EntityTest.java:50)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
...


Top
 Profile  
 
 Post subject: Typical...
PostPosted: Sun Nov 26, 2006 4:50 pm 
Newbie

Joined: Sun Sep 11, 2005 3:28 am
Posts: 8
10 minutes after posting I found the answer...

Had started using the maven eclipse plugin, which handily imported cglib-2.1.3 for hibernate but also cglib-full-2.0 required by jmock-cglib. Updating my pom as follows fixed the problem.

Code:
<dependency>
   <groupId>jmock</groupId>
   <artifactId>jmock-cglib</artifactId>
   <version>1.1.0</version>
   <scope>test</scope>
   <exclusions>
      <exclusion>
         <groupId>cglib</groupId>
         <artifactId>cglib-full</artifactId>
      </exclusion>
   </exclusions>         
</dependency>


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.