Newsgroup: it.comp.java
Titolo: hibernate: SessionFactory

Egregi Signori, sono alle prese con la mia prima applicazione con
hibernate 3.x e non so più che pesci pigliare. Ho il seguente messaggio
dump dei log ma non riesco ad istanziare il SessionFactory ... mi date 
idee per favore?
19:29:06,578  INFO Environment:479 - Hibernate 3.1.3
19:29:06,593  INFO Environment:509 - hibernate.properties not found
19:29:06,593  INFO Environment:525 - using CGLIB reflection optimizer
19:29:06,656  INFO Environment:555 - using JDK 1.4 java.sql.Timestamp
handling
19:29:06,781  INFO Configuration:1308 - configuring from resource:
/hibernate.cfg.xml
19:29:06,781  INFO Configuration:1285 - Configuration resource:
/hibernate.cfg.xml
19:29:06,953  INFO Configuration:240 - Reading mappings from file:
NewmanMapping.hbm.xml
19:29:07,109  INFO HbmBinder:309 - Mapping class:
it.mibmagazine.hibernate.beans.User -> Users
19:29:07,125  INFO HbmBinder:1397 - Mapping collection:
it.mibmagazine.hibernate.beans.User.USERSFORGROUP -> GROUPS
19:29:07,125  INFO HbmBinder:309 - Mapping class:
it.mibmagazine.hibernate.beans.Group -> Groups
19:29:07,140  INFO HbmBinder:1397 - Mapping collection:
it.mibmagazine.hibernate.beans.Group.USERS_GROUP -> USERGROUP
19:29:07,140  INFO HbmBinder:309 - Mapping class:
it.mibmagazine.hibernate.beans.RssFeed -> RssFeeds
19:29:07,140  INFO HbmBinder:1397 - Mapping collection:
it.mibmagazine.hibernate.beans.RssFeed.NEWSFORFEED -> NEWSFEED
19:29:07,140  INFO HbmBinder:309 - Mapping class:
it.mibmagazine.hibernate.beans.Source -> Sources
19:29:07,140  INFO HbmBinder:1397 - Mapping collection:
it.mibmagazine.hibernate.beans.Source.RSS_FEEDS -> SOURCEFORCATEGORY
19:29:07,140  INFO HbmBinder:309 - Mapping class:
it.mibmagazine.hibernate.beans.Category -> Categories
19:29:07,140  INFO HbmBinder:309 - Mapping class:
it.mibmagazine.hibernate.beans.New -> News
19:29:07,140  INFO Configuration:1419 - Configured SessionFactory:
it.mibmagazine.hibernate.InitSessionFactory
19:29:07,328 DEBUG Application:191 - using: C:\Documents and
Settings\mess_2\workspace\newman\hibernate.cfg.xml as hibernate conf file
19:29:07,328  INFO Configuration:265 - Reading mappings from file:
C:\Documents and Settings\mess_2\workspace\newman\hibernate.cfg.xml
19:29:07,406  INFO DriverManagerConnectionProvider:41 - Using Hibernate
built-in connection pool (not for production use!)
19:29:07,406  INFO DriverManagerConnectionProvider:42 - Hibernate
connection pool size: 20
19:29:07,406  INFO DriverManagerConnectionProvider:45 - autocommit mode:
false
19:29:07,406  INFO DriverManagerConnectionProvider:80 - using driver:
com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost/newman
19:29:07,406  INFO DriverManagerConnectionProvider:86 - connection
properties: {user=root, password=****}
19:29:07,859  INFO SettingsFactory:77 - RDBMS: MySQL, version:
5.0.22-community-nt
19:29:07,859  INFO SettingsFactory:78 - JDBC driver: MySQL-AB JDBC
Driver, version: mysql-connector-java-3.1.12 ( $Date: 2005-11-17
15:53:48 +0100 (Thu, 17 Nov 2005) $, $Revision$ )
19:29:07,875  INFO Dialect:103 - Using dialect:
org.hibernate.dialect.MySQLDialect
19:29:07,890  INFO TransactionFactoryFactory:31 - Using default
transaction strategy (direct JDBC transactions)
19:29:07,890  INFO TransactionManagerLookupFactory:33 - No
TransactionManagerLookup configured (in JTA environment, use of
read-write or transactional second-level cache is not recommended)
19:29:07,890  INFO SettingsFactory:125 - Automatic flush during
beforeCompletion(): disabled
19:29:07,890  INFO SettingsFactory:129 - Automatic session close at end
of transaction: disabled
19:29:07,890  INFO SettingsFactory:136 - JDBC batch size: 15
19:29:07,890  INFO SettingsFactory:139 - JDBC batch updates for
versioned data: disabled
19:29:07,890  INFO SettingsFactory:144 - Scrollable result sets: enabled
19:29:07,890  INFO SettingsFactory:152 - JDBC3 getGeneratedKeys(): enabled
19:29:07,890  INFO SettingsFactory:160 - Connection release mode: auto
19:29:07,890  INFO SettingsFactory:184 - Maximum outer join fetch depth: 2
19:29:07,890  INFO SettingsFactory:187 - Default batch fetch size: 1
19:29:07,890  INFO SettingsFactory:191 - Generate SQL with comments:
disabled
19:29:07,890  INFO SettingsFactory:195 - Order SQL updates by primary
key: disabled
19:29:07,890  INFO SettingsFactory:338 - Query translator:
org.hibernate.hql.ast.ASTQueryTranslatorFactory
19:29:07,906  INFO ASTQueryTranslatorFactory:24 - Using
ASTQueryTranslatorFactory
19:29:07,906  INFO SettingsFactory:203 - Query language substitutions: {}
19:29:07,906  INFO SettingsFactory:209 - Second-level cache: enabled
19:29:07,906  INFO SettingsFactory:213 - Query cache: disabled
19:29:07,906  INFO SettingsFactory:325 - Cache provider:
org.hibernate.cache.EhCacheProvider
-- 
Mess
http://www.mibmagazine.it

