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.  [ 6 posts ] 
Author Message
 Post subject: NoSuchMethodError at getCurrentsession
PostPosted: Mon Jul 25, 2005 3:27 pm 
Newbie

Joined: Tue May 03, 2005 11:53 am
Posts: 7
Hello,
I have a strange error with hibernate3 and jonas:
Code:
java.lang.NoSuchMethodError:org.hibernate.SessionFactory.getCurrentSession()Lorg/hibernate/classic/Session;
        at test.service.util.HibernateUtilJNDI.getSession(HibernateUtilJNDI.java:71)


The code is :
Code:
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

public class HibernateUtilJNDI {
   public static final String HIBERNATE_JNDI_NAME = "HibernateFactory";
   // Create the initial SessionFactory from the default configuration files
   static {
      try {
         configuration = new Configuration();
         configuration.configure().buildSessionFactory();
      } catch (Throwable ex) {
         log.fatal("Building SessionFactory failed.", ex);
         throw new ExceptionInInitializerError(ex);
      }
   }

   public static SessionFactory getSessionFactory() {
      SessionFactory sessions = null;
      try {
         Context ctx = new InitialContext();
         sessions = (SessionFactory) ctx.lookup(HIBERNATE_JNDI_NAME);
      } catch (NamingException ex) {
         throw new InfrastructureException(ex);
      }
      return sessions;
   }
   public static Session getSession() {
      return getSessionFactory().getCurrentSession();
   }


My code works properly on anther application server!

Any help is welcomed.
Thanks in advance.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 25, 2005 3:32 pm 
Expert
Expert

Joined: Tue Oct 05, 2004 9:45 am
Posts: 263
it seems you have the "wrong" Session ...
Code:
org/hibernate/classic/Session


The classic-package is for the old apis ... perhaps the wrong session-Implementation/Interface in JNDI?

gtx
curio


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 25, 2005 3:46 pm 
Newbie

Joined: Tue May 03, 2005 11:53 am
Posts: 7
curio wrote:
it seems you have the "wrong" Session ...
Code:
org/hibernate/classic/Session


The classic-package is for the old apis ... perhaps the wrong session-Implementation/Interface in JNDI?


Thank for your response.

When I print the sessionFactory stored in jndi, it prints:
Code:
org.hibernate.impl.SessionFactoryImpl@247418


Here is my config file:
Code:
<!DOCTYPE hibernate-configuration PUBLIC
   "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
   "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
   <session-factory name="HibernateFactory">
      <property name="show_sql">true</property>
      <property name="dialect">org.hibernate.dialect.MySQLDialect</property>
      <property name="hibernate.connection.datasource">TestManagerDS</property>
      <property name="transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</property>
      <property name="jta.UserTransaction">javax.transaction.UserTransaction</property>
      <property name="hibernate.cache.use_second_level_cache">false</property>
      <property name="transaction.manager_lookup_class">org.hibernate.transaction.JOTMTransactionManagerLookup</property>
      <mapping resource="test/model/bean/Test.hbm.xml"/>
   </session-factory>
</hibernate-configuration>


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 26, 2005 9:18 am 
Newbie

Joined: Mon Mar 15, 2004 10:07 am
Posts: 4
i have the same problem, any answers here ?

thanks :-)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 26, 2005 3:46 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
The only thing that comes to mind is competing hibernate jars. Does jonas maybe ship with some hibernate version?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 26, 2005 5:04 pm 
Newbie

Joined: Tue May 03, 2005 11:53 am
Posts: 7
I've solved this problem ;-)
I've put these files in $JONAS_BASE/lib/ext :
asm-attrs.jar
cglib-2.1.jar
commons-logging-1.0.4.jar
ehcache-1.1.jar
asm.jar
commons-collections-2.1.1.jar
dom4j-1.6.jar
hibernate3.jar

Hope this help.


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