4 Replies Latest reply on Aug 29, 2006 3:40 PM by maxandersen

    Cache-related error creating SessionFactory in Hibernate Con

    dserodio

      I'm using Eclipse 3.2, with Hibernate Tools beta7.

      I created a "hibernate.cfg.xml" using the Eclipse Wizard, but when I try to open the SessionFactory in Hibernate Console, I get:

      org.hibernate.HibernateException: Could not instantiate cache implementation
       at org.hibernate.cache.CacheFactory.createCache(CacheFactory.java:64)
       at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:214)
       at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1218)
       at org.hibernate.console.ConsoleConfiguration$2.execute(ConsoleConfiguration.java:282)
       at org.hibernate.console.execution.DefaultExecutionContext.execute(DefaultExecutionContext.java:56)
       at org.hibernate.console.ConsoleConfiguration.execute(ConsoleConfiguration.java:85)
       at org.hibernate.console.ConsoleConfiguration.buildSessionFactory(ConsoleConfiguration.java:277)
       at org.hibernate.eclipse.console.workbench.LazySessionFactoryAdapter.getChildren(LazySessionFactoryAdapter.java:41)
       at org.hibernate.eclipse.console.workbench.BasicWorkbenchAdapter.getChildren(BasicWorkbenchAdapter.java:88)
       at org.hibernate.eclipse.console.workbench.BasicWorkbenchAdapter.fetchDeferredChildren(BasicWorkbenchAdapter.java:94)
       at org.eclipse.ui.progress.DeferredTreeContentManager$1.run(DeferredTreeContentManager.java:207)
       at org.eclipse.core.internal.jobs.Worker.run(Worker.java:58)
      Caused by: org.hibernate.cache.NoCachingEnabledException: Second-level cache is not enabled for usage [hibernate.cache.use_second_level_cache | hibernate.cache.use_query_cache]
       at org.hibernate.cache.NoCacheProvider.buildCache(NoCacheProvider.java:21)
       at org.hibernate.cache.CacheFactory.createCache(CacheFactory.java:61)
       ... 11 more


      I added the suggested settings to the hibernate.cfg.xml file, but I still get the same error. My cfg file is:
      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE hibernate-configuration PUBLIC
       "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
       "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
      <hibernate-configuration>
       <session-factory name="Console">
       <property name="hibernate.connection.driver_class">org.hsqldb.jdbcDriver</property>
       <property name="hibernate.connection.url">jdbc:hsqldb:bd/nfe</property>
       <property name="hibernate.connection.username">sa</property>
       <property name="hibernate.dialect">org.hibernate.dialect.HSQLDialect</property>
       <property name="hibernate.cache.provider_class">org.hibernate.cache.HashtableCacheProvider</property>
       <property name="hibernate.cache.use_second_level_cache">true</property>
       <property name="hibernate.cache.use_query_cache">true</property>
       </session-factory>
      </hibernate-configuration>
      


        • 1. Re: Cache-related error creating SessionFactory in Hibernate
          maxandersen

          does it change anything if you restart eclipse ?

          • 2. Re: Cache-related error creating SessionFactory in Hibernate
            dserodio

             

            "max.andersen@jboss.com" wrote:
            does it change anything if you restart eclipse ?

            I restarted Eclipse, and it worked the first time I tried to open the SessionFactory. Then, I ran a HQL query, and it threw an error, complaining that the table didn't exist.
            So I edited the hibernate.cfg.xml file, correcting the database URL, and next time I tried to open the SessionFactory, I got:
            net.sf.cglib.core.CodeGenerationException: java.lang.reflect.InvocationTargetException-->null
             at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:237)
             at net.sf.cglib.proxy.Enhancer.createHelper(Enhancer.java:377)
             at net.sf.cglib.proxy.Enhancer.createClass(Enhancer.java:317)
             at org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.getProxyFactory(CGLIBLazyInitializer.java:121)
             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:266)
             at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:422)
             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 org.hibernate.console.ConsoleConfiguration$2.execute(ConsoleConfiguration.java:282)
             at org.hibernate.console.execution.DefaultExecutionContext.execute(DefaultExecutionContext.java:56)
             at org.hibernate.console.ConsoleConfiguration.execute(ConsoleConfiguration.java:85)
             at org.hibernate.console.ConsoleConfiguration.buildSessionFactory(ConsoleConfiguration.java:277)
             at org.hibernate.eclipse.console.workbench.LazySessionFactoryAdapter.getChildren(LazySessionFactoryAdapter.java:41)
             at org.hibernate.eclipse.console.workbench.BasicWorkbenchAdapter.getChildren(BasicWorkbenchAdapter.java:88)
             at org.hibernate.eclipse.console.workbench.BasicWorkbenchAdapter.fetchDeferredChildren(BasicWorkbenchAdapter.java:94)
             at org.eclipse.ui.progress.DeferredTreeContentManager$1.run(DeferredTreeContentManager.java:207)
             at org.eclipse.core.internal.jobs.Worker.run(Worker.java:58)
            Caused by: java.lang.reflect.InvocationTargetException
             at jrockit.reflect.VirtualNativeMethodInvoker.invoke(Ljava.lang.Object;[Ljava.lang.Object;)Ljava.lang.Object;(Unknown Source)
             at java.lang.reflect.Method.invoke(Ljava.lang.Object;[Ljava.lang.Object;I)Ljava.lang.Object;(Unknown Source)
             at net.sf.cglib.core.ReflectUtils.defineClass(ReflectUtils.java:384)
             at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:219)
             ... 23 more
            Caused by: java.lang.NoClassDefFoundError: org/hibernate/proxy/HibernateProxy$$EnhancerByCGLIB$$a9ec73d2_2 : br/pucsp/apt/turgon/cheque/Cheque
             at java.lang.ClassLoader.defineClass(Ljava.lang.String;[BIILjava.security.ProtectionDomain;)Ljava.lang.Class;(Unknown Source)
             at jrockit.reflect.VirtualNativeMethodInvoker.invoke(Ljava.lang.Object;[Ljava.lang.Object;)Ljava.lang.Object;(Unknown Source)
             at java.lang.reflect.Method.invoke(Ljava.lang.Object;[Ljava.lang.Object;I)Ljava.lang.Object;(Unknown Source)
             at net.sf.cglib.core.ReflectUtils.defineClass(ReflectUtils.java:384)
             at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:219)
             at net.sf.cglib.proxy.Enhancer.createHelper(Enhancer.java:377)
             at net.sf.cglib.proxy.Enhancer.createClass(Enhancer.java:317)
             at org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.getProxyFactory(CGLIBLazyInitializer.java:121)
             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:266)
             at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:422)
             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 org.hibernate.console.ConsoleConfiguration$2.execute(ConsoleConfiguration.java:282)
             at org.hibernate.console.execution.DefaultExecutionContext.execute(DefaultExecutionContext.java:56)
             at org.hibernate.console.ConsoleConfiguration.execute(ConsoleConfiguration.java:85)
             at org.hibernate.console.ConsoleConfiguration.buildSessionFactory(ConsoleConfiguration.java:277)
             at org.hibernate.eclipse.console.workbench.LazySessionFactoryAdapter.getChildren(LazySessionFactoryAdapter.java:41)
             at org.hibernate.eclipse.console.workbench.BasicWorkbenchAdapter.getChildren(BasicWorkbenchAdapter.java:88)
             at org.hibernate.eclipse.console.workbench.BasicWorkbenchAdapter.fetchDeferredChildren(BasicWorkbenchAdapter.java:94)
             at org.eclipse.ui.progress.DeferredTreeContentManager$1.run(DeferredTreeContentManager.java:207)
            


            • 3. Re: Cache-related error creating SessionFactory in Hibernate
              dserodio

              I'd restarted Eclipse, and this (second) problem was not fixed. I disabled "Build Project Automatically", "Project > Clean"'ed it, and restarted Eclipse again, and now it seems to work.

              • 4. Re: Cache-related error creating SessionFactory in Hibernate
                maxandersen

                i just "love" eclipse classloading...somehow it gets messed up.

                maybe we have an exception leak somewhere.