non riesco a vederlo l'errore
Mess ha scritto:


 
scusa adesso ?
--------------------------------------------------------------------------
java it/mibmagazine/hibernate/TestInsert
Punto 0
Static part 0
- Hibernate 3.1.3
- hibernate.properties not found
- using CGLIB reflection optimizer
- using JDK 1.4 java.sql.Timestamp handling
- configuring from resource: /hibernate.cfg.xml
- Configuration resource: /hibernate.cfg.xml
- Reading mappings from file: NewmanMapping.hbm.xml
- Mapping class: it.mibmagazine.hibernate.beans.User -> Users
- Mapping collection: it.mibmagazine.hibernate.beans.User.USERSFORGROUP
-> GROUPS
- Mapping class: it.mibmagazine.hibernate.beans.Group -> Groups
- Mapping collection: it.mibmagazine.hibernate.beans.Group.USERS_GROUP
-> USERGROUP
- Mapping class: it.mibmagazine.hibernate.beans.RssFeed -> RssFeeds
- Mapping collection: it.mibmagazine.hibernate.beans.RssFeed.NEWSFORFEED
-> NEWSFEED
- Mapping class: it.mibmagazine.hibernate.beans.Source -> Sources
- Mapping collection: it.mibmagazine.hibernate.beans.Source.RSS_FEEDS ->
SOURCEFORCATEGORY
- Mapping class: it.mibmagazine.hibernate.beans.Category -> Categories
- Mapping class: it.mibmagazine.hibernate.beans.New -> News
- Configured SessionFactory:
it.mibmagazine.hibernate.SingletonSessionFactory
- Using Hibernate built-in connection pool (not for production use!)
- Hibernate connection pool size: 20
- autocommit mode: false
- using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost/mib
- connection properties: {user=root, password=****}
- RDBMS: MySQL, version: 5.0.18-Debian_9-log
- JDBC driver: MySQL-AB JDBC Driver, version:
mysql-connector-java-3.1.12 ( $Date: 2005-11-17 15:53:48 +0100 (Thu, 17
Nov 2005) $, $Revision$ )
- Using dialect: org.hibernate.dialect.MySQLDialect
- Using default transaction strategy (direct JDBC transactions)
- No TransactionManagerLookup configured (in JTA environment, use of
read-write or transactional second-level cache is not recommended)
- Automatic flush during beforeCompletion(): disabled
- Automatic session close at end of transaction: disabled
- JDBC batch size: 15
- JDBC batch updates for versioned data: disabled
- Scrollable result sets: enabled
- JDBC3 getGeneratedKeys(): enabled
- Connection release mode: auto
- Maximum outer join fetch depth: 2
- Default batch fetch size: 1
- Generate SQL with comments: disabled
- Order SQL updates by primary key: disabled
- Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
- Using ASTQueryTranslatorFactory
- Query language substitutions: {}
- Second-level cache: enabled
- Query cache: disabled
- Cache provider: org.hibernate.cache.EhCacheProvider
Exception in thread "main" java.lang.NoClassDefFoundError
         at
