Hibernate Books

All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Session closed
PostPosted: Fri Nov 18, 2011 3:41 am 
Newbie

Joined: Thu Nov 17, 2011 11:15 am
Posts: 1
hi,
ich habe folgendes problem:
wenn ich mehrere (ab 4) lesende zugriffe auf eine datenbank ueber hibernate ausf├╝hre wird jedesmal eine der drei folgenden Ausnahmen geworfen:
java.sql.SQLException: You can't operate on a closed Statement!!!
ERROR org.hibernate.util.JDBCExceptionReporter - This ResultSet is closed.
ERROR org.hibernate.AssertionFailure - an assertion failure occured (this may indicate a bug in Hibernate, but is more likely due to unsafe use of the session)

das projekt ist ein gwt projekt das waehrend der entwicklung mit einem jetty und spaeter mit einem tomcat applicationserver benutzt wird. fuer das connection pooling wird c3pO benutzt (das gleiche problem tritt auch ohne c3pO auf). Mit weniger als 3 zugriffen funktioniert alles praechtig. das session objekt wird mit einem singelton verwaltet. es wird also nur einmal erzeugt und danach immer die erzeugte referenz benutzt. hier die hibernate.cfg.xml datei:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!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="">            
      <!-- SQL dialect -->
      <property name="hibernate.dialect">org.hibernatespatial.postgis.PostgisDialect</property>
      <!-- property name="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</property -->

      <!-- Enable Hibernate's automatic session context management -->
      <property name="current_session_context_class">thread</property>

      <!-- Disable the second-level cache -->
      <property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
      <property name="hibernate.session_factory_name">jdbc/odm</property>
...

hier die jetty-web.xml
Code:
<?xml version="1.0" encoding="UTF-8"?>
<Configure class="org.mortbay.jetty.webapp.WebAppContext">
    <New id="odm" class="org.mortbay.jetty.plus.naming.Resource">
        <Arg>jdbc/odm</Arg>
        <Arg>
            <New class="com.mchange.v2.c3p0.ComboPooledDataSource">
               <Set name="driverClass">org.postgresql.Driver</Set>
                <Set name="jdbcUrl">jdbc:postgresql://xxx/yyy</Set>
                <Set name="user">xxx</Set>
                <Set name="password">xxx</Set>
            <Set name="minPoolSize">5</Set>
            <Set name="maxPoolSize">100</Set>
            <Set name="maxStatements">200</Set>
            <Set name="maxStatementsPerConnection">200</Set>
            <Set name="maxIdleTime">30000</Set>
            <Set name="idleConnectionTestPeriod">30</Set>
            <Set name="automaticTestTable">connection_test</Set>
            <Set name="acquireRetryAttempts">60</Set>
            <Set name="acquireRetryDelay">1000</Set>
            <Set name="breakAfterAcquireFailure">false</Set>
            </New>
        </Arg>
    </New>
</Configure>

hier das singelton fuer den hibernate zugriff (privater konstruktor):
Code:
private TablesManager(String pathToHibernateCfg) {
      try {
         sessionFactory = new AnnotationConfiguration().configure(
               pathToHibernateCfg).buildSessionFactory();
         java.lang.reflect.Field f = SessionFactoryImpl.class
               .getDeclaredField("properties");
         f.setAccessible(true);
         Properties p = (Properties) f.get(sessionFactory);

         try {
            batchSize = Integer.parseInt(p
                  .getProperty("hibernate.jdbc.batch_size"));
         } catch (Exception e) {
            logger.debug("hibernate.jdbc.batch_size undefined in hibernate.cfg.xml. Using a value of "
                  + batchSize);
         }

         session = sessionFactory.openSession();

      } catch (Throwable ex) {
         // Make sure you log the exception, as it might be swallowed
         logger.error("Initial SessionFactory creation failed." + ex);
         throw new ExceptionInInitializerError(ex);
      }
   }


ich bin fuer jede hilfe sehr dankbar
gruss juergen


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

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.