[Red5devs] enabling jpa in red5

Aljosa Mohorovic aljosa.mohorovic at gmail.com
Wed Oct 22 10:36:23 PDT 2008


i'm trying to enable jpa (using hibernate as jpa provider) in red5
application and now i'm stuck with:
 =>  javax.persistence.PersistenceException: No Persistence provider
for EntityManager named

for last 7 hours i've tried to find what i did wrong but i can't
figure it out so i'm hoping that somebody can help me and that result
of this post will be a document on:
 => howto enable jpa in red5

in order to figure out what is wrong i did this:
#1 => created a library with database models/entities +
persistence.xml (no red5 code) - jpa_lib
#2 => created a cli (command-line) java app that uses jpa_lib (no red5
code) - jpa_cli
 - jpa_cli app works as expected - successfully connected to database
and retrieved data
 - jpa_cli app is only a few lines of code:
-----
EntityManagerFactory emf =
Persistence.createEntityManagerFactory("<persistence unit name>");
EntityManager em = emf.createEntityManager();
EntityTransaction tx = em.getTransaction();
tx.begin();
List tokens = em.createQuery("select t from Red5Authtoken t").getResultList();
System.out.println("red5tokens: " + tokens.size() + " token(s) found");
tx.commit();
em.close();
emf.close();
-----

 - then i removed all jars that jpa_cli requires to find out which
exception is thrown when some jar is missing:
=> missing jar - exception:
ejb3-persistence.jar - Exception in thread "main"
java.lang.NoClassDefFoundError: javax/persistence/Persistence
hibernate-entitymanager.jar - Exception in thread "main"
javax.persistence.PersistenceException: No Persistence provider for
EntityManager named
hibernate3.jar - Exception in thread "main"
java.lang.NoClassDefFoundError: org/hibernate/MappingException
dom4j.jar - Exception in thread "main" java.lang.NoClassDefFoundError:
org/dom4j/DocumentException
hibernate-annotations.jar - Exception in thread "main"
java.lang.NoClassDefFoundError:
org/hibernate/cfg/AnnotationConfiguration
hibernate-commons-annotations.jar - Exception in thread "main"
java.lang.NoClassDefFoundError:
org/hibernate/annotations/common/reflection/ReflectionManager
slf4j-api.jar - Exception in thread "main"
java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
slf4j-log4j12.jar - Exception in thread "main"
java.lang.NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder
log4j.jar - Exception in thread "main" java.lang.NoClassDefFoundError:
org/apache/log4j/LogManager
javassist.jar - Exception in thread "main"
java.lang.NoClassDefFoundError: javassist/bytecode/ClassFile
commons-collections.jar - Exception in thread "main"
java.lang.NoClassDefFoundError:
org/apache/commons/collections/map/LRUMap
antlr.jar - Exception in thread "main" java.lang.NoClassDefFoundError:
antlr/ANTLRException
jta.jar - Exception in thread "main" java.lang.NoClassDefFoundError:
javax/transaction/SystemException

#3 => created red5 application:
 - "empty" red5 app that runs
 - added jpa_lib and this code in AppStart:
-----
EntityManagerFactory emf =
Persistence.createEntityManagerFactory("<persistence unit name>");
emf.close();
-----

 - copied all jars that i think are needed in RED5_HOME/lib
 - started red5.sh:
------
[INFO] [main] org.springframework.beans.factory.support.DefaultListableBeanFactory
- Pre-instantiating singletons in
org.springframework.beans.factory.support.DefaultListableBeanFactory at 19360e7:
defining beans [placeholderConfig,web.context,web.scope,web.handler];
parent: org.springframework.beans.factory.support.DefaultListableBeanFactory at e7e8eb
getLoggerContext request for texasholdem
Context is in map: true
[ERROR] [main] org.red5.server.Scope - Could not start scope
[WebScope at 1edd9b3 Depth = 1, Path = '/default', Name = 'texasholdem'].
javax.persistence.PersistenceException: No Persistence provider for
EntityManager named texasholdem
-----

exception "javax.persistence.PersistenceException: No Persistence
provider for EntityManager named" would mean that
hibernate-entitymanager.jar is missing but it is located in
RED5_HOME/lib

i'm hoping somebody has time to help me solve this problem. i'm also
interested to know if support for something like this is important or
not to core developers?
any comments are welcome.

Aljosa Mohorovic

p.s.
- i'm running red5 standalone, a few days old checkout
- "<persistence unit name>" above is "texasholdem" in my code
- OS/Java: Ubuntu 8.04 $ java -version
java version "1.6.0_07"
Java(TM) SE Runtime Environment (build 1.6.0_07-b06)
Java HotSpot(TM) Server VM (build 10.0-b23, mixed mode)



More information about the Red5devs mailing list