-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: No TransactionManagerLookup specified exception
PostPosted: Wed Jun 29, 2005 5:54 pm 
Pro
Pro

Joined: Fri Nov 19, 2004 5:52 pm
Posts: 232
Location: Chicago, IL
I'm attempting to make use of the EntityManager in a non-managed environment, however, I'm receiving a HibernateException with a description of "No TransactionManagerLookup specified" when I attempt to get an object using EntityManager.find(). Does anyone know what might be the problem?

Hibernate version: hibernate-3.1alpha1, hibernate-annotations-3.1beta3, hibernate-entitymanager-3.1beta1

Mapping documents:

persistence.xml

Code:
<?xml version="1.0"
   encoding="UTF-8"?>
<entity-manager>
   <name>bb_bb60</name>
   <properties>
      <property name="hibernate.ejb.cfgfile"
         value="META-INF/hibernate.cfg.xml"/>
      <property name="hibernate.dialect"
         value="org.hibernate.dialect.Oracle9Dialect"/>
      <property name="hibernate.connection.driver_class"
         value="oracle.jdbc.driver.OracleDriver"/>
      <property name="hibernate.connection.url"
         value="jdbc:oracle:thin:@localhost:1522:BB60"/>
      <property name="hibernate.connection.username"
         value=""/>
      <property name="hibernate.connection.password"
         value=""/>
   </properties>
</entity-manager>

hibernate.cfg.xml

Code:
<?xml version="1.0"
   encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration
   PUBLIC
   "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
   "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
   <session-factory>
      <mapping class="edu.uchicago.at.blackboard.persistence.entity.CalendarItem"/>
      <mapping class="edu.uchicago.at.blackboard.persistence.entity.Course"/>
      <mapping class="edu.uchicago.at.blackboard.persistence.entity.CourseMembership"/>
      <mapping class="edu.uchicago.at.blackboard.persistence.entity.CourseRole"/>
      <mapping class="edu.uchicago.at.blackboard.persistence.entity.User"/>
   </session-factory>
</hibernate-configuration>


Code between sessionFactory.openSession() and session.close():

EntityManagerFactory emf = Persistence.createEntityManagerFactory("bb_bb60");
EntityManager em = emf.getEntityManager();
CourseRole cr = em.find(CourseRole.class, "S");

Full stack trace of any exception that occurs:

[exec] org.hibernate.HibernateException: No TransactionManagerLookup specif
ied
[exec] at org.hibernate.impl.SessionFactoryImpl.getCurrentSession(Sessi
onFactoryImpl.java:513)
[exec] at org.hibernate.ejb.CurrentEntityManagerImpl.getSession(Current
EntityManagerImpl.java:23)
[exec] at org.hibernate.ejb.AbstractEntityManagerImpl.find(AbstractEnti
tyManagerImpl.java:97)
[exec] at edu.uchicago.at.blackboard.test.Test.main(Test.java:47)

Name and version of the database you are using: Oracle 9i

Debug level Hibernate log excerpt:

