-->
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: Hibernate Example not working, and not throwing an exception
PostPosted: Fri Apr 09, 2004 3:36 pm 
Beginner
Beginner

Joined: Thu Feb 26, 2004 6:42 pm
Posts: 24
Hello,
I am using jdk1.4, hibernate 2.1.2, struts with tomcat 5.0.19. I have configured and tested my jndi data source from a plugin that I wrote for struts. Now I am trying to run the CAT Hibernate example but it does not seem to work. The Tomcat Console looks as follows

INFO: Loading validation rules file from '/WEB-INF/validator-rules.xml'
Apr 9, 2004 2:15:43 PM org.apache.struts.validator.ValidatorPlugIn initResources

INFO: Loading validation rules file from '/WEB-INF/validation.xml'
[b]**************************
**************************
**************************
**************************
**************************
**************1************
***************1***********
****************1**********
*****************1*********
******************1********
Apr 9, 2004 2:15:43 PM net.sf.hibernate.cfg.Environment <clinit>
INFO: Hibernate 2.1.2
Apr 9, 2004 2:15:43 PM net.sf.hibernate.cfg.Environment <clinit>
INFO: hibernate.properties not found
Apr 9, 2004 2:15:43 PM net.sf.hibernate.cfg.Environment <clinit>
INFO: using CGLIB reflection optimizer
Apr 9, 2004 2:15:43 PM net.sf.hibernate.cfg.Configuration configure
INFO: configuring from resource: /hibernate.cfg.xml
Apr 9, 2004 2:15:43 PM net.sf.hibernate.cfg.Configuration getConfigurationInputS
tream
INFO: Configuration resource: /hibernate.cfg.xml
Apr 9, 2004 2:15:43 PM net.sf.hibernate.cfg.Configuration addResource
INFO: Mapping resource: Cenet.hbm.xml
Apr 9, 2004 2:15:43 PM net.sf.hibernate.cfg.Binder bindRootClass
INFO: Mapping class: com.sbc.hrtech.loa.server.hibernate.Cenet -> CENET
Apr 9, 2004 2:15:44 PM net.sf.hibernate.cfg.Configuration addResource
INFO: Mapping resource: Cat.hbm.xml
Apr 9, 2004 2:15:44 PM net.sf.hibernate.cfg.Configuration addResource
INFO: Mapping resource: Cat.hbm.xml
Apr 9, 2004 2:15:44 PM org.apache.catalina.core.StandardHost [/b]getDeployer
INFO: Create Host deployer for direct deployment ( non-jmx )
Apr 9, 2004 2:15:44 PM org.apache.catalina.core.StandardHostDeployer install
INFO: Processing Context configuration file URL file:C:\software\Tomcat5.0\conf\
Catalina\localhost\admin.xml
Apr 9, 2004 2:15:44 PM org.apache.struts.util.PropertyMessageResources <init>
INFO: Initializing, config='org.apache.struts.util.LocalStrings', returnNull=tru
e
Apr 9, 2004 2:15:44 PM org.apache.struts.util.PropertyMessageResources <init>
INFO: Initializing, config='org.apache.struts.action.ActionResources', returnNul
l=true
Apr 9, 2004 2:15:44 PM org.apache.struts.util.PropertyMessageResources <init>
INFO: Initializing, config='org.apache.webapp.admin.ApplicationResources', retur
nNull=true
Apr 9, 2004 2:15:45 PM org.apache.catalina.core.StandardHostDeployer install
INFO: Processing Context configuration file URL file:C:\software\Tomcat5.0\conf\
Catalina\localhost\balancer.xml
Apr 9, 2004 2:15:45 PM org.apache.catalina.core.StandardHostDeployer install
INFO: Processing Context configuration file URL file:C:\software\Tomcat5.0\conf\
Catalina\localhost\manager.xml
Apr 9, 2004 2:15:46 PM org.apache.catalina.core.StandardHostDeployer install
INFO: Installing web application at context path /jsp-examples from URL file:C:\
software\Tomcat5.0\webapps\jsp-examples
Apr 9, 2004 2:15:46 PM org.apache.catalina.core.StandardHostDeployer install
INFO: Installing web application at context path from URL file:C:\software\Tomc
at5.0\webapps\ROOT
Apr 9, 2004 2:15:46 PM org.apache.catalina.core.StandardHostDeployer install
INFO: Installing web application at context path /servlets-examples from URL fil
e:C:\software\Tomcat5.0\webapps\servlets-examples
Apr 9, 2004 2:15:46 PM org.apache.catalina.core.StandardHostDeployer install
INFO: Installing web application at context path /tomcat-docs from URL file:C:\s
oftware\Tomcat5.0\webapps\tomcat-docs
Apr 9, 2004 2:15:46 PM org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on port 8080
Apr 9, 2004 2:15:46 PM org.apache.jk.common.ChannelSocket init
INFO: JK2: ajp13 listening on /0.0.0.0:8009
Apr 9, 2004 2:15:46 PM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/30 config=C:\software\Tomcat5.0\conf\jk2.propertie
s
Apr 9, 2004 2:15:46 PM org.apache.catalina.startup.Catalina start



