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: No Execution and No Errors in Websphere 5.1.x
PostPosted: Tue Jul 26, 2005 10:55 am 
Beginner
Beginner

Joined: Thu Jul 21, 2005 10:28 am
Posts: 21
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 3.0.5

Mapping documents: N/A

Code between sessionFactory.openSession() and session.close(): N/A

Full stack trace of any exception that occurs: N/A

Name and version of the database you are using: Oracle 9.1

The generated SQL (show_sql=true): N/A

Debug level Hibernate log excerpt: N/A

I am using IRAD6 with Websphere 5.1 and we want to switch from Hibernate 2.x to 3.x. I have a very, very, very simple DAO class. The code follows:

Code:
import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;
import com.dataaccess.dvo.AgentMessageDVO;

public class AgentMessageDAO {
   
public void save(AgentMessageDVO agentMessageDVO) throws Exception {
   System.out.println("save: start");
   Session session = null;
   try {
      System.out.println("save: start: in try-block with Hibernate Exception");
   }
   catch (HibernateException he) {
      System.out.println("save: HibernateException: " + he.getMessage());
   }
   catch(Exception e) {
      System.out.println("save: Exception: " + e.getMessage());
   }
   System.out.println("save: finish");
   }
}


The calling code looks like this:
Code:
public static void main (String args[]) {
System.out.println("creating AgentMessageDAO: start");
AgentMessageDAO agentMessageDAO = new AgentMessageDAO();
System.out.println("creating AgentMessageDAO: finish");
}


If I run this program from a standalone application it works fine. When I try to run this code from Websphere 5.1.x I get the first line that says its "creating AgentMessageDAO: start" but then it just stops there ... no error message in any logs. None in the console and none in the Websphere Portal logs. I've included all the jars that I thought neccessary.

When I comment out the line that tries to capture the HibernateException, then my application works fine on Websphere.

So .... why is it that I can't instantiate an object that tries to call one class within Hibernate 3?????????????? I've already spent 1 day working on this and I rather not waste another day on this, so any help would be much appreciated.


Top
 Profile  
 
 Post subject: No Errors Problem Solved
PostPosted: Wed Jul 27, 2005 3:26 pm 
Beginner
Beginner

Joined: Thu Jul 21, 2005 10:28 am
Posts: 21
When you create your HibernateUtil class and within the static method, make sure it matches the simple version.

Code:
private static Configuration configuration;
private static SessionFactory sessionFactory;
private static final ThreadLocal threadSession = new ThreadLocal();

//*** Create the initial SessionFactory from the default configuration files
static {
   try {
      java.net.URL configFileURL =
      configuration = new Configuration();
   sessionFactory = configuration.configure().buildSessionFactory();
      //*** We could also let Hibernate bind it to JNDI:
      //*** configuration.configure().buildSessionFactory()
   } catch (Throwable ex) {
      //*** We have to catch Throwable, otherwise we will miss
      //*** NoClassDefFoundError and other subclasses of Error
      System.out.println("Building SessionFactory failed: " + ex);
      throw new ExceptionInInitializerError(ex);
   }
}


Make sure you catch Throwable and not exception ... or you will miss NoClassDefFoundErrors. Also forget logging, just System.out.println the issue.

Once I copied this method from the documentation here, I found out I was missing a few jars, but now I'm good to go.


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.