[exec] Jun 29, 2005 4:38:45 PM org.hibernate.cfg.Environment <clinit>
[exec] INFO: Hibernate 3.1alpha1
[exec] Jun 29, 2005 4:38:45 PM org.hibernate.cfg.Environment <clinit>
[exec] INFO: hibernate.properties not found
[exec] Jun 29, 2005 4:38:45 PM org.hibernate.cfg.Environment <clinit>
[exec] INFO: using CGLIB reflection optimizer
[exec] Jun 29, 2005 4:38:45 PM org.hibernate.cfg.Environment <clinit>
[exec] INFO: using JDK 1.4 java.sql.Timestamp handling
[exec] Jun 29, 2005 4:38:46 PM org.hibernate.cfg.Configuration configure
[exec] INFO: configuring from resource: META-INF/hibernate.cfg.xml
[exec] Jun 29, 2005 4:38:46 PM org.hibernate.cfg.Configuration getConfigura
tionInputStream
[exec] INFO: Configuration resource: META-INF/hibernate.cfg.xml
[exec] Jun 29, 2005 4:38:46 PM org.hibernate.cfg.Configuration doConfigure
[exec] INFO: Configured SessionFactory: null
[exec] Jun 29, 2005 4:38:48 PM org.hibernate.cfg.Configuration secondPassCo
mpile
[exec] INFO: processing extends queue
[exec] Jun 29, 2005 4:38:48 PM org.hibernate.cfg.Configuration secondPassCo
mpile
[exec] INFO: processing collection mappings
[exec] Jun 29, 2005 4:38:48 PM org.hibernate.cfg.annotations.CollectionBind
er bindCollectionSecondPass
[exec] INFO: Mapping collection: edu.uchicago.at.blackboard.persistence.ent
ity.Course.courseMemberships -> course_users
[exec] Jun 29, 2005 4:38:48 PM org.hibernate.cfg.annotations.CollectionBind
er bindCollectionSecondPass
[exec] INFO: Mapping collection: edu.uchicago.at.blackboard.persistence.ent
ity.User.calendarItems -> calendar
[exec] Jun 29, 2005 4:38:48 PM org.hibernate.cfg.Configuration secondPassCo
mpile
[exec] INFO: processing association property references
[exec] Jun 29, 2005 4:38:48 PM org.hibernate.cfg.Configuration secondPassCo
mpile
[exec] INFO: processing foreign key constraints
[exec] Jun 29, 2005 4:38:48 PM org.hibernate.cfg.Configuration secondPassCo
mpile
[exec] INFO: processing extends queue
[exec] Jun 29, 2005 4:38:48 PM org.hibernate.cfg.Configuration secondPassCo
mpile
[exec] INFO: processing collection mappings
[exec] Jun 29, 2005 4:38:48 PM org.hibernate.cfg.Configuration secondPassCo
mpile
[exec] INFO: processing association property references
[exec] Jun 29, 2005 4:38:48 PM org.hibernate.cfg.Configuration secondPassCo
mpile
[exec] INFO: processing foreign key constraints
[exec] Jun 29, 2005 4:38:48 PM org.hibernate.connection.DriverManagerConnec
tionProvider configure
[exec] INFO: Using Hibernate built-in connection pool (not for production u
se!)
[exec] Jun 29, 2005 4:38:48 PM org.hibernate.connection.DriverManagerConnec
tionProvider configure
[exec] INFO: Hibernate connection pool size: 20
[exec] Jun 29, 2005 4:38:48 PM org.hibernate.connection.DriverManagerConnec
tionProvider configure
[exec] INFO: autocommit mode: true
[exec] Jun 29, 2005 4:38:49 PM org.hibernate.connection.DriverManagerConnec
tionProvider configure
[exec] INFO: using driver: oracle.jdbc.driver.OracleDriver at URL: jdbc:ora
cle:thin:@localhost:1522:BB60
[exec] Jun 29, 2005 4:38:49 PM org.hibernate.connection.DriverManagerConnec
tionProvider configure
[exec] INFO: connection properties: {user=****, password=****, auto
commit=true, release_mode=auto}
[exec] Jun 29, 2005 4:38:51 PM org.hibernate.cfg.SettingsFactory buildSetti
ngs
[exec] INFO: RDBMS: Oracle, version: Oracle9i Enterprise Edition Release 9.
2.0.6.0 - 64bit Production
[exec] With the Partitioning, OLAP and Oracle Data Mining options
[exec] JServer Release 9.2.0.6.0 - Production
[exec] Jun 29, 2005 4:38:51 PM org.hibernate.cfg.SettingsFactory buildSetti
ngs
[exec] INFO: JDBC driver: Oracle JDBC driver, version: 9.2.0.5.0
[exec] Jun 29, 2005 4:38:51 PM org.hibernate.dialect.Dialect <init>
[exec] INFO: Using dialect: org.hibernate.dialect.Oracle9Dialect
[exec] Jun 29, 2005 4:38:51 PM org.hibernate.transaction.TransactionFactory
Factory buildTransactionFactory
[exec] INFO: Using default transaction strategy (direct JDBC transactions)
[exec] Jun 29, 2005 4:38:51 PM org.hibernate.transaction.TransactionManager
LookupFactory getTransactionManagerLookup
[exec] INFO: No TransactionManagerLookup configured (in JTA environment, us
e of read-write or transactional second-level cache is not recommended)
[exec] Jun 29, 2005 4:38:51 PM org.hibernate.cfg.SettingsFactory buildSetti
ngs
[exec] INFO: Automatic flush during beforeCompletion(): disabled
[exec] Jun 29, 2005 4:38:51 PM org.hibernate.cfg.SettingsFactory buildSetti
ngs
[exec] INFO: Automatic session close at end of transaction: disabled
[exec] Jun 29, 2005 4:38:51 PM org.hibernate.cfg.SettingsFactory buildSetti
ngs
[exec] INFO: JDBC batch size: 15
[exec] Jun 29, 2005 4:38:51 PM org.hibernate.cfg.SettingsFactory buildSetti
ngs
[exec] INFO: JDBC batch updates for versioned data: disabled
[exec] Jun 29, 2005 4:38:51 PM org.hibernate.cfg.SettingsFactory buildSetti
ngs
[exec] INFO: Scrollable result sets: enabled
[exec] Jun 29, 2005 4:38:51 PM org.hibernate.cfg.SettingsFactory buildSetti
ngs
[exec] INFO: JDBC3 getGeneratedKeys(): disabled
[exec] Jun 29, 2005 4:38:51 PM org.hibernate.cfg.SettingsFactory buildSetti
ngs
[exec] INFO: Connection release mode: auto
[exec] Jun 29, 2005 4:38:51 PM org.hibernate.cfg.SettingsFactory buildSetti
ngs
[exec] INFO: Default batch fetch size: 1
[exec] Jun 29, 2005 4:38:51 PM org.hibernate.cfg.SettingsFactory buildSetti
ngs
[exec] INFO: Generate SQL with comments: disabled
[exec] Jun 29, 2005 4:38:51 PM org.hibernate.cfg.SettingsFactory buildSetti
ngs
[exec] INFO: Order SQL updates by primary key: disabled
[exec] Jun 29, 2005 4:38:51 PM org.hibernate.cfg.SettingsFactory createQuer
yTranslatorFactory
[exec] INFO: Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFact
ory
[exec] Jun 29, 2005 4:38:51 PM org.hibernate.hql.ast.ASTQueryTranslatorFact
ory <init>
[exec] INFO: Using ASTQueryTranslatorFactory
[exec] Jun 29, 2005 4:38:51 PM org.hibernate.cfg.SettingsFactory buildSetti
ngs
[exec] INFO: Query language substitutions: {}
[exec] Jun 29, 2005 4:38:51 PM org.hibernate.cfg.SettingsFactory buildSetti
ngs
[exec] INFO: Second-level cache: enabled
[exec] Jun 29, 2005 4:38:51 PM org.hibernate.cfg.SettingsFactory buildSetti
ngs
[exec] INFO: Query cache: disabled
[exec] Jun 29, 2005 4:38:51 PM org.hibernate.cfg.SettingsFactory createCach
eProvider
[exec] INFO: Cache provider: org.hibernate.cache.EhCacheProvider
[exec] Jun 29, 2005 4:38:51 PM org.hibernate.cfg.SettingsFactory buildSetti
ngs
[exec] INFO: Optimize cache for minimal puts: disabled
[exec] Jun 29, 2005 4:38:51 PM org.hibernate.cfg.SettingsFactory buildSetti
ngs
[exec] INFO: Structured second-level cache entries: disabled
[exec] Jun 29, 2005 4:38:51 PM org.hibernate.cfg.SettingsFactory buildSetti
ngs
[exec] INFO: Statistics: disabled
[exec] Jun 29, 2005 4:38:51 PM org.hibernate.cfg.SettingsFactory buildSetti
ngs
[exec] INFO: Deleted entity synthetic identifier rollback: enabled
[exec] Jun 29, 2005 4:38:51 PM org.hibernate.cfg.SettingsFactory buildSetti
ngs
[exec] INFO: Default entity-mode: pojo
[exec] Jun 29, 2005 4:38:51 PM org.hibernate.impl.SessionFactoryImpl <init>

