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