nanlabs / logical-delete

Apache License 2.0
8 stars 8 forks source link

Conflict with Grails Searchable plugin, start-up error #4

Open vahidpaz opened 10 years ago

vahidpaz commented 10 years ago

My Grails app does not start-up if I have the Grails Searchable plugin enabled, version 0.6.6. Error:

2014-01-10 17:00:55,905 [localhost-startStop-1] ERROR context.GrailsContextLoader  - Error initializing the application: com.sun.proxy.$Proxy49 cannot be cast to org.hibernate.impl.SessionFactoryImpl
Message: com.sun.proxy.$Proxy49 cannot be cast to org.hibernate.impl.SessionFactoryImpl
    Line | Method
->>   95 | injectLifecycle in org.compass.gps.device.hibernate.lifecycle.DefaultHibernateEntityLifecycleInjector
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|     46 | injectLifecycle in org.compass.gps.device.hibernate.lifecycle.DefaultHibernateEntityCollectionLifecycleInjector
|    147 | doStart . . . . in org.compass.gps.device.hibernate.HibernateGpsDevice
|    124 | start           in org.compass.gps.device.AbstractGpsDevice
|     73 | start . . . . . in org.compass.gps.device.support.parallel.AbstractParallelGpsDevice
|    166 | start           in org.compass.gps.impl.AbstractCompassGps
|    149 | doCall . . . .  in SearchableGrailsPlugin$_closure3
|    262 | run             in java.util.concurrent.FutureTask
|   1145 | runWorker . . . in java.util.concurrent.ThreadPoolExecutor
|    615 | run             in java.util.concurrent.ThreadPoolExecutor$Worker
^    744 | run . . . . . . in java.lang.Thread

tags: compass, lucene

jalessandro commented 10 years ago

@vahidpaz I've installed both plugins, but I didn't see any errors when starting my app.

vahidpaz commented 10 years ago

@jalessandro That's strange because I just reproduced it again right now (more debug output below). I'm using Grails 2.3.6 and still at Searchable 0.6.6.

I temporarily went into Logical Delete and removed the dependency on hibernate-hijacker, and then I could successfully load both Searchable and Logical Delete in my Grails app. Obviously I had to modify DeleteHibernateFilterConfigurator.java temporarily so that it would not extend HibernateConfigPostProcessor, thus making Logical Delete unusable, but the point was to find out what's going on. So my conclusion is a conflict between Searchable and Hibernate Hijacker.

My error stack points out line 95. I think the code looks something like this: http://grepcode.com/file/repo1.maven.org/maven2/com.github.lhanson/compass/2.2.2-ldh/org/compass/gps/device/hibernate/lifecycle/DefaultHibernateEntityLifecycleInjector.java#95

It looks like Hijacker uses WrappedSessionFactoryBean.buildSessionFactory() to wrap the real factory with its own proxy, while Compass is expecting the SessionFactoryImpl concrete type.

Should we contact the Compass developers and see if they can use the org.hibernate.SessionFactory interface rather than a concrete type?

2014-03-04 18:19:04,825 [localhost-startStop-1] INFO  config.ConsumerAnnotationReader  - Subscribing hibernate.sessionCreated to deleteHibernateFilterEnabler, method enableDeleteHibernateFilter
| Error 2014-03-04 18:19:04,918 [localhost-startStop-1] ERROR context.GrailsContextLoader  - Error initializing the application: com.sun.proxy.$Proxy44 cannot be cast to org.hibernate.impl.SessionFactoryImpl
Message: com.sun.proxy.$Proxy44 cannot be cast to org.hibernate.impl.SessionFactoryImpl
    Line | Method
->>   95 | injectLifecycle in org.compass.gps.device.hibernate.lifecycle.DefaultHibernateEntityLifecycleInjector
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|     46 | injectLifecycle in org.compass.gps.device.hibernate.lifecycle.DefaultHibernateEntityCollectionLifecycleInjector
|    147 | doStart . . . . in org.compass.gps.device.hibernate.HibernateGpsDevice
|    124 | start           in org.compass.gps.device.AbstractGpsDevice
|     73 | start . . . . . in org.compass.gps.device.support.parallel.AbstractParallelGpsDevice
|    166 | start           in org.compass.gps.impl.AbstractCompassGps
|    151 | doCall . . . .  in SearchableGrailsPlugin$_closure3
|    262 | run             in java.util.concurrent.FutureTask
|   1145 | runWorker . . . in java.util.concurrent.ThreadPoolExecutor
|    615 | run             in java.util.concurrent.ThreadPoolExecutor$Worker
^    744 | run . . . . . . in java.lang.Thread
2014-03-04 18:19:04,952 [Thread-13] INFO  impl.DefaultCompass  - Closing Compass [default]
2014-03-04 18:19:04,958 [Thread-13] INFO  impl.DefaultCompass  - Closed Compass [default]
2014-03-04 18:19:05,069 [Thread-14] INFO  hibernate.WrappedSessionFactoryBean  - Closing Hibernate SessionFactory
carlosorrego commented 10 years ago

i get thwe same error in grails 2.4.2

luchovelez commented 9 years ago

Switching back to the:

runtime ":hibernate:3.6.10.17" and changing

cache.region.factory_class = 'net.sf.ehcache.hibernate.EhCacheRegionFactory' in the DataSource.groovy resolves the problem.