it.mibmagazine.hibernate.DbInsertion.autoCommit(DbInsertion.java:60)
         at it.mibmagazine.hibernate.TestInsert.main(TestInsert.java:19)
-- 
Mess
http://www.mibmagazine.it

mi sa che hai dimenticato il jar
ehcache-1.1.jar
prova ad aggiungerlo, sta nella distribuzione di hibernate
se hai tempo vedi se riesci a rispondere al mio post
http://groups.google.it/group/it.comp.java/browse_thread/thread/ee2c12895e93279a/bf93af2e4d505c77?hl=it#bf93af2e4d505c77
fammi sapere se hai risolto ciao
Mess ha scritto:


mi sa che forse non ti trova la classe
DbInsertion.java
Mess ha scritto:


 
in effetto con il tuo consiglio c'č stato un passo in avanti ... ma 
continuo ad avere problemi e sto hibernate me ne sta dando piů di quelli 
che mi sta risolvendo.
Ti faccio cut and paste del mio dump da consolle:
17:59:27,234  INFO Environment:479 - Hibernate 3.1.3
17:59:27,234  INFO Environment:509 - hibernate.properties not found
17:59:27,234  INFO Environment:525 - using CGLIB reflection optimizer
17:59:27,234  INFO Environment:555 - using JDK 1.4 java.sql.Timestamp 
handling
%%%% Error Creating HibernateSessionFactory %%%%
javax.naming.NoInitialContextException: Need to specify class name in 
environment or system property, or as an applet parameter, or in an 
application resource file:  java.naming.factory.initial
	at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
	at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
	at javax.naming.InitialContext.getURLOrDefaultInitCtx(Unknown Source)
	at javax.naming.InitialContext.lookup(Unknown Source)
	at 
