persistence@glassfish.java.net

Re: Help with EJB3 and Glassfish!

From: Sanjeeb Kumar Sahoo <Sanjeeb.Sahoo_at_Sun.COM>
Date: Fri, 13 Jan 2006 00:02:10 +0530

Hi,

Tamar Bosikashvili wrote:

> 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.
>
Don't worry. If you configured jdbc/DataSource to talk to SQL Server,
then this entity manager factory will internally talk to MS Sql Server.

> When I run client wthis this part of this code throws excetion
>
> |EntityManagerFactory emf =
> Persistence.createEntityManagerFactory("|myEntityManager|");|
> |// create EntityManager|
> E|ntityManager em = emf.createEntityManager();|
>
> | |
>
> |Exception:|
>
> javax.persistence.PersistenceException: No Persistence provider for
> EntityManager named myEntityManager
>
> at
> javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:67)
>
Your problem seem to be that you deployed the persistence unit in the
application server and now you are trying to use it outside the
container. Here are a few examples that can guide you to use Java
Persistence API:

https://glassfish.dev.java.net/javaee5/persistence/persistence-example.html
http://weblogs.java.net/blog/ss141213/archive/2005/12/introduction_to.html
http://weblogs.java.net/blog/ss141213/archive/2005/12/using_java_pers.html

Thanks,
Sahoo

Note: Check the time/timezone in your computer.

> 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.
>