8 Replies Latest reply on Mar 7, 2013 4:53 AM by Stephen Coy

    hibernate cast exception

    nasir naseem Newbie

      17:18:20,436 ERROR [org.jboss.seam.jsf.SeamPhaseListener] (http--127.0.0.1-8080-1) swallowing exception: java.lang.RuntimeException: could not proxy delegate

                at org.jboss.seam.persistence.HibernatePersistenceProvider.proxyDelegate(HibernatePersistenceProvider.java:173) [jboss-seam-2.3.0-20120313.053927-58.jar:2.3.0-SNAPSHOT]

                at org.jboss.seam.persistence.EntityManagerInvocationHandler.handleGetDelegate(EntityManagerInvocationHandler.java:81) [jboss-seam-2.3.0-20120313.053927-58.jar:2.3.0-SNAPSHOT]

                at org.jboss.seam.persistence.EntityManagerInvocationHandler.invoke(EntityManagerInvocationHandler.java:40) [jboss-seam-2.3.0-20120313.053927-58.jar:2.3.0-SNAPSHOT]

                at $Proxy58.getDelegate(Unknown Source)          at org.hibernate.search.jpa.impl.FullTextEntityManagerImpl.getDelegate(FullTextEntityManagerImpl.java:165) [hibernate-search-3.1.1.GA.jar:3.1.1.GA]

                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.6.0_33]

                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [rt.jar:1.6.0_33]

                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [rt.jar:1.6.0_33]

                at java.lang.reflect.Method.invoke(Method.java:597) [rt.jar:1.6.0_33]

                at org.jboss.seam.persistence.EntityManagerInvocationHandler.handleGetDelegate(EntityManagerInvocationHandler.java:81) [jboss-seam-2.3.0-20120313.053927-58.jar:2.3.0-SNAPSHOT]

                at org.jboss.seam.persistence.EntityManagerInvocationHandler.invoke(EntityManagerInvocationHandler.java:40) [jboss-seam-2.3.0-20120313.053927-58.jar:2.3.0-SNAPSHOT]

                at $Proxy59.getDelegate(Unknown Source)          at org.jboss.seam.persistence.HibernatePersistenceProvider.getSession(HibernatePersistenceProvider.java:410) [jboss-seam-2.3.0-20120313.053927-58.jar:2.3.0-SNAPSHOT]

                at org.jboss.seam.persistence.HibernatePersistenceProvider.setFlushModeManual(HibernatePersistenceProvider.java:182) [jboss-seam-2.3.0-20120313.053927-58.jar:2.3.0-SNAPSHOT]

                at org.jboss.seam.persistence.ManagedPersistenceContext.setEntityManagerFlushMode(ManagedPersistenceContext.java:332) [jboss-seam-2.3.0-20120313.053927-58.jar:2.3.0-SNAPSHOT]

                at org.jboss.seam.persistence.ManagedPersistenceContext.changeFlushMode(ManagedPersistenceContext.java:317) [jboss-seam-2.3.0-20120313.053927-58.jar:2.3.0-SNAPSHOT]

                at org.jboss.seam.persistence.PersistenceContexts.changeFlushModes(PersistenceContexts.java:125) [jboss-seam-2.3.0-20120313.053927-58.jar:2.3.0-SNAPSHOT]

                at org.jboss.seam.persistence.PersistenceContexts.changeFlushMode(PersistenceContexts.java:101) [jboss-seam-2.3.0-20120313.053927-58.jar:2.3.0-SNAPSHOT]

                at org.jboss.seam.persistence.HibernatePersistenceProvider.setRenderFlushMode(HibernatePersistenceProvider.java:193) [jboss-seam-2.3.0-20120313.053927-58.jar:2.3.0-SNAPSHOT]

                at org.jboss.seam.persistence.PersistenceContexts.beforeRender(PersistenceContexts.java:140) [jboss-seam-2.3.0-20120313.053927-58.jar:2.3.0-SNAPSHOT]

                at org.jboss.seam.jsf.SeamPhaseListener.beforeRenderResponse(SeamPhaseListener.java:495) [jboss-seam-2.3.0-20120313.053927-58.jar:2.3.0-SNAPSHOT]

                at org.jboss.seam.jsf.SeamPhaseListener.beforeServletPhase(SeamPhaseListener.java:147) [jboss-seam-2.3.0-20120313.053927-58.jar:2.3.0-SNAPSHOT]

                at org.jboss.seam.jsf.SeamPhaseListener.beforePhase(SeamPhaseListener.java:117) [jboss-seam-2.3.0-20120313.053927-58.jar:2.3.0-SNAPSHOT]

                at com.sun.faces.lifecycle.Phase.handleBeforePhase(Phase.java:214) [jsf-impl-1.2_15-jbossorg-2.jar:1.2_15.jbossorg-1-20111019-SNAPSHOT]

                at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:96) [jsf-impl-1.2_15-jbossorg-2.jar:1.2_15.jbossorg-1-20111019-SNAPSHOT]

                at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139) [jsf-impl-1.2_15-jbossorg-2.jar:1.2_15.jbossorg-1-20111019-SNAPSHOT]

                at javax.faces.webapp.FacesServlet.service(FacesServlet.java:266) [jsf-api-1.2_15-jbossorg-2.jar:1.2_15.jbossorg-1-20111019-SNAPSHOT]

                at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329) [jbossweb-7.0.13.Final.jar:]

                at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:]

                at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83) [jboss-seam-2.3.0-20120313.053927-58.jar:2.3.0-SNAPSHOT]

                at org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:40) [jboss-seam-2.3.0-20120313.053927-58.jar:2.3.0-SNAPSHOT]

                at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69) [jboss-seam-2.3.0-20120313.053927-58.jar:2.3.0-SNAPSHOT]

                at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:90) [jboss-seam-2.3.0-20120313.053927-58.jar:2.3.0-SNAPSHOT]

                at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69) [jboss-seam-2.3.0-20120313.053927-58.jar:2.3.0-SNAPSHOT]

                at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64) [jboss-seam-2.3.0-20120313.053927-58.jar:2.3.0-SNAPSHOT]

                at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69) [jboss-seam-2.3.0-20120313.053927-58.jar:2.3.0-SNAPSHOT]

                at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45) [jboss-seam-2.3.0-20120313.053927-58.jar:2.3.0-SNAPSHOT]

                at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69) [jboss-seam-2.3.0-20120313.053927-58.jar:2.3.0-SNAPSHOT]

                at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:206) [richfaces-impl.jar:3.3.3.Final]

                at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290) [richfaces-impl.jar:3.3.3.Final]

                at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:388) [richfaces-impl.jar:3.3.3.Final]

                at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:515) [richfaces-impl.jar:3.3.3.Final]

                at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:56) [jboss-seam-2.3.0-20120313.053927-58.jar:2.3.0-SNAPSHOT]

                at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69) [jboss-seam-2.3.0-20120313.053927-58.jar:2.3.0-SNAPSHOT]

                at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:60) [jboss-seam-2.3.0-20120313.053927-58.jar:2.3.0-SNAPSHOT]

                at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69) [jboss-seam-2.3.0-20120313.053927-58.jar:2.3.0-SNAPSHOT]

                at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158) [jboss-seam-2.3.0-20120313.053927-58.jar:2.3.0-SNAPSHOT]

                at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.13.Final.jar:]

                at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:]

                at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [jbossweb-7.0.13.Final.jar:]

                at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.13.Final.jar:]

                at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50) [jboss-as-jpa-7.1.1.Final.jar:7.1.1.Final]

                at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]

                at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155) [jbossweb-7.0.13.Final.jar:]

                at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.13.Final.jar:]

                at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.13.Final.jar:]

                at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368) [jbossweb-7.0.13.Final.jar:]

                at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.13.Final.jar:]

                at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671) [jbossweb-7.0.13.Final.jar:]

                at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930) [jbossweb-7.0.13.Final.jar:]

                at java.lang.Thread.run(Thread.java:662) [rt.jar:1.6.0_33]

      Caused by: java.lang.ClassCastException: org.eclipse.persistence.internal.jpa.EntityManagerImpl cannot be cast to org.hibernate.Session

                at org.jboss.seam.persistence.HibernatePersistenceProvider.proxyDelegate(HibernatePersistenceProvider.java:165) [jboss-seam-2.3.0-20120313.053927-58.jar:2.3.0-SNAPSHOT]

                ... 60 more

       

       

       

       

       

      i ma facing this error when tryin to add a simple jbpm process to a seam apllication

       

      jars added in my application are

       

      antlr-2.7.7.jar

      bsh-2.0b4.jar

      commons-beanutils.jar

      commons-digester.jar

      commons-validator-1.3.1.jar

      dom4j-1.6.1.jar

      eclipselink.jar

      hibernate-commons-annotations-3.1.0.GA.jar

      hibernate-search-3.1.1.GA.jar

      hibernate-validator.jar

      hibernate3.jar

      j2ee-1.4.jar

      javax.persistence_2.0.4.v201112161009.jar

      jboss-el-1.0_02.CR6.jar

      jboss-seam-2.3.0-20120313.053927-58.jar

      jboss-seam-debug.jar

      jboss-seam-ui.jar

      jbpm-jpdl-3.2.3.jar

      jsf-api.jar

      jsf-facelets.jar

      jsf-impl.jar

      jstl-api-1.2.jar

      jstl-impl-1.2.jar

      lucene-core-2.4.1.jar

      mongo-2.9.1.jar

      myfaces-api-2.0.3 .jar

      org.eclipse.persistence.nosql_2.4.0.v20120608-r11652.jar

      richfaces-api.jar

      richfaces-impl.jar

      richfaces-ui.jar

      slf4j-api.jar

      slf4j-log4j12.jar

      testng-5.5-jdk15.jar

      validation-api-1.0.0.GA.jar

        • 1. Re: hibernate cast exception
          Nicklas Karlsson Master

          Try taking out stuff marked with (*) 

          * antlr-2.7.7.jar

          * bsh-2.0b4.jar

          commons-beanutils.jar

          commons-digester.jar

          commons-validator-1.3.1.jar

          * dom4j-1.6.1.jar

          * eclipselink.jar

          * hibernate-commons-annotations-3.1.0.GA.jar

          * hibernate-search-3.1.1.GA.jar

          * hibernate-validator.jar

          * hibernate3.jar

          * j2ee-1.4.jar

          * javax.persistence_2.0.4.v201112161009.jar

          * jboss-el-1.0_02.CR6.jar

          jboss-seam-2.3.0-20120313.053927-58.jar

          jboss-seam-debug.jar

          jboss-seam-ui.jar

          jbpm-jpdl-3.2.3.jar

          * jsf-api.jar

          * jsf-facelets.jar

          * jsf-impl.jar

          * jstl-api-1.2.jar

          * jstl-impl-1.2.jar

          lucene-core-2.4.1.jar

          mongo-2.9.1.jar

          * myfaces-api-2.0.3 .jar

          org.eclipse.persistence.nosql_2.4.0.v20120608-r11652.jar

          richfaces-api.jar

          richfaces-impl.jar

          richfaces-ui.jar

          * slf4j-api.jar

          * slf4j-log4j12.jar

          * testng-5.5-jdk15.jar

          * validation-api-1.0.0.GA.jar

          • 2. Re: hibernate cast exception
            nasir naseem Newbie

            removing all the jars marked with (*) shows import javax.persistence.entitymanager cannot be resolved .

            • 3. Re: hibernate cast exception
              Nicklas Karlsson Master

              How are you building your project? Maven? You still need the EE API:s on the classpath but they should only be compile-time dependencies and not included in the final WAR.

              • 4. Re: hibernate cast exception
                nasir naseem Newbie

                i am creating a war using eclipse ...

                • 5. Re: hibernate cast exception
                  Stephen Coy Master

                  At a guess I'd say that org.eclipse.persistence.nosql_2.4.0.v20120608-r11652.jar contains a JPA implementation that the container has detected, as indicated by:

                   

                       Caused by: java.lang.ClassCastException: org.eclipse.persistence.internal.jpa.EntityManagerImpl cannot be cast to org.hibernate.Session

                   

                  Do you really need that? If so you should try specifying the provider explicitly in your persistence.xml file:

                   

                  {code:xml}<provider>org.hibernate.ejb.HibernatePersistence</provider>{code}

                   

                  ... and do what Nicklas suggested regarding jars too!

                  • 6. Re: hibernate cast exception
                    nasir naseem Newbie

                    My persistence .xml contains

                     

                     

                    <?xml version="1.0" encoding="UTF-8" ?>

                    <persistence xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

                            xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"

                            version="2.0" xmlns="http://java.sun.com/xml/ns/persistence">

                        <persistence-unit name="mongo" transaction-type="RESOURCE_LOCAL">

                          <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>

                         <!-- <provider>org.hibernate.ejb.HibernatePersistence</provider>-->

                            <class>com.acc.entity.User</class>

                             <class>com.acc.entity.Movie</class>

                              <class>com.acc.entity.Booking</class>

                            <validation-mode>NONE</validation-mode>

                             

                           

                            <properties>

                             <property name="eclipselink.target-server" value="JBoss"/>

                          

                             <property name="eclipselink.target-database" value="org.eclipse.persistence.nosql.adapters.mongo.MongoPlatform"/>

                                <property name="eclipselink.nosql.connection-spec" value="com.acc.dbconn.DBConnection"/>

                               

                                <property name="eclipselink.nosql.property.mongo.port" value="27017"/>

                                <property name="eclipselink.nosql.property.mongo.host" value="localhost"/>

                                <property name="eclipselink.nosql.property.mongo.db" value="mydb"/>

                                <!-- <property name="eclipselink.nosql.property.mongo.user" value="admin"/>

                                <property name="eclipselink.nosql.property.mongo.password" value="DvHs3m_KcrKq"/> -->

                                <property name="eclipselink.logging.level" value="FINEST"/>

                                <property name="javax.persistence.validation.group.pre-persist"

                               value="com.acc.entity.Booking"/>

                               

                            </properties>

                        </persistence-unit>

                    </persistence>

                    • 7. Re: hibernate cast exception
                      nasir naseem Newbie

                      antlr-2.7.7.jar

                      bsh-2.0b4.jar

                      hibernate3.jar

                      hibernate-validator.jar

                      jboss-el.jar

                      jsf-facelets.jar

                       

                      removing these jars show class not found error during deployment .

                      • 8. Re: hibernate cast exception
                        Stephen Coy Master

                        I don't believe you can use this:

                         

                        {code:xml}<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>{code}

                         

                        and expect hibernate to work.