it.mibmagazine.hibernate.InitSessionFactory.initSessionFactory(InitSessionFactory.java:116)17:59:27,312 
DEBUG InitSessionFactory:110 - Loading cfg file: C:\Documents and 
Settings\mess_2\workspace\newman\hibernate.cfg.xml
17:59:27,312  INFO Configuration:1308 - configuring from resource: 
/hibernate.cfg.xml
17:59:27,312  INFO Configuration:1285 - Configuration resource: 
/hibernate.cfg.xml
17:59:27,421  INFO Configuration:240 - Reading mappings from file: 
NewmanMapping.hbm.xml
17:59:27,546  INFO HbmBinder:309 - Mapping class: 
it.mibmagazine.hibernate.beans.User -> Users
17:59:27,578  INFO HbmBinder:1397 - Mapping collection: 
it.mibmagazine.hibernate.beans.User.USERSFORGROUP -> GROUPS
17:59:27,578  INFO HbmBinder:309 - Mapping class: 
it.mibmagazine.hibernate.beans.Group -> Groups
17:59:27,578  INFO HbmBinder:1397 - Mapping collection: 
it.mibmagazine.hibernate.beans.Group.USERS_GROUP -> USERGROUP
17:59:27,578  INFO HbmBinder:309 - Mapping class: 
it.mibmagazine.hibernate.beans.RssFeed -> RssFeeds
17:59:27,578  INFO HbmBinder:1397 - Mapping collection: 
it.mibmagazine.hibernate.beans.RssFeed.NEWSFORFEED -> NEWSFEED
17:59:27,578  INFO HbmBinder:309 - Mapping class: 
it.mibmagazine.hibernate.beans.Source -> Sources
17:59:27,578  INFO HbmBinder:1397 - Mapping collection: 
it.mibmagazine.hibernate.beans.Source.RSS_FEEDS -> SOURCEFORCATEGORY
17:59:27,578  INFO HbmBinder:309 - Mapping class: 
it.mibmagazine.hibernate.beans.Category -> Categories
17:59:27,593  INFO HbmBinder:309 - Mapping class: 
it.mibmagazine.hibernate.beans.New -> News
17:59:27,593  INFO Configuration:1419 - Configured SessionFactory: 
it.mibmagazine.hibernate.InitSessionFactory
17:59:27,593  INFO Configuration:265 - Reading mappings from file: 
C:\Documents and Settings\mess_2\workspace\newman\hibernate.cfg.xml
17:59:27,671  INFO DriverManagerConnectionProvider:41 - Using Hibernate 
built-in connection pool (not for production use!)
17:59:27,671  INFO DriverManagerConnectionProvider:42 - Hibernate 
connection pool size: 20
17:59:27,671  INFO DriverManagerConnectionProvider:45 - autocommit mode: 
false
17:59:27,671  INFO DriverManagerConnectionProvider:80 - using driver: 
com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost/newman
17:59:27,671  INFO DriverManagerConnectionProvider:86 - connection 
properties: {user=root, password=****}
17:59:27,890  INFO SettingsFactory:77 - RDBMS: MySQL, version: 
5.0.22-community-nt
17:59:27,890  INFO SettingsFactory:78 - JDBC driver: MySQL-AB JDBC 
Driver, version: mysql-connector-java-3.1.12 ( $Date: 2005-11-17 
15:53:48 +0100 (Thu, 17 Nov 2005) $, $Revision$ )
17:59:27,906  INFO Dialect:103 - Using dialect: 
org.hibernate.dialect.MySQLDialect
17:59:27,921  INFO TransactionFactoryFactory:31 - Using default 
transaction strategy (direct JDBC transactions)
17:59:27,921  INFO TransactionManagerLookupFactory:33 - No 
TransactionManagerLookup configured (in JTA environment, use of 
read-write or transactional second-level cache is not recommended)
17:59:27,921  INFO SettingsFactory:125 - Automatic flush during 
beforeCompletion(): disabled
17:59:27,921  INFO SettingsFactory:129 - Automatic session close at end 
of transaction: disabled
17:59:27,921  INFO SettingsFactory:136 - JDBC batch size: 15
17:59:27,921  INFO SettingsFactory:139 - JDBC batch updates for 
versioned data: disabled
17:59:27,921  INFO SettingsFactory:144 - Scrollable result sets: enabled
17:59:27,921  INFO SettingsFactory:152 - JDBC3 getGeneratedKeys(): enabled
17:59:27,921  INFO SettingsFactory:160 - Connection release mode: auto
17:59:27,921  INFO SettingsFactory:184 - Maximum outer join fetch depth: 2
17:59:27,921  INFO SettingsFactory:187 - Default batch fetch size: 1
17:59:27,921  INFO SettingsFactory:191 - Generate SQL with comments: 
disabled
17:59:27,921  INFO SettingsFactory:195 - Order SQL updates by primary 
key: disabled
17:59:27,921  INFO SettingsFactory:338 - Query translator: 
org.hibernate.hql.ast.ASTQueryTranslatorFactory
17:59:27,937  INFO ASTQueryTranslatorFactory:24 - Using 
ASTQueryTranslatorFactory
17:59:27,937  INFO SettingsFactory:203 - Query language substitutions: {}
17:59:27,937  INFO SettingsFactory:209 - Second-level cache: enabled
17:59:27,937  INFO SettingsFactory:213 - Query cache: disabled
17:59:27,937  INFO SettingsFactory:325 - Cache provider: 
org.hibernate.cache.EhCacheProvider
17:59:27,937  INFO SettingsFactory:228 - Optimize cache for minimal 
puts: disabled
17:59:27,937  INFO SettingsFactory:237 - Structured second-level cache 
entries: disabled
17:59:27,937  INFO SettingsFactory:257 - Echoing all SQL to stdout
17:59:27,937  INFO SettingsFactory:264 - Statistics: disabled
17:59:27,937  INFO SettingsFactory:268 - Deleted entity synthetic 
identifier rollback: disabled
17:59:27,937  INFO SettingsFactory:283 - Default entity-mode: pojo
17:59:27,968  INFO SessionFactoryImpl:154 - building session factory
17:59:28,015 DEBUG CacheManager:191 - Creating new CacheManager with 
default config
17:59:28,015 DEBUG CacheManager:164 - Configuring ehcache from classpath.
17:59:28,031  WARN Configurator:126 - No configuration found. 
Configuring ehcache from ehcache-failsafe.xml found in the classpath: 
jar:file:/C:/Documents%20and%20Settings/mess_2/workspace/newman/lib/ehcache-1.1.jar!/ehcache-failsafe.xml
17:59:28,031 DEBUG Configuration$DiskStore:185 - Disk Store Path: 
C:\DOCUME~1\mess_2\IMPOST~1\Temp\
17:59:28,453  INFO SessionFactoryObjectFactory:86 - Factory name: 
it.mibmagazine.hibernate.InitSessionFactory
17:59:28,468  INFO NamingHelper:26 - JNDI InitialContext properties:{}
17:59:28,468  WARN SessionFactoryObjectFactory:98 - Could not bind 
factory to JNDI
javax.naming.NoInitialContextException: Need to specify class name in 
environment or system property, or as an applet parameter, or in an 
application resource file:  java.naming.factory.initial
	at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
	at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
	at javax.naming.InitialContext.getURLOrDefaultInitCtx(Unknown Source)
	at javax.naming.InitialContext.getNameParser(Unknown Source)
	at org.hibernate.util.NamingHelper.bind(NamingHelper.java:52)
	at 
