Exception in GWT Dev Mode + Spring 3.1 + Hibernate 4.0.1

纵饮孤独 提交于 2019-11-28 08:38:16
Matt G

This issue is fixed in Hibernate 4.1.4.


I had the same problem, and it seems to be related to the Jetty classloader (the GWT plugin uses Jetty for hosted mode), the GWT plugin and Hibernate (although it apparently crops up with other libraries as well).

It's similar to the bug mentioned here Hibernate Bug Report but in our cases we're running it via the GWT plugin and it causes a ClassCastException for the ConnectionProvider.

The fix mentioned in the bug report should fix that particular problem.

For org.hibernate.service.classloading.internalClassLoaderServiceImpl set the parent to null via the constructor:

this.classClassLoader = new ClassLoader(null) {
        @Override
        protected Class<?> findClass(String name) throws ClassNotFoundException {
            for ( ClassLoader loader : classLoadingClassLoaders ) {
                try {
                    return loader.loadClass( name );
                }
                catch (Exception ignore) {
                }
            }
            throw new ClassNotFoundException( "Could not load requested class : " + name );
        }
};

remove ejb3-persistence.jar in the /lib directory if already there; it conflicts with hibernate-jpa-2.0-api-1.0.1.Final.jar in hibernate 4. That worked for me after having this issue, I achieved to host a GWT, Hibernate 4, Spring 3.1.1 app on Openshift environment https://openshift.redhat.com/app/

I think you don't need to set <provider>org.hibernate.ejb.HibernatePersistence</provider> in persistence.xml. Check the docs.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!