-->
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.  [ 5 posts ] 
Author Message
 Post subject: problem trying to use Hibernate as an MBean with JBoss
PostPosted: Wed Apr 14, 2004 12:13 am 
Newbie

Joined: Sun Apr 11, 2004 12:13 pm
Posts: 7
Hi. I'm using Hibernate 2.1 with JBoss 3.2.1 and am having a problem trying to use Hibernate as an MBean.

The problem I am having does not occur when I first start up JBoss; rather, it only happens after I rebuild my application and do a hot deploy of my .ear file to JBoss.

After the hot deploy, I get the following warning from Hibernate and my find method returns no rows:
Code:
2004-04-13 23:49:33,646 WARN  [net.sf.hibernate.hql.QueryTranslator] no persistent classes found for query class: from com.taos.server.hibernate.jaws.JawsJob


I noticed that when I get a SessionFactory the first time, hibernate logs all of the attributes/mappings it found in the mbean; however, after redeploying my .ear file and rerunning my application, these log statements are not generated. I have to actually restart JBoss to make it work again.

Any ideas would be greatly appreciated.

here is my jboss-service.xml file
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE server>

<server>
   <mbean code="net.sf.hibernate.jmx.HibernateService" name="jboss.jca:service=Hibernate">
       <depends>jboss.jca:service=RARDeployer</depends>
       <attribute name="MapResources">com/taos/server/hibernate/jaws/JawsJob.hbm.xml,
                                        com/taos/server/hibernate/jaws/JobEndStartCond.hbm.xml
       </attribute>
       <attribute name="JndiName">java:/HibernateFactory</attribute>
       <attribute name="Datasource">java:jdbc/jaws</attribute>
       <attribute name="Dialect">net.sf.hibernate.dialect.SQLServerDialect</attribute>
       <attribute name="UseOuterJoin">true</attribute>
       <attribute name="ShowSql">true</attribute>
       <attribute name="UserTransactionName">UserTransaction</attribute>
       <attribute name="TransactionStrategy">net.sf.hibernate.transaction.JTATransactionFactory</attribute>
       <attribute name="TransactionManagerLookupStrategy">net.sf.hibernate.transaction.JBossTransactionManagerLookup</attribute>
       <attribute name="CacheProvider"> net.sf.ehcache.hibernate.Provider</attribute>
   </mbean>

</server>


HibernateUtility.java
Code:
public class HibernateUtility {

    private static final SessionFactory jawsSessionFactory;
   
    static {
        try {
            jawsSessionFactory = setupJawsSessionFactory();
        }
        catch (TaosException ex) {
            throw new RuntimeException("Excpeption building SessionFactory:  " + ex.getMessage(), ex);
        }
    }
   
    public static final ThreadLocal jawsSession = new ThreadLocal();
   

    public static Session currentJawsSession() throws HibernateException {
        Session s = (Session) jawsSession.get();
        //Open a new Session, if this Thread has none yet
        if (s==null) {
            s = jawsSessionFactory.openSession();
            session.set(s);
        }
        return s;       
    }
   
    public static void closeJawsSession() throws HibernateException {
        Session s = (Session) jawsSession.get();
        jawsSession.set(null);
        if (s!=null) {
            s.close();
        }           
    }
           
    private static SessionFactory setupJawsSessionFactory () throws TaosException {
        try {           
            Context context = new InitialContext();
         Object obj = context.lookup("java:/HibernateFactory");
            SessionFactory sessions = (SessionFactory)obj;
            return sessions;
        }
        catch (NamingException ex) {
            logger.debug("Naming exception.  " + ex.getMessage());           
            throw new TaosException("Naming Exception.  " + ex.getMessage());
        }


    }
   
}


method to execute query
Code:
public Vector getJawsJobs() throws TaosException {
        Vector returnJobs = new Vector();
        try {
            Session session = HibernateUtility.currentJawsSession();       
            Transaction tx=session.beginTransaction();
            List joblist = session.find("from JawsJob" );
            Iterator jobs = joblist.iterator();
            logger.debug("after iterator.");
            while (jobs.hasNext()) {     
                JawsJob job = (JawsJob)jobs.next();
                logger.debug("got jaws job:  " + job.getJobName());
                returnJobs.add(job);
            }         
            tx.commit();
            session.connection().close();
            return returnJobs;   
        }
        catch (HibernateException ex) {
            logger.debug("Hibernate exception.  " + ex.getMessage());
            throw new TaosException("Hibernate Exception.  " + ex.getMessage());
        }
}


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 14, 2004 12:09 pm 
Beginner
Beginner

Joined: Wed Feb 18, 2004 1:28 pm
Posts: 20
Location: Rovereto - Italy
I have the same problem


Top
 Profile  
 
 Post subject: pain in the a**
PostPosted: Fri Jul 23, 2004 6:19 pm 
Newbie

Joined: Fri Jul 23, 2004 6:15 pm
Posts: 1
Yeah, I'm having the same problem.
Each time I rebuild my application and do a hot deploy I get the same error message... but if I restart JBoss everything runs fine...
Where are the hibernate team to answer this question?
Please! I need help.
Thanx

PS: I'm using Hibernate 2.1.4 under JBoss 3.2.5 (got the same problem in 3.2.4)


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jul 24, 2004 11:00 am 
Senior
Senior

Joined: Tue Nov 25, 2003 9:35 am
Posts: 194
Location: San Francisco
I think this is an issue with JBoss classloading and the Hibernate dynamic CGLIB classes.

I have seen this behavior if you have your Hibernate SARs in the JBoss deployment directory on their own, and the Hibernate support jars in the JBoss lib directory. Try putting everything in an EAR and hot deploying that.



Sherman


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 26, 2004 4:32 am 
Beginner
Beginner

Joined: Wed Feb 18, 2004 1:28 pm
Posts: 20
Location: Rovereto - Italy
I solved my problems with hotdeploy with jboss 3.2.3 but the hotdeploy still doesn't work with jboss 3.2.4 or 3.2.5 (there is a new version of tomcat and I have unsolved problems with the war deploy....)


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