org.hibernate.impl.SessionFactoryObjectFactory.addInstance(SessionFactoryObjectFactory.java:90)
	at 
org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:291)
	at 
org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1176)
	at 
it.mibmagazine.hibernate.InitSessionFactory.initSessionFactory(InitSessionFactory.java:114)
	at 
it.mibmagazine.hibernate.InitSessionFactory.getInstance(InitSessionFactory.java:62)
	at it.mibmagazine.hibernate.beans.NewTest.testOne(NewTest.java:21)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at junit.framework.TestCase.runTest(TestCase.java:154)
	at junit.framework.TestCase.runBare(TestCase.java:127)
	at junit.framework.TestResult$1.protect(TestResult.java:106)
	at junit.framework.TestResult.runProtected(TestResult.java:124)
	at junit.framework.TestResult.run(TestResult.java:109)
	at junit.framework.TestCase.run(TestCase.java:118)
	at junit.framework.TestSuite.runTest(TestSuite.java:208)
	at junit.framework.TestSuite.run(TestSuite.java:203)
	at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478)
	at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
	at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
17:59:28,468 DEBUG InitSessionFactory:115 - get a jndi session factory
	at 
it.mibmagazine.hibernate.InitSessionFactory.getInstance(InitSessionFactory.java:62)
	at it.mibmagazine.hibernate.beans.NewTest.testOne(NewTest.java:21)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at junit.framework.TestCase.runTest(TestCase.java:154)
	at junit.framework.TestCase.runBare(TestCase.java:127)
	at junit.framework.TestResult$1.protect(TestResult.java:106)
	at junit.framework.TestResult.runProtected(TestResult.java:124)
	at junit.framework.TestResult.run(TestResult.java:109)
	at junit.framework.TestCase.run(TestCase.java:118)
	at junit.framework.TestSuite.runTest(TestSuite.java:208)
	at junit.framework.TestSuite.run(TestSuite.java:203)
	at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478)
	at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
	at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
-- 
Mess
http://www.mibmagazine.it

in realtà quello che non trova è un JNDI che ancora non mi è 
perfettamente chiaro di che si tratti...Quello che segue è un frammento 
dei log dell'applicazione.
----------------------------------------------------
09:38:06,109  WARN SessionFactoryObjectFactory:98 - Could not bind 
factory to JNDI
----------------------------------------------------
Ringrazio tutti
-- 
Mess
http://www.mibmagazine.it


per il fatto che ti da più problemi di quanti te ne risolva è
normale.
Ho appena iniziato a studiarlo anch'io. E' uno strumento molto potente
e per questo anche abbastanza complesso e se lo si vuole utilizzare al
meglio tocca studiare..
Il JNDI è un servizio nel application server (tomcat, jboss, oc4j..
ecc). Nel caso di hibernate il servizio jndi mette a disposizione le
definizioni dei datasource per l'accesso ai Db.. Io uso Jboss (il
motore è quello di tomcat), specifico un file xml contenete le info
per l'accesso a db.
Per l'errore che ti da prova a mettere questo nel file di
configurazione hibernate.cfg.xml se ancora non l'hai fatto
<property
name="hibernate.current_session_context_class">org.hibernate.context.ThreadLocalSessionContext</property>
prova a vedere che ti dice
Mess ha scritto:


io avevo messo semplicemente questa riga:
<property name="hibernate.current_session_context_class">thread</property>
ma scusa poi perchè non possono mettere un JNDI nella lib di hibernate 
come per tutti gli altri jar ?

-- 
Mess
http://www.mibmagazine.it

si quella riga dovrebbe fare lo stesso
il file jndi nella lib di hibernate che c'entra? una libreria di solito
la si importa e la si utilizza per il suo fine senza modificarla.
cerca su google come fare ad utilizzare un servizio jndi ci sono
milioni di esempi. cerca come si configura qs con il tuo appserver
(penso userai tomcat).
ciao
Mess ha scritto:


hibernate non è semplicissimo ripeto, ti coviene scaricarti un libro e
iniziare a studiare.. di solito se l'argomento è complesso si perde
molto più tempo a cercare es su internet che a leggersi un lib di 600
pag.,
Mess ha scritto:


 
Senza offesa ma io ho letto i primi 4 (ormai 5) capitoli del libro 
"Hibernate in action" e sinceramente mi ha dato delle interessanti base 
teoriche su come hibernate modella ORM, come ottimizzare le relazioni 
tra entità, sulla sua struttura interna ecc ecc ma non da nessuna 
indicazione su come far girare la prima applicazione. La dritta che mi 
hai dato tu in merito al file ehcache.jar non è scritta da nessuna 
parte. I problemi che ho riportato nei post precedenti riguardano 
proprio l'inizializzazione di hibernate che non avviene ed il supporto 
in questo senso è davvero scarso.
Adesso io sto scrivendo un'applicazione stand-alone che non gira né con 
JBoss né con Tomcat.... come faccio ? hibernate mi serve solo per poter 
  rappresentare velocemente delle entità in un DB ma non è il core 
dell'applicazione.
Ti ringrazio molto per qualunque suggerimento
saluti
-- 
Mess
http://www.mibmagazine.it

4-5 capitoli!! Allora sei messo meglo di me!! ;)
Si di materiale completo, esempi e cose funzionanti se ne trovano
davvero poche.
Io parecchi dubbi e problemi li ho risolti scrivendo sul forum di
hibernate
Se gira stand-alone penso il discorso jndi cade. Devi configurarti
manualmente i datasource nel file hibernate.cfg.xml
una cosa del tipo
<property
name="hibernate.bytecode.use_reflection_optimizer">false</property>
        <property
name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
        <property
name="hibernate.connection.password">tuaPasswordperAccessoDB</property>
        <property
