persistence@glassfish.java.net

RE: Help with EJB3 and Glassfish!

From: Gordon Yorke <gordon.yorke_at_oracle.com>
Date: Thu, 12 Jan 2006 13:17:15 -0500

Hello,
   The EntityManagerFactoryProvider is not database specific. There is only one implementation that is generic and is used for all databases.
    Second when acquiring a EntityManagerFactory in a Java EE environment you must use either injection or JNDI lookup. The Persistence class call you have used below is only for Java SE deployments.
--Gordon

  -----Original Message-----
  From: Tamar Bosikashvili [mailto:TamarB_at_nbg.gov.ge]
  Sent: Thursday, January 12, 2006 4:15 AM
  To: persistence_at_glassfish.dev.java.net
  Subject: Help with EJB3 and Glassfish!


   

  I have An EJB3 Entity Persistence project in NetBeans, using GlassFish .

  I have in Continer configured JDBC pool and JDBC connection via MS.SQLServer .

  I have META-INF/persistence.xml file like this:

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

  <persistence-unit name ="myEntityManager">

             <description>Sample Customer Database</description>

        

          <jta-data-source>jdbc/DataSourse</jta-data-source>

          <class>avr.Author</class>

          <class>avr.Book</class>

          </persistence-unit>

  </persistence>

   

  But when I deploy this project is throws Exception :

   

  [#|2006-01-12T10:28:35.043+0300|INFO|sun-appserver-pe9.0|javax.enterprise.system.core.classloading|_ThreadID=12;_ThreadName=httpWorkerThread-4848-3;jdbc/DataSourse;|JTADSName = jdbc/DataSourse|#]

  [#|2006-01-12T10:28:35.059+0300|INFO|sun-appserver-pe9.0|javax.enterprise.system.core.classloading|_ThreadID=12;_ThreadName=httpWorkerThread-4848-3;jdbc/DataSourse;|nonJTADSName = jdbc/DataSourse|#]

  [#|2006-01-12T10:28:35.059+0300|INFO|sun-appserver-pe9.0|javax.enterprise.system.core.classloading|_ThreadID=12;_ThreadName=httpWorkerThread-4848-3;|PersistenceInfo for this pud is :

  <persistence-unit>

          <PURoot>file:/E:/NetBeansProject/EnterpriseApplication2/EnterpriseApplication2-war/build/web/WEB-INF/classes/</PURoot>

          <name>myEntityManager</name>

          <provider>oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider</provider>

          <transaction-type>JTA</transaction-type>

          <jta-data-source>com.sun.gjc.spi.DataSource_at_14a4067</jta-data-source>

          <non-jta-data-source>com.sun.gjc.spi.DataSource_at_1ca623f</non-jta-data-source>

          <class-name>avr.Author</class-name>

          <class-name>avr.Book</class-name>

          <properties>{}</properties>

          <class-loader>InstrumentableWebappClassLoader

   Parent -> WebappClassLoader

    delegate: true

    repositories:

      /WEB-INF/classes/

   

  It uses oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider , but I need MSSql Server's EntityManagerFactoryProvider.

   

  When I run client wthis this part of this code throws excetion

  EntityManagerFactory emf = Persistence.createEntityManagerFactory("myEntityManager");
  // create EntityManager
  EntityManager em = emf.createEntityManager();

   

  Exception:

  javax.persistence.PersistenceException: No Persistence provider for EntityManager named myEntityManager

          at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:67)

   

   

   

  Now I have queshen: How I can make correct persistence.xml file to complile project correctly and Persistence.createEntityManagerFactory find this myEntityManager.

  If can you, help me!

   

  Tamri!




  CONFIDENTIAL
  This message contains confidential information and is intended only for persistence_at_glassfish.dev.java.net. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system.