-
1. Re: org.jboss.seam.persistence.HibernateSessionProxy cannot be cast to org.hibernate.classic.Session
njrich28 Aug 25, 2010 4:51 PM (in response to dmaier)Try using
@In FullTextEntityManager entityManager;
If Hibernate Search is available on the classpath then Seam always wraps the EntityManager in a FullTextEntityManager before injecting it. FullTextEntityManager extends EntityManager so you can inject it as either.
-
2. Re: org.jboss.seam.persistence.HibernateSessionProxy cannot be cast to org.hibernate.classic.Session
boy18nj Aug 25, 2010 10:07 PM (in response to dmaier)Use this-
@In(create=true, required=true, value="fullTextEntityManager") FullTextEntityManager ftem ;
If you use ftem, seam will try inject the fullentitymanager with the following value
ftem
which does not exists. -
3. Re: org.jboss.seam.persistence.HibernateSessionProxy cannot be cast to org.hibernate.classic.Session
jfaath Oct 1, 2010 6:10 PM (in response to dmaier)I'm getting the same error and none of the solutions seems to work. The differences are:
- Using Tomcat 6
- Using the latest snapshot build of Hibernate Search. The reason being is this issue was just resolved:
http://opensource.atlassian.com/projects/hibernate/browse/HSEARCH-591- I am not using Hibernate Search annotations but instead am programmatically mapping the tables I want to index.
What mechanism does Seam use to
detect
Hibernate Search on the classpath? Could one of theses differences be the reason for the problem?Thanks,
Jeff
-
4. Re: org.jboss.seam.persistence.HibernateSessionProxy cannot be cast to org.hibernate.classic.Session
njrich28 Oct 1, 2010 6:44 PM (in response to dmaier)Seam uses the following mechanism in org.jboss.seam.persistence.HibernatePersistenceProvider to detect Hibernate Search on the classpath
try { Class.forName("org.hibernate.search.Version"); hibernateSearchPresent = true; } catch (Exception e) { log.debug("Hibernate Search not present", e); }
Just noticed that Dahn's post says
java.lang.ClassCastException: org.jboss.seam.persistence.HibernateSessionProxy cannot be cast to org.hibernate.classic.Session
If you've got exactly the same error then it may be worth checking the imports you've got in your code to make sure that your IDE hasn't put the wrong one in by mistake.
-
5. Re: org.jboss.seam.persistence.HibernateSessionProxy cannot be cast to org.hibernate.classic.Session
jfaath Oct 4, 2010 3:10 PM (in response to dmaier)I see the code in Seam where this is happening. I should have pointed out that I was using Seam 2.2.0.GA. The code in this version looks like this:
try { Class searchVersionClass = Class.forName("org.hibernate.search.Version"); Field versionField = searchVersionClass.getDeclaredField("VERSION"); version = (String) versionField.get(null); } catch (Exception e) { log.debug("no Hibernate Search, sorry :-(", e); }
Which produces this error:
13:45:34,796 DEBUG [HibernatePersistenceProvider] no Hibernate Search, sorry :-( java.lang.NoSuchFieldException: VERSION at java.lang.Class.getDeclaredField(Class.java:1882) at org.jboss.seam.persistence.HibernatePersistenceProvider.<clinit>(HibernatePersistenceProvider.java:61) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:513) at java.lang.Class.newInstance0(Class.java:355) at java.lang.Class.newInstance(Class.java:308) at org.jboss.seam.Component.instantiateJavaBean(Component.java:1438) at org.jboss.seam.Component.instantiate(Component.java:1359) at org.jboss.seam.Component.newInstance(Component.java:2122) at org.jboss.seam.Component.getInstance(Component.java:2021) at org.jboss.seam.Component.getInstance(Component.java:2000) at org.jboss.seam.Component.getInstance(Component.java:1994) at org.jboss.seam.Component.getInstance(Component.java:1967) at org.jboss.seam.Component.getInstance(Component.java:1962) at org.jboss.seam.persistence.PersistenceProvider.instance(PersistenceProvider.java:203) at org.jboss.seam.persistence.ManagedPersistenceContext.initEntityManager(ManagedPersistenceContext.java:79) at org.jboss.seam.persistence.ManagedPersistenceContext.getEntityManager(ManagedPersistenceContext.java:107) 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 org.jboss.seam.util.Reflections.invoke(Reflections.java:22) at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:144) at org.jboss.seam.Component.callComponentMethod(Component.java:2249) at org.jboss.seam.Component.unwrap(Component.java:2275) at org.jboss.seam.Component.getInstance(Component.java:2041) at org.jboss.seam.Component.getInstance(Component.java:1983) at org.jboss.seam.Component.getInstance(Component.java:1977) at org.jboss.seam.Component.getInstanceInAllNamespaces(Component.java:2349) at org.jboss.seam.Component.getValueToInject(Component.java:2301) at org.jboss.seam.Component.injectAttributes(Component.java:1736) at org.jboss.seam.Component.inject(Component.java:1554) at org.jboss.seam.core.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:61) at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68) at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:44) at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68) at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107) at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:185) at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:103) at com.cloudlogix.registry.config.SystemProperties_$$_javassist_seam_0.onCreate(SystemProperties_$$_javassist_seam_0.java) 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 org.jboss.seam.util.Reflections.invoke(Reflections.java:22) at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:144) at org.jboss.seam.Component.callComponentMethod(Component.java:2249) at org.jboss.seam.Component.callCreateMethod(Component.java:2172) at org.jboss.seam.Component.newInstance(Component.java:2132) at org.jboss.seam.contexts.Contexts.startup(Contexts.java:304) at org.jboss.seam.contexts.Contexts.startup(Contexts.java:296) at org.jboss.seam.contexts.Contexts.startup(Contexts.java:278) at org.jboss.seam.contexts.ServletLifecycle.endInitialization(ServletLifecycle.java:116) at org.jboss.seam.init.Initialization.init(Initialization.java:740) at org.jboss.seam.servlet.SeamListener.contextInitialized(SeamListener.java:36) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3843) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4342) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045) at org.apache.catalina.core.StandardHost.start(StandardHost.java:719) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443) at org.apache.catalina.core.StandardService.start(StandardService.java:516) at org.apache.catalina.core.StandardServer.start(StandardServer.java:710) at org.apache.catalina.startup.Catalina.start(Catalina.java:578) 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 org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Which makes me think I'm using incompatible versions of Seam and Hibernate Search. Is there a recommended Seam version to use keeping in mind that I need to use the latest snapshot of Hibernate Search?
-
6. Re: org.jboss.seam.persistence.HibernateSessionProxy cannot be cast to org.hibernate.classic.Session
bravocharlie.seam.signup.benny.me.uk Oct 15, 2010 12:55 PM (in response to dmaier)Just found this with Search 3.3.0Beta1 on Seam 2.2.1.CR1
To fix, I copied the whole HibernatePersistenceProvider class, changed precedence to APPLICATION and replaced the version check with:
String version = null; try { Class searchVersionClass = Class.forName("org.hibernate.search.Version"); Method versionMethod = searchVersionClass.getDeclaredMethod("getVersionString"); version = (String) versionMethod.invoke(null); }
Bit of a bodge, but seems to work!