-->
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.  [ 8 posts ] 
Author Message
 Post subject: How to configure hibernate to run outside servlet ?
PostPosted: Mon Dec 15, 2003 6:50 am 
Newbie

Joined: Mon Dec 15, 2003 6:25 am
Posts: 7
What is the recommended way to configure Hibernate without using a servlet environement ( pure J2SE ) for unit testing purpose? The Configuration class seems to provide a lot of way of setting JDBC connection and Hibernate properties but is not clear how to use it.

Is there any samples doing so around ( only found quickstart
which is servlet based ) ?

-- Alexis K


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 15, 2003 7:19 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Hi,

i have yesterday written a short introduction to hibernate, which is not using a servlet container. It is not completely finished but maybe you may find it useful:
http://gloeglnew.oktiron.net/8.html


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 15, 2003 9:42 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
There are a number of resources around:
On our wiki page http://hibernate.bluemars.net/78.html
you will find Nick has a nice intro http://www.systemmobile.com/articles/hibernate_intro.php, as well as one I think it appropriate http://files.blog-city.com/files/aa/1018/b/HibernateKickstart.html.

There are many resources if you look through the wiki.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 15, 2003 11:53 am 
Newbie

Joined: Mon Dec 15, 2003 6:25 am
Posts: 7
gloeglm : Thanks. We have tried your approach, but at run-time we get the following error:
Code:
Initializing Hibernate
[...]
- Transaction strategy:
             net.sf.hibernate.transaction.JDBCTransactionFactory
       
- TransactionFactory class not found
java.lang.ClassNotFoundException:
             net/sf/hibernate/transaction/JDBCTransactionFactory
       
   at java.lang.Class.forName0(Native Method)
   at java.lang.Class.forName(Class.java:141)
   at net.sf.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:255)
   at net.sf.hibernate.impl.SessionFactoryImpl.buildTransactionFactory(SessionFactoryImpl.java:469)
   at net.sf.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:184)
   at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:594)


Do you have any idea of what the cause might be ? We have all the .jar files that you indicates on the 'run' command line, but that does not seem to be enough.


david: Thanks for the links, we completly missed those external docs!

Alexis


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 15, 2003 12:14 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Are you using the current hibernate release? If yes, make sure you got the classpath-Thing for the run-command really correct. net.sf.hibernate.transaction.JDBCTransactionFactory should definately be included in the hibernate2.jar


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 15, 2003 12:53 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Hi, I added a zip of my devleopement directory to the page (at the bottom), you can try to download it and run the example from there.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 15, 2003 1:32 pm 
Newbie

Joined: Mon Dec 15, 2003 6:25 am
Posts: 7
Thank you gloeglm,

Because i noticed you used the cglib2.jar module i 've upgraded from Hibernate 2.0.3 to Hibernate 2.1 and it has workded after using the following command line ( some .jar are missing in your example ), thank you very much for your help!

Code:
java -classpath .\lib\hibernate2.jar;.\lib\jta.jar;.\lib\commons-logging.jar;.
\lib\mysql\mysql-connector-java-3.0.9-stable-bin.jar;.\lib\cglib2.jar;.\lib\commons-collections.jar;.\lib\dom4j.jar;.\li
b\odmg.jar;.\lib\commons-lang-1.0.1.jar;.\lib\commons-beanutils-1.6.1.jar;.\lib\cglib.jar;.\lib\commons-collections.jar;
.\out com.HibernateMain
Initializing Hibernate
log4j:WARN No appenders could be found for logger (net.sf.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
Finished Initializing Hibernate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 15, 2003 1:58 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Hi, you should definately not have both cglib.jar and cglib2.jar in your classpath.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 8 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.