-->
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.  [ 4 posts ] 
Author Message
 Post subject: Cannot query hibernate object. No exceptions, no logs.
PostPosted: Wed Jul 27, 2005 11:54 am 
Newbie

Joined: Fri Jun 24, 2005 3:32 pm
Posts: 11
Hibernate3.0, JBoss4.0.2, JDK-1.4.2_01

My apologies for the cross-posting (i.e. JBoss forums), but I realized this would be a much more appropriate place to post.

I'm utilizing the Hibernate Deployer in JBoss. I have two files. techdesk.har and techdesk.war. The har file has only three classes made persistent, and deploys correctly, and the SessionFactory bound correctly in JNDI:

Quote:
2005-07-26 22:40:52,511 INFO [org.jboss.hibernate.jmx.Hibernate] SessionFactory successfully built and bound into JNDI [java:/TechDesk/SessionFactory]


However, when I access my servlet with code to load a class from hibernate, nothing comes back (not even errors or exceptions). I even have ShowSQL=true in my hibernate parameters, but no SQL statements were output'd. Here is the log from when I access the servlet:

Quote:
2005-07-26 22:30:30,557 DEBUG [org.hibernate.impl.SessionFactoryObjectFactory] JNDI lookup: TechDesk/SessionFactory
2005-07-26 22:30:30,557 DEBUG [org.hibernate.impl.SessionFactoryObjectFactory] lookup: uid=8a8be5ef0555af6a010555af8d9e0001
2005-07-26 22:30:30,557 DEBUG [org.hibernate.jdbc.JDBCContext] no active transaction, could not register Synchronization
2005-07-26 22:30:30,557 DEBUG [org.hibernate.impl.SessionImpl] opened session at timestamp: 4597479139561472
2005-07-26 22:30:30,567 DEBUG [org.hibernate.transaction.JTATransaction] begin
2005-07-26 22:30:30,567 DEBUG [org.hibernate.transaction.JTATransaction] Looking for UserTransaction under: UserTransaction
2005-07-26 22:30:30,567 DEBUG [org.hibernate.transaction.JTATransaction] Obtained UserTransaction
2005-07-26 22:30:30,567 DEBUG [org.hibernate.transaction.JTATransaction] Began a new JTA transaction
2005-07-26 22:30:30,577 DEBUG [org.hibernate.jdbc.JDBCContext] successfully registered Synchronization
2005-07-26 22:30:30,697 DEBUG [org.hibernate.transaction.JTATransaction] commit
2005-07-26 22:30:30,697 DEBUG [org.hibernate.transaction.CacheSynchronization] transaction before completion callback
2005-07-26 22:30:30,697 DEBUG [org.hibernate.transaction.CacheSynchronization] automatically flushing session
2005-07-26 22:30:30,697 DEBUG [org.hibernate.impl.SessionImpl] automatically flushing session
2005-07-26 22:30:30,697 DEBUG [org.hibernate.jdbc.JDBCContext] before transaction completion
2005-07-26 22:30:30,697 DEBUG [org.hibernate.impl.SessionImpl] before transaction completion
2005-07-26 22:30:30,697 DEBUG [org.hibernate.transaction.CacheSynchronization] transaction after completion callback, status: 3
2005-07-26 22:30:30,697 DEBUG [org.hibernate.jdbc.JDBCContext] after transaction completion
2005-07-26 22:30:30,697 DEBUG [org.hibernate.impl.SessionImpl] after transaction completion
2005-07-26 22:30:30,697 DEBUG [org.hibernate.transaction.CacheSynchronization] automatically closing session
2005-07-26 22:30:30,697 DEBUG [org.hibernate.impl.SessionImpl] automatically closing session
2005-07-26 22:30:30,697 DEBUG [org.hibernate.impl.SessionImpl] closing session
2005-07-26 22:30:30,697 DEBUG [org.hibernate.transaction.JTATransaction] Committed JTA UserTransaction
2005-07-26 22:30:36,536 DEBUG [org.hibernate.jdbc.JDBCContext] running Session.finalize()


It's as if no queries were even made?! Here is a snip of the code that calls the hibernate lookup:

Code:
Transaction tx = null;
      Session session = null;
      try {
         InitialContext ctx = new InitialContext();
         SessionFactory factory = (SessionFactory) ctx
               .lookup("java:/TechDesk/SessionFactory");
         session = factory.openSession();
      } catch (NamingException e) {
         // TODO Auto-generated catch block
         e.printStackTrace();
      }

      PrintWriter out = resp.getWriter();
      tx = session.beginTransaction();
      try {
         List results = session.createCriteria(Ticket.class).list();
         for (Iterator i = results.iterator(); i.hasNext();) {
            Ticket ticket = (Ticket) i.next();
            out.println(ticket.getId() + " " + ticket.getProblem());
            if (ticket.getOwner() != null) {
               out.println(ticket.getOwner().getUsername());
            } else {
               out.println("No Owner");
            }
         }
      } catch (HibernateException e) {
         e.printStackTrace();
      } finally {
            tx.commit();
      }


Can anyone point out what I'm doing wrong? I've been staring at this code for too long, and need a fresh set of (experienced) eyes. This code works correctly outside of JBoss and Tomcat using a POJO.

Thanks so much!
--Aaron


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 28, 2005 6:22 pm 
Newbie

Joined: Fri Jun 24, 2005 3:32 pm
Posts: 11
Since I haven't gotten any responses, this must be only an issue with me, so a JIRA entry probably wouldn't make sense. I guess I'll try and build the hibernate objects the old fasion way (i.e. not using JBoss's HAR deployer) and see what happens.

Is anyone else successfully using Hibernate3.0 with JBoss's HAR deployer?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 29, 2005 8:40 am 
Newbie

Joined: Fri Jul 15, 2005 10:02 am
Posts: 12
I am no expert with JBoss and Hibernate but I have gotten 4.0.2 to work with a HAR archive with no problems.

A question about your first post though. When you deploy your application do you see that hibernate is mapping your hbm.xml files? Can you post the layout of your HAR archive as well as the contents of your hibernate-service.xml file?


Top
 Profile  
 
 Post subject: FIXED!!!
PostPosted: Fri Jul 29, 2005 9:02 pm 
Newbie

Joined: Fri Jun 24, 2005 3:32 pm
Posts: 11
Heh heh.....

I can't believe I did this!!! I was posting my HAR file structure, when I decided to just run "jar -tf techdesk.har".

Ummm.... apparently I changed my ant build file inadvertently, and it never copied my classes nor my hbm.xml files to the har. Just the hibernate-service.xml.

THAT explains alot!

Thanks Merkkila!! Had you not asked me for my HAR structure, God knows when I would have found this.

What a life saver you are!!!!

THANKS!!

P.S. ~ Should I put in a JIRA issue to include "ClassNotFoundException" when running code against hibernate classes that aren't there? You know.... for us idiots?? <grin>


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.