firesprite / memcached-session-manager

Automatically exported from code.google.com/p/memcached-session-manager
0 stars 0 forks source link

Kryo serializer HibernateCollectionsSerializerFactory is broken for Hibernate 4 #193

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Kryo serializer {{{d.j.w.m.s.kryo.HibernateCollectionsSerializerFactory}}} 
relies on Hibernate3's 
{{{org.hibernate.collection.AbstractPersistentCollection}}} which has been 
renamed into 
{{{org.hibernate.collection.internal.AbstractPersistentCollection}}} in 
Hibernate 4.

{{{
06-Jan-2014 17:43:48.975 SEVERE [http-bio-8706-exec-2] 
org.apache.coyote.http11.AbstractHttp11Processor.process Error processing 
request
 java.lang.NoClassDefFoundError: org/hibernate/collection/AbstractPersistentCollection
    at de.javakaffee.web.msm.serializer.kryo.HibernateCollectionsSerializerFactory.newSerializer(HibernateCollectionsSerializerFactory.java:41)
    at de.javakaffee.web.msm.serializer.kryo.KryoTranscoder.loadCustomSerializer(KryoTranscoder.java:227)
    at de.javakaffee.web.msm.serializer.kryo.KryoTranscoder.access$300(KryoTranscoder.java:79)
    at de.javakaffee.web.msm.serializer.kryo.KryoTranscoder$1.newSerializer(KryoTranscoder.java:133)
    at com.esotericsoftware.kryo.Kryo.handleUnregisteredClass(Kryo.java:329)
    at de.javakaffee.web.msm.serializer.kryo.KryoTranscoder$1.handleUnregisteredClass(KryoTranscoder.java:172)
    at com.esotericsoftware.kryo.Kryo.getRegisteredClass(Kryo.java:305)
    at com.esotericsoftware.kryo.Kryo.writeObject(Kryo.java:520)
    at com.esotericsoftware.kryo.ObjectBuffer.writeObject(ObjectBuffer.java:251)
    at de.javakaffee.web.msm.serializer.kryo.KryoTranscoder.serializeAttributes(KryoTranscoder.java:272)
    at de.javakaffee.web.msm.TranscoderService.serializeAttributes(TranscoderService.java:153)
    at de.javakaffee.web.msm.BackupSessionTask.serializeAttributes(BackupSessionTask.java:175)
    at de.javakaffee.web.msm.BackupSessionTask.call(BackupSessionTask.java:109)
    at de.javakaffee.web.msm.BackupSessionTask.call(BackupSessionTask.java:50)
    at de.javakaffee.web.msm.BackupSessionService$SynchronousExecutorService.submit(BackupSessionService.java:346)
    at de.javakaffee.web.msm.BackupSessionService.backupSession(BackupSessionService.java:205)
    at de.javakaffee.web.msm.MemcachedSessionService.backupSession(MemcachedSessionService.java:1076)
    at de.javakaffee.web.msm.RequestTrackingHostValve.backupSession(RequestTrackingHostValve.java:244)
    at de.javakaffee.web.msm.RequestTrackingHostValve.invoke(RequestTrackingHostValve.java:173)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
    at org.apache.catalina.valves.RemoteIpValve.invoke(RemoteIpValve.java:680)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1041)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:603)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: 
org.hibernate.collection.AbstractPersistentCollection
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 29 more
}}}

Original issue reported on code.google.com by clecl...@cloudbees.com on 6 Jan 2014 at 6:02

GoogleCodeExporter commented 9 years ago
Not sure what's the best solution for this.

In msm-kryo-serializer I cannot simply provide both 
HibernateCollectionsSerializerFactory (for hib3) and 
Hibernate4CollectionsSerializerFactory (for hib4) because it's not possible to 
add both dependencies in pom.xml - only the hib4 dependency would be used.

To provide both SerializerFactories out of the box I would have to add another 
maven module for just the Hibernate4CollectionsSerializerFactory.

As alternative solution you (or any other user using hib4) could write it's own 
Hibernate4CollectionsSerializerFactory by just copying the original 
HibernateCollectionsSerializerFactory and changing the import.
We could also add an appropriate documentation to the msm documentation.

We could also switch to hibernate 4 in msm-kryo-serializer and provide this 
documentation for hibernate 3 users.

What do you think?

Original comment by martin.grotzke on 7 Jan 2014 at 9:41

GoogleCodeExporter commented 9 years ago
Hello Martin,

I initially had the same idea as yours: we need 2 maven modules: 
msm-kryo-serializer-hibernate3 and msm-kryo-serializer-hibernate4.

And during the night I had the idea of using Java reflection and try :

* Hibernate 3: 
`Class.forname("org.hibernate.collection.AbstractPersistentCollection")` 
* then Hibernate 4: 
`Class.forname("org.hibernate.collection.AbstractPersistentCollection")`

I can propose a pull-request with this reflection thing.

Original comment by clecl...@cloudbees.com on 7 Jan 2014 at 9:47

GoogleCodeExporter commented 9 years ago
Sounds good, a PR would be great!

Original comment by martin.grotzke on 7 Jan 2014 at 10:01

GoogleCodeExporter commented 9 years ago
Here it is: https://github.com/magro/memcached-session-manager/pull/34

Original comment by clecl...@cloudbees.com on 9 Jan 2014 at 1:52

GoogleCodeExporter commented 9 years ago
Thanx, it's merged.

Original comment by martin.grotzke on 9 Jan 2014 at 8:48

GoogleCodeExporter commented 9 years ago

Original comment by martin.grotzke on 2 Feb 2014 at 2:09