Page 2 of 2 FirstFirst 12
Results 11 to 11 of 11

Thread: SessionFactory configuration problem

  1. #11
    Join Date
    May 2012
    Location
    Brazil
    Posts
    6

    Default

    Hey Marten, good morning!

    Ok ... so I got the right difference from classes to entities since the beginning. Good news!

    The fact is that my classes in 'muitobafao.model' are completely annotated (they are, in fact, entities). I pasted Comentario.java as an example class (as it is considerably -- 85% -- smaller than Usuario.java) so you can see how my classes are annotated. They all follow the same annotation style (I chose to annotate the fields).

    Why do you say I shouldn't be using HibernateTemplate? The book says exactly the opposite... because when I use HibernateDaoSupport it simplifies my code (and as a side effect makes it more dependable upon Spring).
    Would it be better for me to use SessionFactory directly and pass it as a constructor argument to my DAO classes?

    If I got it right ... you are saying I should proceed the way taught by this tutorial. Is it?

    Thanks again.



    ------------------

    EDIT:

    Well, I tried following that tutorial I posted above but when manually creating the SessionFactory (using the exact same piece of code provided in the website) the same exception happened:

    Code:
    Initial SessionFactory creation failed.java.lang.NoSuchMethodError: org.objectweb.asm.ClassWriter.<init>(I)V
    Exception in thread "main" java.lang.ExceptionInInitializerError
    	at muitobafao.util.HibernateUtil.<clinit>(HibernateUtil.java:21)
    	at muitobafao.util.Example1.main(Example1.java:21)
    Caused by: java.lang.NoSuchMethodError: org.objectweb.asm.ClassWriter.<init>(I)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:144)
    	at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:116)
    	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:117)
    	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:295)
    	at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:434)
    	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:1294)
    	at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:859)
    	at muitobafao.util.HibernateUtil.<clinit>(HibernateUtil.java:17)
    	... 1 more
    Java Result: 1
    I have already changed the libraries. And it didn't get fixed.
    Last edited by toffolo; May 10th, 2012 at 07:13 AM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •