2 Replies Latest reply on Jul 10, 2007 4:04 PM by Alex Grönholm

    Exception in calling an Entity Bean from Servlet

    ashutosh sri Newbie

      Hi All ,
      I am getting this exception after making a call to persist some data . Please can anybody help me out :



      ERROR [[TestServlet]] Servlet.service() for servlet TestServlet threw exception
      java.lang.ClassCastException: org.hibernate.ejb.HibernatePersistence
      at javax.persistence.Persistence.findAllProviders(Persistence.java:112)
      at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:79)
      at Ejbtest.mainTest(Ejbtest.java:47)
      at TestServlet.doPost(TestServlet.java:75)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
      at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
      at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
      at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241)
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:580)
      at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
      at java.lang.Thread.run(Unknown Source)



      My Persistence.xml lokks like this :

      <?xml version="1.0" encoding="UTF-8"?>
      <persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
      <persistence-unit name="testApp">

      oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider
      Ejbtest
      Employee
      Software
      SoftwareFile
      Tab1
      <!-- <jta-data-source>java:/XAOracleDS</jta-data-source> -->

      <!-- Provider-specific connection properties -->




      <!-- Provider-specific settings -->

      <!-- other values are: drop-and-create-tables|none -->

      </persistence-unit>

        • 1. Re: Exception in calling an Entity Bean from Servlet
          ashutosh sri Newbie

          Hi All ,
          I am getting this exception after making a call to persist some data . Please can anybody help me out :



          ERROR [[TestServlet]] Servlet.service() for servlet TestServlet threw exception
          java.lang.ClassCastException: org.hibernate.ejb.HibernatePersistence
          at javax.persistence.Persistence.findAllProviders(Persistence.java:112)
          at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:79)
          at Ejbtest.mainTest(Ejbtest.java:47)
          at TestServlet.doPost(TestServlet.java:75)
          at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
          at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
          at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
          at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
          at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
          at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
          at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
          at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
          at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
          at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
          at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
          at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241)
          at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
          at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:580)
          at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
          at java.lang.Thread.run(Unknown Source)



          My Persistence.xml lokks like this :



          <?xml version="1.0" encoding="UTF-8"?>
          <persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
          <persistence-unit name="testApp">

          oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider
          Ejbtest
          Employee
          Software
          SoftwareFile
          Tab1
          <!-- <jta-data-source>java:/XAOracleDS</jta-data-source> -->

          <!-- Provider-specific connection properties -->




          <!-- Provider-specific settings -->

          <!-- other values are: drop-and-create-tables|none -->

          </persistence-unit>

          • 2. Re: Exception in calling an Entity Bean from Servlet
            Alex Grönholm Novice

            Why are you using Toplink Essentials instead of Hibernate? There are no advantages to that, only drawbacks.