My java code is as follows

[code] System.out.println("**************1************");
System.out.println("***************1***********");
System.out.println("****************1**********");
System.out.println("*****************1*********");
System.out.println("******************1********");
// for (Iterator it = query.iterate(); it.hasNext();) {
// Cenet cat = (Cenet) it.next();
// System.out.println("FIRST" + cat.getUnofficialFirstName() );
// }
// tx.commit();
// session.close();
Session session = com.sbc.hrtech.loa.server.hibernate.HibernateUtil.currentSession();

Transaction tx= session.beginTransaction();

com.sbc.hrtech.loa.server.hibernate.Cat princess = new com.sbc.hrtech.loa.server.hibernate.Cat();
princess.setName("Princess");
princess.setSex('F');
princess.setWeight(7.4f);

session.save(princess);
tx.commit();

com.sbc.hrtech.loa.server.hibernate.HibernateUtil.closeSession();
System.out.println("****2**********************");
System.out.println("*****2*********************");
System.out.println("******2********************");
System.out.println("*******2*******************");
System.out.println("**************************");

Transaction tx1= session.beginTransaction();

Query query = session.createQuery("select cat from Cat as cat where cat.sex = :sex");
query.setCharacter("sex", 'F');
for (Iterator it = query.iterate(); it.hasNext();) {
com.sbc.hrtech.loa.server.hibernate.Cat cat = (com.sbc.hrtech.loa.server.hibernate.Cat) it.next();
System.out.println("Female Cat: " + cat.getName() );
}

tx1.commit(); [/code]

As you can see, it does not print the **********2********* and does not throw any exceptions either. The hibernate.cfg.xml in my web-inf/classes is as follows

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="connection.datasource">java:comp/env/jdbc/loacenet</property>
<property name="show_sql">false</property>
<property name="dialect">net.sf.hibernate.dialect.OracleDialect</property>
<property name="hibernate.cache.provider_class property">net.sf.hibernate.cache.HashtableCacheProvider</property>
<property name="transaction.factory_class">net.sf.hibernate.transaction.JTATransactionFactory</property>
<!--property name="hibernate.session_factory_name">java:comp/env/jdbc/loacenet</property-->
<!-- Mapping files -->
<mapping resource="Cenet.hbm.xml"/>
<mapping resource="Cat.hbm.xml"/>
</session-factory>
</hibernate-configuration>

The database I am using is oracle 8.1.7
Any help appreciated,
Thanks,
Sohil


Top
 Profile  
 
 Post subject: found problem
PostPosted: Fri Apr 09, 2004 4:53 pm 
Beginner
Beginner

Joined: Thu Feb 26, 2004 6:42 pm
Posts: 24
There was a transactionException in my tomcat logs. I had to put jta.jar in the web-inf/lib folder. I thought that this was only required for stand alone applications?


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.