Glassfish 4 with EMF Texo - JPA No persistence provider

I'm trying to use EMF Texo in Glassfish 4, but when I want to initialize EntityManagerProvider I get the error:

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

I tried to implement the Texo tutorial found here. The difference is that I want it to run on Glassfish 4.

Bellow is my code:

web.xml:

<listener>
    <listener-class>texo.web.TexoContextListener</listener-class>
</listener>

<filter>
    <filter-name>emFilter</filter-name>
    <filter-class>org.eclipse.emf.texo.server.store.CurrentEntityManagerRequestFilter</filter-class>
</filter>

<filter-mapping>
    <filter-name>emFilter</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

TexoContextListener.java

import javax.servlet.ServletContextListener;
import org.eclipse.emf.texo.server.service.ServiceModelPackageRegistry;
import org.eclipse.emf.texo.server.store.EntityManagerProvider;
import org.eclipse.emf.texo.test.model.base.identifiable.IdentifiableModelPackage;

public class TexoContextListener implements ServletContextListener{

@Override
public void contextInitialized(ServletContextEvent arg0) {
    ServiceModelPackageRegistry.getInstance().register(IdentifiableModelPackage.INSTANCE);
    EntityManagerProvider.getInstance().setPersistenceUnitName("HelloTexo"); 
    // initialize aggressively
    EntityManagerProvider.getInstance().initialize();
}
@Override
public void contextDestroyed(ServletContextEvent arg0) {
    // TODO Auto-generated method stub

}

}

In debug I get the error mentioned above when I try to initialize() the EntityManagerProvider.

persistence.xml

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.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_2_0.xsd">
    <persistence-unit name="HelloTexo" transaction-type="JTA">
        <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider> 
        <jta-data-source>jdbc/__MySQLDataSource</jta-data-source>
    </persistence-unit>
</persistence>

I created this file automatically by adding JPA Project Facet to my project from Eclipse. The connection to database is succesful. I tried to move the persistence.xml to WEB-INF/classes/META-INF/ but I still get the same error.

Any idea what might cause the error? I am stuck here for some days now... I really hope someone will be able to give me an ideea.

Answers


There may be a classloader conflict. Glassfish4 includes EclipseLink in the container library path. Try removing your explicit <provider> tag and any jpa implementation jars from WEB-INF/lib folder. The standard Glassfish javax.persistence.jar should be all you need.


Need Your Help

JMX Monitoring Software

jboss monitoring jmx

I am trying to find a good monitoring software for my simple hello world application written by test purposes.

Sliding form stop animation if mandatory field empty

jquery forms validation animation

I have a big form so for that am using sliding form

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.