I'm pretty new with beanlib and I have a problem with HibernateTemplate, DtoCentricHibernate3Template and DetachedCriteria. I override createHibernateTemplate method in HibernateTemple.
java.lang.ClassCastException: $Proxy22 cannot be cast to org.hibernate.engine.SessionImplementor
at org.hibernate.criterion.DetachedCriteria.getExecutableCriteria(DetachedCriteria.java:52)
at my.company.server.persistance.dao.page.HibernatePageBuilder$1.doInHibernate(HibernatePageBuilder.java:61)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:372)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:338)
at my.company.server.persistance.dao.page.HibernatePageBuilder.createPage(HibernatePageBuilder.java:58)
at eu.b2i.telematic.rus.server.persistance.dao.TcuConnectionDAOImpl.findByTcu(TcuConnectionDAOImpl.java:45)
at my.company.server.persistance.dao.TcuConnectionDAOImplTest.testFindByTcu(TcuConnectionDAOImplTest.java:97)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at junit.framework.TestCase.runTest(TestCase.java:168)
at junit.framework.TestCase.runBare(TestCase.java:134)
at org.springframework.test.ConditionalTestCase.runBare(ConditionalTestCase.java:69)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:124)
at junit.framework.TestSuite.runTest(TestSuite.java:232)
at junit.framework.TestSuite.run(TestSuite.java:227)
at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:128)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Hibernate is trying to cast Session object, build by beanlib I think, into a SessionImplementor, and it failed.
Is there something to do if I want to use beanlib with Hibernate ?
Hibernate 3.2.4sp1
Spring 2.0.5
Beanlib 3.3.0beta5
Thanks
Damien
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I concur. When spring upgraded from 1.x to 2.x, changes were made in the createSessionProxy method which happens to have been overridden by Beanlib and therefore caused the bug since.
I've put the fixed in beanlib 3.3.0beta6 which is now available for download. Can you let me know if this fixes the problems ? Thanks.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
I'm pretty new with beanlib and I have a problem with HibernateTemplate, DtoCentricHibernate3Template and DetachedCriteria. I override createHibernateTemplate method in HibernateTemple.
java.lang.ClassCastException: $Proxy22 cannot be cast to org.hibernate.engine.SessionImplementor
at org.hibernate.criterion.DetachedCriteria.getExecutableCriteria(DetachedCriteria.java:52)
at my.company.server.persistance.dao.page.HibernatePageBuilder$1.doInHibernate(HibernatePageBuilder.java:61)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:372)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:338)
at my.company.server.persistance.dao.page.HibernatePageBuilder.createPage(HibernatePageBuilder.java:58)
at eu.b2i.telematic.rus.server.persistance.dao.TcuConnectionDAOImpl.findByTcu(TcuConnectionDAOImpl.java:45)
at my.company.server.persistance.dao.TcuConnectionDAOImplTest.testFindByTcu(TcuConnectionDAOImplTest.java:97)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at junit.framework.TestCase.runTest(TestCase.java:168)
at junit.framework.TestCase.runBare(TestCase.java:134)
at org.springframework.test.ConditionalTestCase.runBare(ConditionalTestCase.java:69)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:124)
at junit.framework.TestSuite.runTest(TestSuite.java:232)
at junit.framework.TestSuite.run(TestSuite.java:227)
at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:128)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Hibernate is trying to cast Session object, build by beanlib I think, into a SessionImplementor, and it failed.
Is there something to do if I want to use beanlib with Hibernate ?
Hibernate 3.2.4sp1
Spring 2.0.5
Beanlib 3.3.0beta5
Thanks
Damien
I found the problem, in DtoCentricHibernate3Template, line 267 in beanlib 3.3.0beta5
When you look at original code in HibernateTemplate, sometimes, SessionImplementor interface has to be used
protected Session createSessionProxy(Session session) {
Class[] sessionIfcs = null;
if (session instanceof SessionImplementor) {
sessionIfcs = new Class[] {Session.class, SessionImplementor.class};
}
else {
sessionIfcs = new Class[] {Session.class};
}
return (Session) Proxy.newProxyInstance(
getClass().getClassLoader(), sessionIfcs,
new CloseSuppressingInvocationHandler(session));
}
I concur. When spring upgraded from 1.x to 2.x, changes were made in the createSessionProxy method which happens to have been overridden by Beanlib and therefore caused the bug since.
I've put the fixed in beanlib 3.3.0beta6 which is now available for download. Can you let me know if this fixes the problems ? Thanks.
It works now on a specific subset of tests.
I need to wait for jars availability on central maven repository to do more tests.
Thanks
Damien
You can vote for the maven propagation if you'd like:
http://jira.codehaus.org/browse/MAVENUPLOAD-1590
Thank you !
Damien
It's there now :)
http://repo1.maven.org/maven2/net/sf/beanlib/beanlib/3.3.0beta6/
Thanks for reporting this. Fix is on it's way. Stay tuned.