-->
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: Is Hibernate.cfg.xml always needed?
PostPosted: Mon May 17, 2004 9:22 am 
Beginner
Beginner

Joined: Sun May 16, 2004 3:53 pm
Posts: 47
Location: Belo Horizonte, Brazil
Hi,
i'm trying to build my first hibernate app, but i'm also having problems.

I'm on JBoss 3.2.3 and Hibernate 2.1.

Is the file Hibernate.cfg.xml always needed? If it is, where should i include it?

I followed the "tutorial" at the site to use hibernate as an mbean in jboss,
so doesn't the jboss-service.xml do the whole service?

I'm getting an exception when trying to access the db and i don't know if it has something to do with the hibernate.cfg.file.

My exception is

10:18:42,921 INFO [STDOUT] Found jndi ok !!!
10:18:42,921 INFO [HibernateServiceMBean] starting service at JNDI name: java:/hibernate/SessionFactory
10:18:42,921 INFO [HibernateServiceMBean] service properties: {hibernate.session_factory_name=java:/hibernate/SessionFactory, hibernate.transaction.manager_lookup_class=net.sf.hibernate.transaction.JBossTransactionManagerLookup, hibernate.dialect=net.sf.hibernate.dialect.MySQLDialect, hibernate.show_sql=false, hibernate.use_outer_join=false, hibernate.transaction.factory_class=net.sf.hibernate.transaction.JTATransactionFactory, hibernate.connection.datasource=java:comp/env/jdbc/hibernate_test, jta.UserTransaction=UserTransaction}
10:18:42,921 INFO [Configuration] Mapping resource: hibernate/Person.hbm.xml
10:18:42,921 ERROR [LogInterceptor] RuntimeException:
net.sf.hibernate.LazyInitializationException: Hibernate lazy instantiation problem

For the following Session bean code
Code:
                Context ctx = new InitialContext();
   SessionFactory factory = (SessionFactory) ctx.lookup("java:/hibernate/SessionFactory");
   if (factory == null){
      System.out.println("Lookup returned NULL !!!");
   }
   System.out.println("Found jndi ok !!! ");
   Session session = factory.openSession();
   System.out.println("Opened session ok !!! ");



My jboss-service.xml is the following
Code:
<server>
   <mbean code="net.sf.hibernate.jmx.HibernateService" name="jboss.jca:service=Hibernate">
       <depends>jboss.jca:service=RARDeployer</depends>
       <attribute name="MapResources">hibernate/Person.hbm.xml</attribute>
       <attribute name="JndiName">java:/hibernate/SessionFactory</attribute>
       <attribute name="Datasource">java:comp/env/jdbc/hibernate_test</attribute>
       <attribute name="Dialect">net.sf.hibernate.dialect.MySQLDialect</attribute>
       <attribute name="UseOuterJoin">false</attribute>
       <attribute name="ShowSql">false</attribute>
       <attribute name="UserTransactionName">UserTransaction</attribute>
       <attribute name="TransactionStrategy">net.sf.hibernate.transaction.JTATransactionFactory</attribute>
       <attribute name="TransactionManagerLookupStrategy">net.sf.hibernate.transaction.JBossTransactionManagerLookup</attribute>
   </mbean>

</server>



Thanks a lot,
ltcmelo


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 17, 2004 10:43 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
You don't need the cfg.xml if you use the mbean.


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 17, 2004 11:06 am 
Beginner
Beginner

Joined: Sun May 16, 2004 3:53 pm
Posts: 47
Location: Belo Horizonte, Brazil
Thanks Michael,
ltcmelo


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.