name="hibernate.connection.url">jdbc:oracle:thin:@localhost:1521:orcl</property>
        <property
name="hibernate.connection.username">tuaUsernamePerAccessoDB</property>
        <property
name="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect</property>
        <property name="show_sql">true</property>
        <property
name="hibernate.current_session_context_class">org.hibernate.context.ThreadLocalSessionContext</property>
così le definizioni di accesso non le tira su dal JNDI ma le metti
dirette nell'xml di configurazione di hibernate
vedi un po che ti dice
ricordati di mettere questo xml nei source. così come i file xml di
mapping tra le classi java e le tabelle db
Mess ha scritto:


Egregio sickness, sembrerò pedante e rompiscatole ma continua a cercarmi 
  il famoso JNDI... e non so che pesci pigliare.
Ti incollo di seguito il mio hibernate.cfg.xml ... possibile che sia 
l'unico ad avere questi problemi ?
<?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 name="it.mibmagazine.hibernate.SingletonSessionFactory">
		<property name="hibernate.connection.driver_class">
			com.mysql.jdbc.Driver
		</property>
		<property name="hibernate.connection.url">
			jdbc:mysql://localhost/newman
		</property>
		<property name="hibernate.connection.username">spank</property>
		<property name="hibernate.connection.password">password</property>
		<!--  SQL Dialect -->
		<property name="hibernate.dialect">
			org.hibernate.dialect.MySQLDialect
		</property>
		<!-- JDBC connection pool (use the built-in) -->
		<property name="hibernate.connection.pool_size">20</property>
		<!-- Enable Hibernate's automatic session context management
		<property name="hibernate.current_session_context_class">
			thread
		</property> -->
 
		<!-- Echo all executed SQL to stdout -->
		<property name="show_sql">true</property>
	    <property 
name="hibernate.current_session_context_class">org.hibernate.context.ThreadLocalSessionContext</property>
		<property 
name="hibernate.bytecode.use_reflection_optimizer">false</property>
		<!-- Mapping file with DB schema -->
		<mapping file="NewmanMapping.hbm.xml" />		
	</session-factory>
</hibernate-configuration>


non so forse hai scritto qualche classe per hibernate che fa la lookup
del servizio jndi?
Mess ha scritto:


Così per così ti direi di no ... dal momento che nella mia applicazione 
non vi è nessun riferimento a JNDI ma cosa ci fa hibernate lo ignoro ... 
conosci qualche modo per verificarlo ?

-- 
Mess
http://www.mibmagazine.it

Ciao, per la mia applicazione standalone ho risolto passando questo
parametro a java.
java -cp aaa;naming-xyz.jar....
-Djava.naming.factory.initial=org.apache.naming.java.javaURLContextFactory
  -jar qualcosa.jar XyxMain
Puoi vedere in
http://directory.apache.org
Non so se c'è qualche altra libreria da inserire
Michele.


Egregi ... sono riuscito a risolvere adesso scrive nel DB. Il problema 
era da gestire su due livelli. Uno č il file di configurazione l'altro č 
il codice con il quale si persistono gli oggetti.
Il primo punto basta togliere la dichiarazione della classe 
SessionFactory in hibernate.cfg.xml lasciando solo il tag 
<session-factory> senza l'attributo name. In questo modo lui non cerca 
di fare il binding via JNDI.
A questo punto quando č necessario persistere un oggetto basta il codice 
seguente:
Session sess = InitSessionFactory.getInstance().getCurrentSession();
Transaction tx = sess.beginTransaction();
MyObj _o= new MyObj();
_o.setProp1("This is a test meessage!");
_o.setProp2("TEST FROM MESS ");
sess.save(_o);
tx.commit();
Ringrazio davvero tutti per il loro contributo in particolare sickness.
-- 
Mess
http://www.mibmagazine.it

 A questo punto quando è necessario persistere un oggetto basta il codice


Ho un prob hibernate, mi connetto via jodbc a oracle8i tutto ok poi lui non
mi vede li schema perche?
Puo  essere uun bug cin oracle8i?
bye