Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.ClassNotFoundException: org.hibernate.engine.spi.SharedSessionContractImplementor #134

Open
johnou opened this issue Oct 3, 2019 · 5 comments

Comments

@johnou
Copy link

johnou commented Oct 3, 2019

After updating to jackson-datatype-hibernate 2.9.7 (Hibernate 5.1.7 on the classpath) I found that PersistentCollectionSerializer cannot be instantiated when trying to register the module due to a cnfe..

import com.fasterxml.jackson.datatype.hibernate5.PersistentCollectionSerializer;

public class Main {

    public static void main(String[] args) {
        new PersistentCollectionSerializer(null, null, 0, null);
    }
}
Exception in thread "main" java.lang.NoClassDefFoundError: org/hibernate/engine/spi/SharedSessionContractImplementor
	at Main.main(Main.java:8)
Caused by: java.lang.ClassNotFoundException: org.hibernate.engine.spi.SharedSessionContractImplementor
	at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	... 1 more
@cowtowncoder
Copy link
Member

I think that there is fundamental incompatibility between various "minor" Hibernate versions, so that it is not possible for this module to work against 5.0, 5.1 AND 5.2. I forget what were the trade-offs, but I think this problem would go away with Hibernate 5.2 or higher.

@johnou
Copy link
Author

johnou commented Oct 3, 2019

@cowtowncoder what's peculiar is that I cannot see where org.hibernate.engine.spi.SharedSessionContractImplementor is referenced..

@cowtowncoder
Copy link
Member

Perhaps it is referenced indirectly... although that would be bit odd, would expect that not to happen without module somehow referencing it.

@johnou
Copy link
Author

johnou commented Oct 4, 2019

@cowtowncoder I was able to "fix" this by checking out the 2.9.7 tag and changing the Hibernate version to 5.1.17.Final and using that artifact. Only possible workaround I can think of is to introduce a new module for every major version eg. hibernate5 hibernate52 hibernate53

@cowtowncoder
Copy link
Member

Yes, I think that was the conclusion. One small thing that might be helpful would be to at least document which versions of Hibernate module is compatible with -- to me the least bad option would seem to be to try to support as many of the latest 5.x (5.4, 5.3, if possible 5.2....) as possible.

One critical short-coming is that this module does not have active maintainer. If there was one, that person could both figure out contraints and make decisions. Problem for me is that I will try to help as I can, but I do not use Hibernate myself and am not familiar with its internals (to the degree I could fully own this module). Module was added as a contribution, and is clearly useful, so I feel bad for it being bit of an oprhan.

So, if you or anyone else interested and passionate enough wanted to look into things, I would be happy to give more access and authority -- this would be great for users. And I think it is something that could be valuable for the new owner: doing important and quite visible OSS work that benefits many.
So far there are about half a dozen Jackson modules for which I am not the lead (or am not the only lead), and I'd love Hibernate datatype module to become one more.

That being said, I appreciate your reaching out and helping by sharing work-around you have found, additional information. That is helpful as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants