-->
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: unable to buildSessionFactory()
PostPosted: Thu Mar 31, 2005 11:04 am 
Newbie

Joined: Thu Mar 31, 2005 10:37 am
Posts: 2
Location: Halle, Germany
Hibernate version:
3.0rc1
Mapping documents:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping
PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>
<class name="src.test.hibernate.Order" table="orders">
<id name="id" type="string" unsaved-value="null" >
<column name="id" sql-type="char(32)"
not-null="true"/>
<generator class="uuid.hex"/>
</id>
<property name="date">
<column name="order_date" sql-type="datetime" not-null="true"/>
</property>

<property name="priceTotal">
<column name="price_total" sql-type="double" not-null="true"/>
</property>

<set name="orderItems" table="order_items" inverse="true" cascade="all">
<key column="order_id" />
<one-to-many class="src.test.hibernate.OrderItem" />
</set>
</class>

</hibernate-mapping>

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping
PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>

<class name="src.test.hibernate.OrderItem" table="order_items">

<!-- A 32 hex character is our surrogate key. It's automatically
generated by Hibernate with the UUID pattern. -->
<id name="id" type="string" unsaved-value="null" >
<column name="id" sql-type="char(32)" not-null="true"/>
<generator class="uuid.hex"/>
</id>

<property name="orderId" insert="false" update="false">
<column name="order_id" sql-type="char(32)" not-null="true"/>
</property>

<property name="productId" insert="false" update="false">
<column name="product_id" sql-type="char(32)" not-null="true"/>
</property>


<property name="amount">
<column name="amount" sql-type="int" not-null="true"/>
</property>


<property name="price">
<column name="price" sql-type="double" not-null="true"/>
</property>

<many-to-one name="order" class="src.test.hibernate.Order" column="order_id" />
<many-to-one name="product" class="src.test.hibernate.Product" cascade="save-update" column="product_id"/>

</class>

</hibernate-mapping>

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping
PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>

<class name="src.test.hibernate.Product" table="products">

<!-- A 32 hex character is our surrogate key. It's automatically
generated by Hibernate with the UUID pattern. -->
<id name="id" type="string" unsaved-value="null" >
<column name="id" sql-type="char(32)" not-null="true"/>
<generator class="uuid.hex"/>
</id>

<property name="name">
<column name="name" sql-type="char(255)" not-null="true"/>
</property>

<property name="price">
<column name="price" sql-type="double" not-null="true"/>
</property>

<property name="amount">
<column name="amount" sql-type="integer" not-null="true"/>
</property>
</class>

</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
package src.test;

import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Query;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
import src.test.hibernate.Order;
import src.test.hibernate.OrderItem;
import src.test.hibernate.Product;

public class InsertOrder {

public static void main(String[] args) throws Exception {
String q =
"select product from product "
+ "in class src.test.hibernate.Product "
+ "where lower(product.name)=lower(:name)";

Configuration cfg = new Configuration()
.addClass(Product.class)
.addClass(Order.class)
.addClass(OrderItem.class);

SessionFactory sf = cfg.buildSessionFactory();

Session sess = sf.openSession();


+++ and futher code, but the error occurs during buildSessionFactory()!

Full stack trace of any exception that occurs:
java.lang.NoClassDefFoundError: javax/transaction/SystemException
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:140)
at org.hibernate.id.IdentifierGeneratorFactory.class$(IdentifierGeneratorFactory.java:25)
at org.hibernate.id.IdentifierGeneratorFactory.<clinit>(IdentifierGeneratorFactory.java:76)
at org.hibernate.mapping.SimpleValue.createIdentifierGenerator(SimpleValue.java:111)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:166)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1043)
at src.test.InsertOrder.main(InsertOrder.java:26)
Exception in thread "main" 
Name and version of the database you are using:

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:
16:02:20,156 INFO Environment:456 - Hibernate 3.0rc1
16:02:20,234 INFO Environment:474 - loaded properties from resource hibernate.properties: {hibernate.cglib.use_reflection_optimizer=true, hibernate.dialect=org.hibernate.dialect.MySQLInnoDBDialect}
16:02:20,234 INFO Environment:502 - using CGLIB reflection optimizer
16:02:20,250 INFO Environment:532 - using JDK 1.4 java.sql.Timestamp handling
16:02:20,281 INFO Configuration:459 - Mapping resource: src/test/hibernate/Product.hbm.xml
16:02:21,718 INFO HbmBinder:256 - Mapping class: src.test.hibernate.Product -> products
16:02:21,843 INFO Configuration:459 - Mapping resource: src/test/hibernate/Order.hbm.xml
16:02:21,906 INFO HbmBinder:256 - Mapping class: src.test.hibernate.Order -> orders
16:02:21,937 INFO Configuration:459 - Mapping resource: src/test/hibernate/OrderItem.hbm.xml
16:02:22,000 INFO HbmBinder:256 - Mapping class: src.test.hibernate.OrderItem -> order_items
16:02:22,265 INFO Configuration:844 - processing extends queue
16:02:22,265 INFO Configuration:848 - processing collection mappings
16:02:22,265 INFO HbmBinder:1951 - Mapping collection: src.test.hibernate.Order.orderItems -> order_items
16:02:22,265 INFO Configuration:857 - processing association property references
16:02:22,265 INFO Configuration:884 - processing foreign key constraints
16:02:22,406 INFO Dialect:89 - Using dialect: org.hibernate.dialect.MySQLInnoDBDialect
16:02:22,437 INFO SettingsFactory:87 - Maximum outer join fetch depth: 2
16:02:22,437 INFO SettingsFactory:90 - Default batch fetch size: 1
16:02:22,468 INFO SettingsFactory:94 - Generate SQL with comments: disabled
16:02:22,468 INFO SettingsFactory:98 - Order SQL updates by primary key: disabled
16:02:22,468 INFO SettingsFactory:273 - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
16:02:22,531 INFO ASTQueryTranslatorFactory:21 - Using ASTQueryTranslatorFactory
16:02:22,531 INFO SettingsFactory:106 - Query language substitutions: {}
16:02:22,546 WARN UserSuppliedConnectionProvider:23 - No connection properties specified - the user must supply JDBC connections
16:02:22,546 INFO SettingsFactory:148 - JDBC batch size: 15
16:02:22,546 INFO SettingsFactory:151 - JDBC batch updates for versioned data: disabled
16:02:22,546 INFO SettingsFactory:156 - Scrollable result sets: disabled
16:02:22,546 INFO SettingsFactory:164 - JDBC3 getGeneratedKeys(): disabled
16:02:22,546 INFO TransactionFactoryFactory:31 - Using default transaction strategy (direct JDBC transactions)
16:02:22,562 INFO TransactionManagerLookupFactory:33 - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
16:02:22,562 INFO SettingsFactory:176 - Automatic flush during beforeCompletion(): disabled
16:02:22,562 INFO SettingsFactory:179 - Automatic session close at end of transaction: disabled
16:02:22,562 INFO SettingsFactory:260 - Cache provider: org.hibernate.cache.EhCacheProvider
16:02:22,578 INFO SettingsFactory:187 - Second-level cache: enabled
16:02:22,578 INFO SettingsFactory:192 - Optimize cache for minimal puts: disabled
16:02:22,578 INFO SettingsFactory:199 - Structured second-level cache entries: enabled
16:02:22,578 INFO SettingsFactory:203 - Query cache: disabled
16:02:22,578 INFO SettingsFactory:214 - Statistics: disabled
16:02:22,578 INFO SettingsFactory:218 - Deleted entity synthetic identifier rollback: disabled
16:02:22,593 INFO SettingsFactory:232 - Default entity-mode: pojo
16:02:27,718 INFO SessionFactoryImpl:140 - building session factory
16:02:27,921 WARN Configurator:126 - No configuration found. Configuring ehcache from ehcache-failsafe.xml found in the classpath: jar:file:/E:/vtiller/myWebApps/HibernateArticle/lib/ehcache-1.1.jar!/ehcache-failsafe.xml


Executing different tutorial examples always results in that exception
while building the sessionFactory.

Please help me starting with Hibernate.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 31, 2005 2:16 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
read the stacktrace ;)

you are mising a .jar in your classpath - namelyg jta.jar

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 04, 2005 2:34 am 
Newbie

Joined: Thu Mar 31, 2005 10:37 am
Posts: 2
Location: Halle, Germany
Thank you so much, Max, now it works.


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.