Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
[b]Hibernate version:3.0[/b]
[b]Mapping documents:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 2.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">
<!-- Generated file - Do not edit! -->
<hibernate-configuration>
<!-- a SessionFactory instance listed as /jndi/name -->
<session-factory>
<!-- properties -->
<property name="dialect">org.hibernate.dialect.PostgreSQLDialect</property>
<property name="show_sql">false</property>
<property name="use_outer_join">false</property>
<property name="jta.UserTransaction">java:comp/UserTransaction</property>
<property name="connection.username">user</property>
<property name="connection.password">password</property>
<property name="connection.driver_class">org.postgresql.Driver</property>
<property name="connection.url">jdbc:postgresql://ipaddress:port/dbname</property>
<property name="hibernate.transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</property>
<!-- mapping files -->
<mapping resource="com/gloptv/smsc/Customer.hbm.xml"/>
<mapping resource="com/gloptv/smsc/Parameter.hbm.xml"/>
<mapping resource="com/gloptv/smsc/User.hbm.xml"/>
<mapping resource="com/gloptv/smsc/Application.hbm.xml"/>
<mapping resource="com/gloptv/smsc/PhoneNumber.hbm.xml"/>
<mapping resource="com/gloptv/smsc/SmsOut.hbm.xml"/>
<mapping resource="com/gloptv/smsc/Operator.hbm.xml"/>
<mapping resource="com/gloptv/smsc/SmsIn.hbm.xml"/>
<mapping resource="com/gloptv/smsc/Synchro.hbm.xml"/>
<mapping resource="com/gloptv/smsc/Keyword.hbm.xml"/>
<mapping resource="com/gloptv/smsc/Status.hbm.xml"/>
</session-factory>
</hibernate-configuration>
[/b]
[b]Code between sessionFactory.openSession() and session.close():
try
{
session = HibernateUtil.currentSession();
tx = session.beginTransaction();
Date today = Calendar.getInstance().getTime();
setName(user.getName());
setDescription(user.getDescription());
setPassword(user.getPassword());
setIsAdmin(user.isIsAdmin());
setLoginDate(user.getLoginDate());
setLockedDate(user.getLockedDate());
setLastIp(user.getLastIp());
setCustomers(user.getCustomers());
status = STATUS_VALID;
user.setLoginDate(today);
user.setLastIp(lastIp);
session.save(user);
tx.commit();
}
catch (Exception e)
{
if (tx != null)
tx.rollback();
throw new Exception(e.getMessage());
}
finally
{
HibernateUtil.closeSession();
}
[/b]
[b]Full stack trace of any exception that occurs:
May 2, 2005 3:20:12 PM org.hibernate.cfg.Environment <clinit>
INFO: Hibernate 3.0
May 2, 2005 3:20:12 PM org.hibernate.cfg.Environment <clinit>
INFO: hibernate.properties not found
May 2, 2005 3:20:12 PM org.hibernate.cfg.Environment <clinit>
INFO: using CGLIB reflection optimizer
May 2, 2005 3:20:12 PM org.hibernate.cfg.Environment <clinit>
INFO: using JDK 1.4 java.sql.Timestamp handling
May 2, 2005 3:20:12 PM org.hibernate.cfg.Configuration configure
INFO: configuring from resource: hibernate.cfg.xml
May 2, 2005 3:20:12 PM org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: Configuration resource: hibernate.cfg.xml
May 2, 2005 3:20:14 PM org.hibernate.cfg.Configuration addResource
INFO: Mapping resource: com/gloptv/smsc/Customer.hbm.xml
May 2, 2005 3:20:14 PM org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
INFO: Mapping class: com.gloptv.smsc.Customer -> customer
May 2, 2005 3:20:14 PM org.hibernate.cfg.Configuration addResource
INFO: Mapping resource: com/gloptv/smsc/Parameter.hbm.xml
May 2, 2005 3:20:14 PM org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
INFO: Mapping class: com.gloptv.smsc.Parameter -> parameter
May 2, 2005 3:20:14 PM org.hibernate.cfg.Configuration addResource
INFO: Mapping resource: com/gloptv/smsc/User.hbm.xml
May 2, 2005 3:20:14 PM org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
INFO: Mapping class: com.gloptv.smsc.User -> smsc_user
May 2, 2005 3:20:14 PM org.hibernate.cfg.Configuration addResource
INFO: Mapping resource: com/gloptv/smsc/Application.hbm.xml
May 2, 2005 3:20:14 PM org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
INFO: Mapping class: com.gloptv.smsc.Application -> application
May 2, 2005 3:20:14 PM org.hibernate.cfg.Configuration addResource
INFO: Mapping resource: com/gloptv/smsc/PhoneNumber.hbm.xml
May 2, 2005 3:20:14 PM org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
INFO: Mapping class: com.gloptv.smsc.PhoneNumber -> phone_number
May 2, 2005 3:20:14 PM org.hibernate.cfg.Configuration addResource
INFO: Mapping resource: com/gloptv/smsc/SmsOut.hbm.xml
May 2, 2005 3:20:14 PM org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
INFO: Mapping class: com.gloptv.smsc.SmsOut -> sms_out
May 2, 2005 3:20:14 PM org.hibernate.cfg.Configuration addResource
INFO: Mapping resource: com/gloptv/smsc/Operator.hbm.xml
May 2, 2005 3:20:14 PM org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
INFO: Mapping class: com.gloptv.smsc.Operator -> operator
May 2, 2005 3:20:14 PM org.hibernate.cfg.Configuration addResource
INFO: Mapping resource: com/gloptv/smsc/SmsIn.hbm.xml
May 2, 2005 3:20:14 PM org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
INFO: Mapping class: com.gloptv.smsc.SmsIn -> sms_in
May 2, 2005 3:20:14 PM org.hibernate.cfg.Configuration addResource
INFO: Mapping resource: com/gloptv/smsc/Synchro.hbm.xml
May 2, 2005 3:20:14 PM org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
INFO: Mapping class: com.gloptv.smsc.Synchro -> synchro
May 2, 2005 3:20:14 PM org.hibernate.cfg.Configuration addResource
INFO: Mapping resource: com/gloptv/smsc/Keyword.hbm.xml
May 2, 2005 3:20:14 PM org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
INFO: Mapping class: com.gloptv.smsc.Keyword -> keyword
May 2, 2005 3:20:14 PM org.hibernate.cfg.Configuration addResource
INFO: Mapping resource: com/gloptv/smsc/Status.hbm.xml
May 2, 2005 3:20:15 PM org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
INFO: Mapping class: com.gloptv.smsc.Status -> status
May 2, 2005 3:20:15 PM org.hibernate.cfg.Configuration doConfigure
INFO: Configured SessionFactory: null
May 2, 2005 3:20:15 PM org.hibernate.cfg.Configuration secondPassCompile
INFO: processing extends queue
May 2, 2005 3:20:15 PM org.hibernate.cfg.Configuration secondPassCompile
INFO: processing collection mappings
May 2, 2005 3:20:15 PM org.hibernate.cfg.HbmBinder bindCollectionSecondPass
INFO: Mapping collection: com.gloptv.smsc.Customer.phoneNumbers -> phone_number
May 2, 2005 3:20:15 PM org.hibernate.cfg.HbmBinder bindCollectionSecondPass
INFO: Mapping collection: com.gloptv.smsc.User.customers -> customer
May 2, 2005 3:20:15 PM org.hibernate.cfg.HbmBinder bindCollectionSecondPass
INFO: Mapping collection: com.gloptv.smsc.Application.keywords -> keyword
May 2, 2005 3:20:15 PM org.hibernate.cfg.HbmBinder bindCollectionSecondPass
INFO: Mapping collection: com.gloptv.smsc.Application.parameters -> parameter
May 2, 2005 3:20:15 PM org.hibernate.cfg.HbmBinder bindCollectionSecondPass
INFO: Mapping collection: com.gloptv.smsc.PhoneNumber.keywords -> keyword
May 2, 2005 3:20:15 PM org.hibernate.cfg.HbmBinder bindCollectionSecondPass
INFO: Mapping collection: com.gloptv.smsc.Operator.synchros -> synchro
May 2, 2005 3:20:15 PM org.hibernate.cfg.HbmBinder bindCollectionSecondPass
INFO: Mapping collection: com.gloptv.smsc.Operator.smsIns -> sms_in
May 2, 2005 3:20:15 PM org.hibernate.cfg.HbmBinder bindCollectionSecondPass
INFO: Mapping collection: com.gloptv.smsc.SmsIn.smsOuts -> sms_out
May 2, 2005 3:20:15 PM org.hibernate.cfg.HbmBinder bindCollectionSecondPass
INFO: Mapping collection: com.gloptv.smsc.Keyword.smsIns -> sms_in
May 2, 2005 3:20:15 PM org.hibernate.cfg.HbmBinder bindCollectionSecondPass
INFO: Mapping collection: com.gloptv.smsc.Status.smsOuts -> sms_out
May 2, 2005 3:20:15 PM org.hibernate.cfg.Configuration secondPassCompile
INFO: processing association property references
May 2, 2005 3:20:15 PM org.hibernate.cfg.Configuration secondPassCompile
INFO: processing foreign key constraints
May 2, 2005 3:20:15 PM org.hibernate.dialect.Dialect <init>
INFO: Using dialect: org.hibernate.dialect.PostgreSQLDialect
May 2, 2005 3:20:15 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Default batch fetch size: 1
May 2, 2005 3:20:15 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Generate SQL with comments: disabled
May 2, 2005 3:20:15 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Order SQL updates by primary key: disabled
May 2, 2005 3:20:15 PM org.hibernate.cfg.SettingsFactory createQueryTranslatorFactory
INFO: Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
May 2, 2005 3:20:15 PM org.hibernate.hql.ast.ASTQueryTranslatorFactory <init>
INFO: Using ASTQueryTranslatorFactory
May 2, 2005 3:20:15 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Query language substitutions: {}
May 2, 2005 3:20:15 PM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Using Hibernate built-in connection pool (not for production use!)
May 2, 2005 3:20:15 PM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Hibernate connection pool size: 20
May 2, 2005 3:20:15 PM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: autocommit mode: false
May 2, 2005 3:20:15 PM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: using driver: org.postgresql.Driver at URL: jdbc:postgresql://192.168.2.1:5432/smsc
May 2, 2005 3:20:15 PM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: connection properties: {user=glop, password=****}
May 2, 2005 3:20:15 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC batch size: 15
May 2, 2005 3:20:15 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC batch updates for versioned data: disabled
May 2, 2005 3:20:15 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Scrollable result sets: enabled
May 2, 2005 3:20:15 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC3 getGeneratedKeys(): disabled
May 2, 2005 3:20:15 PM org.hibernate.transaction.TransactionFactoryFactory buildTransactionFactory
INFO: Transaction strategy: org.hibernate.transaction.JTATransactionFactory
May 2, 2005 3:20:15 PM org.hibernate.util.NamingHelper getInitialContext
INFO: JNDI InitialContext properties:{}
May 2, 2005 3:20:15 PM org.hibernate.transaction.TransactionManagerLookupFactory getTransactionManagerLookup
INFO: No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
May 2, 2005 3:20:15 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Automatic flush during beforeCompletion(): disabled
May 2, 2005 3:20:15 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Automatic session close at end of transaction: disabled
May 2, 2005 3:20:15 PM org.hibernate.cfg.SettingsFactory createCacheProvider
INFO: Cache provider: org.hibernate.cache.EhCacheProvider
May 2, 2005 3:20:15 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Second-level cache: enabled
May 2, 2005 3:20:15 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Optimize cache for minimal puts: disabled
May 2, 2005 3:20:15 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Structured second-level cache entries: enabled
May 2, 2005 3:20:15 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Query cache: disabled
May 2, 2005 3:20:15 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Statistics: disabled
May 2, 2005 3:20:15 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Deleted entity synthetic identifier rollback: disabled
May 2, 2005 3:20:15 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Default entity-mode: pojo
May 2, 2005 3:20:15 PM org.hibernate.impl.SessionFactoryImpl <init>
INFO: building session factory
May 2, 2005 3:20:15 PM net.sf.ehcache.config.Configurator configure
WARNING: No configuration found. Configuring ehcache from ehcache-failsafe.xml found in the classpath: jar:file:/C:/hibernate-3.0/lib/ehcach
e-1.1.jar!/ehcache-failsafe.xml
May 2, 2005 3:20:16 PM org.hibernate.impl.SessionFactoryObjectFactory addInstance
INFO: Not binding factory to JNDI, no JNDI name configured
May 2, 2005 3:20:16 PM org.hibernate.impl.SessionFactoryImpl checkNamedQueries
INFO: Checking 0 named queries
May 2, 2005 3:20:16 PM org.hibernate.transaction.JTATransaction begin
SEVERE: Could not find UserTransaction in JNDI
javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an ap
plication resource file: java.naming.factory.initial
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:640)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:243)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:280)
at javax.naming.InitialContext.lookup(InitialContext.java:347)
at org.hibernate.transaction.JTATransaction.begin(JTATransaction.java:57)
at org.hibernate.transaction.JTATransactionFactory.beginTransaction(JTATransactionFactory.java:52)
at org.hibernate.jdbc.JDBCContext.beginTransaction(JDBCContext.java:204)
at org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1014)
at com.gloptv.smsc.User.initLogin(Unknown Source)
at com.gloptv.smsc.User.<init>(Unknown Source)
at TestClient.login(Unknown Source)
at TestClient.main(Unknown Source)
Exception in thread "main" java.lang.Exception: Could not find UserTransaction in JNDI:
at com.gloptv.smsc.User.initLogin(Unknown Source)
at com.gloptv.smsc.User.<init>(Unknown Source)
at TestClient.login(Unknown Source)
at TestClient.main(Unknown Source)
[/b]
[b]Name and version of the database you are using:posgresql 8.0[/b]
[b]The generated SQL (show_sql=true):[/b]
[b]Debug level Hibernate log excerpt:[/b]
Can anyone please tell me how to solve the above error.
thanks in advance