The problem is you are using JPA in "Java SE" mode. Java EE applications
don't call Persistence.createEntityManagerFactory(). Your code calls
that method and hence it is treated as a Java SE application and that in
turn requires you to specify provider-name in persistence.xml file. But
that won't solve your problem as I see you have specified
transaction-type as JTA which is not available in Java SE mode. So,
change your code to get hold of EntityManagerFactory or EntityManager
using some other techniques like injection or JNDI lookup. See if [1] helps.
Thanks,
Sahoo
[1]
http://weblogs.java.net/blog/ss141213/archive/2005/12/dont_use_persis_1.html
glassfish_at_javadesktop.org wrote:
> Guys,
>
> Environment Details
>
> Netbeans 6.5
> Glassfish V2 ur2
> Toplink
> Oracle thin JDBC driver
> JAVA EE application
>
> I am getting the following error:
>
> root cause
>
> javax.persistence.PersistenceException: No Persistence provider for EntityManager named myapp-ejbPU: The following providers:
> oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider
> oracle.toplink.essentials.PersistenceProvider
> Returned null to createEntityManagerFactory.
>
>
> persistence.xml file...
>
>
> <?xml version="1.0" encoding="UTF-8"?>
> <persistence version="1.0" xmlns="http://java.sun.com/xml/ns/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_1_0.xsd">
> <persistence-unit name="myapp-ejbPU" transaction-type="JTA">
> <jta-data-source>mydatasource</jta-data-source>
> <properties/>
> </persistence-unit>
> </persistence>
>
>
> also mydatasource pings fine...and I also executed some queries just fine...
>
> this is how I am creating the entity manager...
>
> public EntityManager getEntityManager() {
> if (emf == null) {
> emf = Persistence.createEntityManagerFactory("myapp-ejbPU");
> }
> return emf.createEntityManager();
> }
>
> What am I missing...please suggest...
>
> -Amor
> [Message sent by forum member 'amorous' (amorous)]
>
> http://forums.java.net/jive/thread.jspa?messageID=326620
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>