Announcement Announcement Module
Collapse
No announcement yet.
ResultSet is closing?? not in JSP, but in code!! Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • ResultSet is closing?? not in JSP, but in code!!

    This isn't a OpenInViewSession issue, my query ResultSet is being closed right after I retrieve the data and I cannot access it. Currently I am injenct DAO's into services, then calling the service to retrieve the data.

    Now if I can iterate through my results inside the DAO just fine, but when I try to iterate through the result returned from the DAO I get an exception.

    Code:
    Iterator objs = service.getObjects();
    objs.next();
    once I hit line too I get this exception ( im also including a stacktrace starting from the transaction to the end)

    Code:
    2007-08-21 16:50:20,415 [http-8080-Processor25] DEBUG org.hibernate.jdbc.AbstractBatcher  - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
    2007-08-21 16:50:20,415 [http-8080-Processor25] DEBUG org.hibernate.SQL  - select university0_.id as col_0_0_ from university university0_
    2007-08-21 16:50:20,415 [http-8080-Processor25] TRACE org.hibernate.jdbc.AbstractBatcher  - preparing statement
    2007-08-21 16:50:20,415 [http-8080-Processor25] DEBUG org.hibernate.jdbc.AbstractBatcher  - about to open ResultSet (open ResultSets: 0, globally: 0)
    2007-08-21 16:50:20,415 [http-8080-Processor25] DEBUG org.hibernate.impl.IteratorImpl  - retrieving next results
    2007-08-21 16:50:20,415 [http-8080-Processor25] TRACE org.hibernate.type.IntegerType  - returning '0' as column: col_0_0_
    2007-08-21 16:50:20,415 [http-8080-Processor25] TRACE org.hibernate.event.def.DefaultLoadEventListener  - loading entity: [edu.ucr.c3.fohas.domain.University#0]
    2007-08-21 16:50:20,415 [http-8080-Processor25] TRACE org.hibernate.event.def.DefaultLoadEventListener  - creating new proxy for entity
    2007-08-21 16:50:20,415 [http-8080-Processor25] DEBUG edu.ucr.c3.fohas.dao.hibernate.UniversityDAO  - retrieveAllUniversities(...) successful
    2007-08-21 16:50:20,415 [http-8080-Processor25] DEBUG org.hibernate.transaction.JDBCTransaction  - commit
    2007-08-21 16:50:20,415 [http-8080-Processor25] TRACE org.hibernate.impl.SessionImpl  - automatically flushing session
    2007-08-21 16:50:20,415 [http-8080-Processor25] TRACE org.hibernate.jdbc.JDBCContext  - before transaction completion
    2007-08-21 16:50:20,415 [http-8080-Processor25] TRACE org.hibernate.impl.SessionImpl  - before transaction completion
    2007-08-21 16:50:20,415 [http-8080-Processor25] DEBUG org.hibernate.transaction.JDBCTransaction  - committed JDBC Connection
    2007-08-21 16:50:20,415 [http-8080-Processor25] TRACE org.hibernate.jdbc.JDBCContext  - after transaction completion
    2007-08-21 16:50:20,415 [http-8080-Processor25] DEBUG org.hibernate.jdbc.ConnectionManager  - transaction completed on session with on_close connection release mode; be sure to close the session to release JDBC resources!
    2007-08-21 16:50:20,415 [http-8080-Processor25] TRACE org.hibernate.impl.SessionImpl  - after transaction completion
    2007-08-21 16:50:20,415 [http-8080-Processor25] TRACE org.hibernate.impl.SessionImpl  - setting flush mode to: NEVER
    2007-08-21 16:50:20,415 [http-8080-Processor25] DEBUG org.hibernate.impl.SessionImpl  - disconnecting session
    2007-08-21 16:50:20,415 [http-8080-Processor25] TRACE org.hibernate.jdbc.ConnectionManager  - performing cleanup
    2007-08-21 16:50:20,415 [http-8080-Processor25] DEBUG org.hibernate.jdbc.AbstractBatcher  - about to close ResultSet (open ResultSets: 1, globally: 1)
    2007-08-21 16:50:20,415 [http-8080-Processor25] DEBUG org.hibernate.jdbc.AbstractBatcher  - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
    2007-08-21 16:50:20,415 [http-8080-Processor25] TRACE org.hibernate.jdbc.AbstractBatcher  - closing statement
    2007-08-21 16:50:20,415 [http-8080-Processor25] DEBUG org.hibernate.jdbc.ConnectionManager  - releasing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
    2007-08-21 16:50:20,415 [http-8080-Processor25] TRACE org.hibernate.jdbc.JDBCContext  - after transaction completion
    2007-08-21 16:50:20,415 [http-8080-Processor25] DEBUG org.hibernate.jdbc.ConnectionManager  - transaction completed on session with on_close connection release mode; be sure to close the session to release JDBC resources!
    2007-08-21 16:50:20,415 [http-8080-Processor25] TRACE org.hibernate.impl.SessionImpl  - after transaction completion
    2007-08-21 16:50:20,415 [http-8080-Processor25] DEBUG org.hibernate.util.JDBCExceptionReporter  - could not get next iterator result [???]
    java.sql.SQLException: Operation not allowed after ResultSet closed
    	at com.mysql.jdbc.ResultSet.checkClosed(ResultSet.java:3600)
    	at com.mysql.jdbc.ResultSet.next(ResultSet.java:2465)
    	at org.apache.commons.dbcp.DelegatingResultSet.next(DelegatingResultSet.java:169)
    	at org.hibernate.impl.IteratorImpl.postNext(IteratorImpl.java:83)
    	at org.hibernate.impl.IteratorImpl.next(IteratorImpl.java:120)
    	at ......
    
    2007-08-21 16:50:20,415 [http-8080-Processor25] WARN  org.hibernate.util.JDBCExceptionReporter  - SQL Error: 0, SQLState: S1000
    2007-08-21 16:50:20,415 [http-8080-Processor25] ERROR org.hibernate.util.JDBCExceptionReporter  - Operation not allowed after ResultSet closed
    2007-08-21 16:50:20,415 [http-8080-Processor25] DEBUG edu.ucr.c3.fohas.controller.FOHASExHandler  - FOHASException - Exception thrown executing [AnnotatedAction@6fc417 targetAction = edu.ucr.c3.fohas.controller.students.forms.actions.RegisterFormAction@165b4e3, attributes = map['method' -> 'setupForm']] in state 'enterRegister' of flow 'register' -- action execution attributes were 'map['method' -> 'setupForm']'; nested exception is org.hibernate.exception.GenericJDBCException: could not get next iterator result
    2007-08-21 16:50:20,415 [http-8080-Processor25] TRACE org.hibernate.impl.SessionImpl  - closing session
    2007-08-21 16:50:20,415 [http-8080-Processor25] TRACE org.hibernate.jdbc.ConnectionManager  - connection already null in cleanup : no action

    I have no idea what the problem is. I have dealt with the openViewSession issues before, but nothing like this where I cannot even access the data inside my java code. The funny part is I copied the setup from an existing WORKING app, but now all the sudden I cant access data.

    can anyone please help me? if you need information please let me know this issue is driving me crazy!
    thanks
    -Ray

  • #2
    It looks like a problem with your transaction configuration. You probably have configured transactions around your DAO's and not your services. This will effectivly close the connection (and thus the resultset) after you leave the dao method.

    Comment


    • #3
      Man i cannot figure this out....here is my configuration for a service and TX manager...can you please take a look.

      Code:
      <bean id="txManager" 
      class="org.springframework.orm.hibernate3.HibernateTransactionManager">
      <property name="sessionFactory"><ref local="sessionFactory"/></property>
      <property name="dataSource"><ref local="mainDataSource"/></property>
      </bean>
      Code:
      <bean id="facultyDAO" class="edu.ucr.c3.fohas.dao.hibernate.FacultyDAO">
      <property name="sessionFactory"><ref bean="sessionFactory"/></property>
      </bean>
      <bean id="facultyLoginDAO" class="edu.ucr.c3.fohas.dao.hibernate.FacultyLoginDAO">
      <property name="sessionFactory"><ref bean="sessionFactory"/></property>
      </bean>
      <bean id="universityDAO" class="edu.ucr.c3.fohas.dao.hibernate.UniversityDAO">
      <property name="sessionFactory"><ref bean="sessionFactory"/></property>
      </bean>
      Code:
      <bean id="facultySvcTarget" class="edu.ucr.c3.fohas.business.faculty.impl.FacultyServiceImpl">
      <property name="facultyDAO"><ref bean="facultyDAO"/></property>
      <property name="facultyLoginDAO"><ref bean="facultyLoginDAO"/></property>
      <property name="universityDAO"><ref bean="universityDAO"/></property>
      </bean>
      
      <bean id="facultyService" 
      class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
              <property name="transactionManager">
                  <ref bean="txManager"/>
              </property>
              
              <property name="target">
                  <ref bean="facultySvcTarget"/>
              </property>
              
              <property name="transactionAttributes">
                  <props>
                      <prop key="*">PROPAGATION_REQUIRED</prop>
                  </props>
              </property>
          </bean>

      Comment


      • #4
        One thing you might want to check is that you are injecting 'facultyService' into your other beans. If you are injecting the non-proxied version instead that would explain your problem e.g. 'facultySvcTarget'.

        Comment


        • #5
          for some reason I am able to retrieve single objects just fine and use them in my code....but when I retrieve an Iterator then I get that problem. And by looking at the single object in my debugger its not proxied for some reason.

          I dont directly inject the services into my beans, when I want a service I call the service like this

          Code:
          ApplicationContext springContext = 
          	WebApplicationContextUtils.getWebApplicationContext(servletContext);
          
          springContext.getBean(serviceName);
          I dont know, when I return an Iterator it is proxied but I cant use it....when I return a UniqueResult it is not proxied and I can use it just fine .

          Comment


          • #6
            What service name are you passing though to look up? It would also be useful to see the full stacktrace.

            Comment


            • #7
              Originally posted by karldmoore View Post
              What service name are you passing though to look up? It would also be useful to see the full stacktrace.
              well i have the above code inside a method....and when I call it I used something like this

              Code:
              FacultyService facultyService = (FacultyService)getService("facultyService");
              which part of the stacktrace are you looking for so I can produce it. I posted a partial trace from the point the service is called to when the error occurs. are you looking for a deployment trace?

              Comment


              • #8
                Originally posted by raydawg View Post
                well i have the above code inside a method....and when I call it I used something like this

                Code:
                FacultyService facultyService = (FacultyService)getService("facultyService");
                Is it something like that, or exactly like that . The real I ask is if you looking up that bean then I'm slightly confused.

                Originally posted by raydawg View Post
                which part of the stacktrace are you looking for so I can produce it. I posted a partial trace from the point the service is called to when the error occurs. are you looking for a deployment trace?
                I'm after the stacktrace that comes after this.

                Code:
                java.sql.SQLException: Operation not allowed after ResultSet closed
                	at com.mysql.jdbc.ResultSet.checkClosed(ResultSet.java:3600)
                	at com.mysql.jdbc.ResultSet.next(ResultSet.java:2465)
                	at org.apache.commons.dbcp.DelegatingResultSet.next(DelegatingResultSet.java:169)
                	at org.hibernate.impl.IteratorImpl.postNext(IteratorImpl.java:83)
                	at org.hibernate.impl.IteratorImpl.next(IteratorImpl.java:120)
                	at ......

                Comment


                • #9
                  lol sorry...yes its exactly like that. Basically my setup is that I have a base Action class which has that service lookup method. Then I spawn off a bunch of Action classes which extend that base class. I usually have about 10+ services, so depending on what service I need in that Action I just call the lookup to grab it. Its the same setup ive been using for a couple years now....but for whatever reason something is wrong with this one and I cannot figure it out for the life of me

                  anyways I attatched the trace since it was too big to post on there...thanks again for helping me with this I really need to get this figured out ASAP.

                  Comment

                  Working...
                  X