0

我需要与 GWT ( Google ) 一起研究 hibernate 和 Springs。

这是我的休眠配置文件..

<hibernate-configuration>
    <session-factory>
        <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
        <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/test</property>
        <property name="hibernate.connection.username">root</property>

        <mapping class="com.AAA"  />

    </session-factory>
</hibernate-configuration>

这是模型类

@Entity
public class AAA {

    @Id@GeneratedValue(strategy=GenerationType.AUTO)
    private int id;
    private String Name;
    public int getId() {
        return id;
    }
    public void setId(int id) {
        this.id = id;
    }
    public String getName() {
        return Name;
    }
    public void setName(String name) {
        Name = name;
    }
}

这是我的主要课程

公共静态无效主要(字符串arg []){

    SessionFactory sessionFactory=new AnnotationConfiguration().configure().buildSessionFactory();
    Session hibernate_session = ((org.hibernate.SessionFactory) sessionFactory).openSession();
    hibernate_session.beginTransaction();

    System.out.println("Inside..");

    AAA pr = (AAA)hibernate_session.get(AAA.class,2);


    hibernate_session.getTransaction().commit();
    hibernate_session.close();

    System.out.println("Out sideee..");
}

这是不断出现的错误,即使`Asm.jar文件的不同版本发生了变化。

Exception in thread "main" java.lang.NoSuchMethodError: org.objectweb.asm.ClassWriter.<init>(Z)V
    at net.sf.cglib.core.DebuggingClassWriter.<init>(DebuggingClassWriter.java:47)
    at net.sf.cglib.core.DefaultGeneratorStrategy.getClassWriter(DefaultGeneratorStrategy.java:30)
    at net.sf.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:24)
    at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:216)
    at net.sf.cglib.core.KeyFactory$Generator.create(KeyFactory.java:145)
    at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:117)
    at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:108)
    at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:104)
    at net.sf.cglib.proxy.Enhancer.<clinit>(Enhancer.java:69)
    at org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.getProxyFactory(CGLIBLazyInitializer.java:107)
    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:1291)
    at com.Tesf.main(Tesf.java:13)

这些是我正在使用的以下主要罐子。

asm-3.1.jar
cglib-2.1.3.jar
hibernate3
spring.jar
hibernate-jpa-2.0-api-1.0.1.final.jar

如果我在动态 web 项目中使用这些 jars,一切都很好,但在 GWT webapplication 的情况下它不是......

请给出一些想法来实现它,

4

0 回答 0