powered by Jive Software

Custom database connection in an Openfire plugin

Hi everybody!

I’m writing an OpenFire plugin and in a servlet, I need to connect to another MySQL database.

When I want an EntityManager, I create a factory using:

Persistence.createEntityManagerFactory(“myPersistenceUnit”);

I have in my plugin repository a file “META-INF/persistence.xml” (and the same in a jar in librairies) but I always got this exception:

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

Is there a tip? Can I know where this persistence file is searched?

Thanks a lot in advance!

Regards,

Samuel ROZE.

I found the problem: I have to call the

Persistence.createEntityManagerFactory(“myPersistenceUnit”);

function during the plugin initialization, and it works!

In fact, I was calling that in another package (a library of my plugin), called from the servlet.