so i'm trying to use EclipseLink ORM with a Bukkit plugin.
I know there is already a ORM built-in to Craftbukkit (Ebean) but this one doesn't match my needs, it's too limited for entities Inheritance. That's why I turn to EclipseLink.
The problem is I can't initialize an EntityManagerFactory inside my Bukkit plugin : It seems that JPA can't find the META-INF/persistence.xml inside my plugin JAR. I guess this is a classpath issue, and JPA try to find the persistence file using the Craftbukkit classpath instead of my plugin classpath but I have no idea how to solve this.
So here is my plugin main class :
public class MyPlugin extends JavaPlugin{
@Override
public void onEnable(){
EntityManagerFactory factory = Persistence.createEntityManagerFactory("persistunit");
EntityManager em = factory.createEntityManager();
// ...
}
// ...
}
And my persistence.xml file (which is located in the META-INF folder of my plugin JAR) :
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="persistunit" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<properties>
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://......"/>
<property name="javax.persistence.jdbc.user" value="......."/>
<property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/>
<property name="javax.persistence.jdbc.password" value="........."/>
</properties>
</persistence-unit>
</persistence>
And that's the exception thrown when running :
Error occured while enabling MyPlugin...
javax.persistence.PersistenceException: No Persistence provider for EntityManager named persistunit
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:89) ~[craftbukkit.jar:git-Spigot-1.7.9-R0.2-205-g0a049fa]
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:60) ~[craftbukkit.jar:git-Spigot-1.7.9-R0.2-205-g0a049fa]
Thanks in advance for your help !