Help!
I've tried a bunch of things to get the below to work from a stand alone test case. I got most of my details from here:
http://www.hibernate.org/282.html
but I'm not sure how to setup the TransactionManager in a standalone environment - is this even possible? If not, anyone that is familiar with JBoss to tell me how to configure the TransactionManager in JBoss?
Thanks alot!
Mark
Hibernate version:
3.95
Name and version of the database you are using:
MySQL
Code:
Configuration cfg = new Configuration()
.setProperty("hibernate.dialect", "org.hibernate.dialect.MySQLInnoDBDialect")
.setProperty("hibernate.connection.driver_class", "com.mysql.jdbc.Driver")
.setProperty("hibernate.connection.url", "jdbc:mysql://localhost:3306/taxelerate")
.setProperty("hibernate.connection.username", "ivan")
.setProperty("hibernate.connection.password", "")
.setProperty("hibernate.session_factory_name", "hibernate/SessionFactory")
.setProperty("hibernate.show_sql", "true")
.setProperty("hibernate.transaction.flush_before_completion","true")
.setProperty("hibernate.transaction.factory_class", "org.hibernate.transaction.JDBCTransactionFactory")
.setProperty("hibernate.transaction.manager_lookup_class",
"org.hibernate.transaction.JBossTransactionManagerLookup")
;
17:26:35,471 INFO [Environment] Hibernate 3.0.5
17:26:35,471 INFO [Environment] hibernate.properties not found
17:26:35,502 INFO [Environment] using CGLIB reflection optimizer
17:26:35,502 INFO [Environment] using JDK 1.4 java.sql.Timestamp handling
17:26:35,705 INFO [Configuration] Mapping resource: com/westminster/taxelerate/beans/ProductBean.hbm.xml
17:26:36,236 INFO [HbmBinder] Mapping class: com.westminster.taxelerate.beans.ProductBean -> tx_product
17:26:36,299 INFO [Configuration] Mapping resource: com/westminster/taxelerate/beans/ItemBean.hbm.xml
17:26:36,408 INFO [HbmBinder] Mapping class: com.westminster.taxelerate.beans.ItemBean -> tx_item
17:26:36,627 INFO [Configuration] Mapping resource: com/westminster/taxelerate/beans/AccountBean.hbm.xml
17:26:36,690 INFO [HbmBinder] Mapping class: com.westminster.taxelerate.beans.AccountBean -> tx_account
17:26:36,690 INFO [Configuration] processing extends queue
17:26:36,690 INFO [Configuration] processing collection mappings
17:26:36,690 INFO [HbmBinder] Mapping collection: com.westminster.taxelerate.beans.AccountBean.items -> tx_item
17:26:36,705 INFO [Configuration] processing association property references
17:26:36,705 INFO [Configuration] processing foreign key constraints
17:26:36,768 INFO [DriverManagerConnectionProvider] Using Hibernate built-in connection pool (not for production use!)
17:26:36,768 INFO [DriverManagerConnectionProvider] Hibernate connection pool size: 20
17:26:36,768 INFO [DriverManagerConnectionProvider] autocommit mode: false
17:26:36,783 INFO [DriverManagerConnectionProvider] using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost:3306/taxelerate
17:26:36,783 INFO [DriverManagerConnectionProvider] connection properties: {user=ivan, password=}
17:26:37,361 INFO [SettingsFactory] RDBMS: MySQL, version: 4.1.7-max-log
17:26:37,361 INFO [SettingsFactory] JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-3.0.14-production ( $Date: 2004/04/24 15:49:43 $, $Revision: 1.27.2.39 $ )
17:26:37,424 INFO [Dialect] Using dialect: org.hibernate.dialect.MySQLInnoDBDialect
17:26:37,440 INFO [TransactionFactoryFactory] Transaction strategy: org.hibernate.transaction.JDBCTransactionFactory
17:26:37,440 INFO [TransactionManagerLookupFactory] instantiating TransactionManagerLookup: org.hibernate.transaction.JBossTransactionManagerLookup
17:26:37,455 INFO [TransactionManagerLookupFactory] instantiated TransactionManagerLookup
17:26:37,455 INFO [SettingsFactory] Automatic flush during beforeCompletion(): enabled
17:26:37,455 INFO [SettingsFactory] Automatic session close at end of transaction: disabled
17:26:37,455 INFO [SettingsFactory] JDBC batch size: 15
17:26:37,455 INFO [SettingsFactory] JDBC batch updates for versioned data: disabled
17:26:37,455 INFO [SettingsFactory] Scrollable result sets: enabled
17:26:37,455 INFO [SettingsFactory] JDBC3 getGeneratedKeys(): enabled
17:26:37,455 INFO [SettingsFactory] Connection release mode: null
17:26:37,471 INFO [SettingsFactory] Maximum outer join fetch depth: 2
17:26:37,471 INFO [SettingsFactory] Default batch fetch size: 1
17:26:37,471 INFO [SettingsFactory] Generate SQL with comments: disabled
17:26:37,471 INFO [SettingsFactory] Order SQL updates by primary key: disabled
17:26:37,471 INFO [SettingsFactory] Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
17:26:37,486 INFO [ASTQueryTranslatorFactory] Using ASTQueryTranslatorFactory
17:26:37,486 INFO [SettingsFactory] Query language substitutions: {}
17:26:37,486 INFO [SettingsFactory] Second-level cache: enabled
17:26:37,486 INFO [SettingsFactory] Query cache: disabled
17:26:37,486 INFO [SettingsFactory] Cache provider: org.hibernate.cache.EhCacheProvider
17:26:37,502 INFO [SettingsFactory] Optimize cache for minimal puts: disabled
17:26:37,502 INFO [SettingsFactory] Structured second-level cache entries: disabled
17:26:37,518 INFO [SettingsFactory] Echoing all SQL to stdout
17:26:37,518 INFO [SettingsFactory] Statistics: disabled
17:26:37,518 INFO [SettingsFactory] Deleted entity synthetic identifier rollback: disabled
17:26:37,533 INFO [SettingsFactory] Default entity-mode: pojo
17:26:37,861 INFO [SessionFactoryImpl] building session factory
17:26:37,908 WARN [Configurator] No configuration found. Configuring ehcache from ehcache-failsafe.xml found in the classpath: jar:file:/C:/Documents%20and%20Settings/Mark/workspace/Taxelerate/implementation/lib/ehcache-1.1.jar!/ehcache-failsafe.xml
17:26:38,908 WARN [CacheFactory] read-only cache configured for mutable class: com.westminster.taxelerate.beans.ProductBean
17:26:38,908 WARN [EhCacheProvider] Could not find configuration [com.westminster.taxelerate.beans.ProductBean]; using defaults.
17:26:39,158 INFO [SessionFactoryObjectFactory] Factory name: hibernate/SessionFactory
17:26:39,174 INFO [NamingHelper] JNDI InitialContext properties:{}
17:26:39,440 INFO [SessionFactoryObjectFactory] Bound factory to JNDI name: hibernate/SessionFactory
17:26:39,440 WARN [SessionFactoryObjectFactory] InitialContext did not implement EventContext
17:26:39,440 INFO [NamingHelper] JNDI InitialContext properties:{}
Exception in thread "main" org.hibernate.HibernateException: Could not locate TransactionManager
at org.hibernate.transaction.JNDITransactionManagerLookup.getTransactionManager(JNDITransactionManagerLookup.java:26)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:270)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1005)
at com.westminster.taxelerate.account.AccountDao.main(AccountDao.java:51)
Caused by: javax.naming.NameNotFoundException: TransactionManager not bound
at org.jnp.server.NamingServer.getBinding(NamingServer.java:491)
at org.jnp.server.NamingServer.getBinding(NamingServer.java:499)
at org.jnp.server.NamingServer.getObject(NamingServer.java:505)
at org.jnp.server.NamingServer.lookup(NamingServer.java:278)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:544)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:520)
at javax.naming.InitialContext.lookup(Unknown Source)
at org.hibernate.transaction.JNDITransactionManagerLookup.getTransactionManager(JNDITransactionManagerLookup.java:23)
... 3 more