-->
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.  [ 3 posts ] 
Author Message
 Post subject: I have problems with hibernate.cfg.xml and Sun One 7 App Ser
PostPosted: Tue May 11, 2004 5:45 pm 
Newbie

Joined: Tue May 11, 2004 5:02 pm
Posts: 6
Location: Mexico
i am deploying an ear file to the Sun One 7 app server and have in the ear file , four file, ejb.jar, comunes.jar, hbm.jar and myApp.war, Within the hbm file i put the the hibernate.cfg.xml file and in myapp.war I have a class that calls:
Configuration cfg = new Configuration().configure();

to load the hibernate.cfg.xml file. When this happens i get an NullPointerException in my log file, the hibernate.cfg.xml file didn


Top
 Profile  
 
 Post subject: Sun One 7 App
PostPosted: Tue May 11, 2004 11:04 pm 
Newbie

Joined: Mon Oct 06, 2003 5:35 am
Posts: 9
Location: Perth.au
Hi Mara,

I am working with Sun One Apps Server and I need to connect to a number of database SIDS with different tables. I have changed my session management class to look for a config file with a different filename.

I also place the config file within the WEB-INF/classes/etc

so: -

Session session = GDMSSession.currentSession();
...
...
GDMSSession.stopSession();

I hope this helps ........

Cheers

Jon K

-----------------------------------------------------------------------
/*
* GDMSSession.java
*
* Created on 12 February 2004, 12:30
*/

package gem.common.hibernate;

import net.sf.hibernate.HibernateException;
import net.sf.hibernate.MappingException;
import net.sf.hibernate.Session;
import net.sf.hibernate.SessionFactory;
import net.sf.hibernate.cfg.Configuration;
import gem.common.dao.DAOException;
import java.io.File;
import java.net.URL;

/**
This class is used to get a ThreadLocal instance of the Session class.
This design pattern is documented at: http://hibernate.bluemars.net/42.html

@author <a href="mailto:nick@systemmobile.com">Nick Heudecker</a>
*/

public class GDMSSession {

/**
Returns the ThreadLocal Session instance. This method will initialize
the <code>SessionFactory</code> if necessary.

@return Session
@throws DAOException
*/
public static Session currentSession() throws DAOException {
Session s = (Session) session.get();

try {
if(s == null) {
if (sf == null) {
try {
cfg.configure("/etc/gdms.cfg.xml");
sf = cfg.buildSessionFactory();
}
catch(Exception e) {
System.err.println("%%%% Error Creating SessionFactory %%%%");
e.printStackTrace();
}
}
s = sf.openSession();
session.set(s);
}
}
catch (HibernateException he) {
throw new DAOException(he);
}
finally { }
return s;
}

/**
Closes the session object.
@throws DAOException
*/
public static void closeSession() throws DAOException {
Session s = (Session) session.get();
session.set(null);

if(s != null) {
try {
s.close();
}
catch (HibernateException he) {
throw new DAOException(he);
}
}
}
public static final ThreadLocal session = new ThreadLocal();
private static final Configuration cfg = new Configuration();
private static SessionFactory sf;
}


Top
 Profile  
 
 Post subject: Thank
PostPosted: Mon May 17, 2004 6:48 pm 
Newbie

Joined: Tue May 11, 2004 5:02 pm
Posts: 6
Location: Mexico
Thank you very much Jon K for your help, but my problem was the security that Sun One 7 has.


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