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.  [ 2 posts ] 
Author Message
 Post subject: LazyInitialization exception, what might it be ???
PostPosted: Sun May 16, 2004 11:42 pm 
Beginner
Beginner

Joined: Sun May 16, 2004 3:53 pm
Posts: 47
Location: Belo Horizonte, Brazil
Hi,
i'm trying my first Hibernate app. I "think" i got configuration handled, but...

Here's my Session ejb wich tries to access db
Code:
//...
try {
   Context ctx = new InitialContext();
   SessionFactory factory = (SessionFactory) ctx.lookup("hibernate/SessionFactory");
   System.out.println("Found jndi ok !!! ");
   Session session = factory.openSession();
   System.out.println("Opened sessin ok !!! ");
   Person person = (Person)session.load(Person.class, id);
   System.out.println("Loaded class ok !!! ");
//...



And wich generates the following runtime exception

00:32:45,671 INFO [Configuration] Mapping resource: hibernate/Person.hbm.xml
00:32:45,671 ERROR [LogInterceptor] RuntimeException:
net.sf.hibernate.LazyInitializationException: Hibernate lazy instantiation problem


From the debug info i put inside the code, i can see the everything goes ok right untill the System.out.println("Found jndi ok !!!), as the server print it on console. So, the error happens in the following line (i guess).

Also, my jboss-service 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">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>


Thank you very much for any help,
ltcmelo


Top
 Profile  
 
 Post subject: LazyInitialization exception, what might it be ???
PostPosted: Mon May 17, 2004 12:00 am 
Beginner
Beginner

Joined: Sun May 16, 2004 3:53 pm
Posts: 47
Location: Belo Horizonte, Brazil
Just one more comment.
Actually i think the error is in the lookup section, as the last line i see printed on console is Found jndi ok, and when it tries to open the session... ERROR.
Anyway, i don't know exactly what could be wrong.


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