[exec] INFO: building session factory
[exec] Jun 29, 2005 4:38:51 PM net.sf.ehcache.config.Configurator configure

[exec] WARNING: No configuration found. Configuring ehcache from ehcache-fa
ilsafe.xml found in the classpath: jar:file:/opt/jre1.5.0_04-dev/lib/ext/ehcache
-1.1.jar!/ehcache-failsafe.xml
[exec] Jun 29, 2005 4:38:53 PM org.hibernate.impl.SessionFactoryObjectFacto
ry addInstance
[exec] INFO: Not binding factory to JNDI, no JNDI name configured
[exec] Jun 29, 2005 4:38:53 PM org.hibernate.impl.SessionFactoryImpl checkN
amedQueries
[exec] INFO: Checking 0 named queries
[exec] org.hibernate.HibernateException: No TransactionManagerLookup specif
ied
[exec] at org.hibernate.impl.SessionFactoryImpl.getCurrentSession(Sessi
onFactoryImpl.java:513)
[exec] at org.hibernate.ejb.CurrentEntityManagerImpl.getSession(Current
EntityManagerImpl.java:23)
[exec] at org.hibernate.ejb.AbstractEntityManagerImpl.find(AbstractEnti
tyManagerImpl.java:97)
[exec] at edu.uchicago.at.blackboard.test.Test.main(Test.java:47)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 01, 2005 9:40 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
getEntityManager() is not allowed in a non managed environment

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 01, 2005 12:04 pm 
Pro
Pro

Joined: Fri Nov 19, 2004 5:52 pm
Posts: 232
Location: Chicago, IL
Heh, thanks Emmanuel, good eye. I mistakenly was using getEntityManager() instead of createEntityManager(). It works now. Thanks.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.