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.  [ 1 post ] 
Author Message
 Post subject: Session closed
PostPosted: Fri Nov 18, 2011 3:41 am 

Joined: Thu Nov 17, 2011 11:15 am
Posts: 1
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:
<?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">
   <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
<?xml version="1.0" encoding="UTF-8"?>
<Configure class="org.mortbay.jetty.webapp.WebAppContext">
    <New id="odm" class="org.mortbay.jetty.plus.naming.Resource">
            <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>

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

         try {
            batchSize = Integer.parseInt(p
         } 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

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