java.lang.ClassCastException: org.hibernate.ejb.EntityManagerImpl cannot be cast to org.hibernate.Session

Oracle Community | ziphyre | 8 years ago
tip
Click on the to mark the solution that helps you, Samebug will learn from it.
As a community member, you’ll be rewarded for you help.
  1. 0

    Cast Exception while trying to getDelegate() from EntityManager

    Oracle Community | 8 years ago | ziphyre
    java.lang.ClassCastException: org.hibernate.ejb.EntityManagerImpl cannot be cast to org.hibernate.Session

    Root Cause Analysis

    1. java.lang.ClassCastException

      org.hibernate.ejb.EntityManagerImpl cannot be cast to org.hibernate.Session

      at net.snodd.web.biz.CommentBean.getComments()
    2. net.snodd.web
      CommentBean.getComments
      1. net.snodd.web.biz.CommentBean.getComments(CommentBean.java:29)
      1 frame
    3. Java RT
      Method.invoke
      1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      3. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      4. java.lang.reflect.Method.invoke(Method.java:597)
      4 frames
    4. com.sun.enterprise
      EJBSecurityManager.runMethod
      1. com.sun.enterprise.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1011)
      1 frame
    5. Security Core Classes
      SecurityUtil.invoke
      1. com.sun.enterprise.security.SecurityUtil.invoke(SecurityUtil.java:175)
      1 frame
    6. Embedded GlassFish Web
      EJBObjectInvocationHandler.invoke
      1. com.sun.ejb.containers.BaseContainer.invokeTargetBeanMethod(BaseContainer.java:2920)
      2. com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:4011)
      3. com.sun.ejb.containers.EJBObjectInvocationHandler.invoke(EJBObjectInvocationHandler.java:203)
      3 frames