java - How to set up EclipseLink (or other JPA implementation) with a Minecraft Bukkit plugin? -
so i'm trying utilize eclipselink orm bukkit plugin.
i know there orm built-in craftbukkit (ebean) 1 doesn't match needs, it's limited entities inheritance. that's why turn eclipselink.
the problem can't initialize entitymanagerfactory within bukkit plugin : seems jpa can't find meta-inf/persistence.xml within plugin jar. guess classpath issue, , jpa seek find persistence file using craftbukkit classpath instead of plugin classpath have no thought how solve this.
so here plugin main class :
public class myplugin extends javaplugin{ @override public void onenable(){ entitymanagerfactory mill = persistence.createentitymanagerfactory("persistunit"); entitymanager em = factory.createentitymanager(); // ... } // ... }
and persistence.xml file (which located in meta-inf folder of 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 exception thrown when running :
error occured while enabling myplugin... javax.persistence.persistenceexception: no persistence provider entitymanager named persistunit @ javax.persistence.persistence.createentitymanagerfactory(persistence.java:89) ~[craftbukkit.jar:git-spigot-1.7.9-r0.2-205-g0a049fa] @ javax.persistence.persistence.createentitymanagerfactory(persistence.java:60) ~[craftbukkit.jar:git-spigot-1.7.9-r0.2-205-g0a049fa]
thanks in advance help !
java jpa orm eclipselink bukkit
No comments:
Post a Comment