Hello

I have run into a problem using SQLTransformer in Cocoon 2.0 with Oracle 8.
1.7 and Tomcat 4.0.1 on Windows NT4 Service Pack 5.

Here is the datasource as defined in cocoon.xconf:
     <jdbc name="gtu-bridge">
       <pool-controller min="5" max="10" oradb="true"/>
       <dburl>jdbc:oracle:thin:@172.16.1.5:1521:gtu</dburl>
       <user>gtu</user>
       <password>gtu</password>
     </jdbc>

The system generates an SQL on the database which returns a number of rows.
  Then it does a second query for each row returned using the values 
returned in the first query through the <ancestor-value> tag.

All the SQL statements are correct, in that they return the expected 
results when they run. The problem is that if the pipeline is run two or 
three times, the database crashes with a NullPointerException. Here is an 
extract from the log. I have omitted the actual SQL statements and some of 
the level 1 queries.

   SQLTransformer: SQLTransformer executing query nr 0
   SQLTransformer$Query: EXECUTING SELECT ....
   DefaultPool: Retrieving a 
org.apache.avalon.excalibur.datasource.JdbcConnection from the pool
   DefaultPool: Returning a 
org.apache.avalon.excalibur.datasource.JdbcConnection to the pool
   SQLTransformer: SQLTransformer executing query nr 1
   SQLTransformer$Query: EXECUTING SELECT ....
   DefaultPool: Retrieving a 
org.apache.avalon.excalibur.datasource.JdbcConnection from the pool
   DefaultPool: Returning a 
org.apache.avalon.excalibur.datasource.JdbcConnection to the pool
   ........
   SQLTransformer: SQLTransformer executing query nr 1
   SQLTransformer$Query: EXECUTING SELECT ....
   DefaultPool: Retrieving a 
org.apache.avalon.excalibur.datasource.JdbcConnection from the pool
   DefaultPool: Returning a 
org.apache.avalon.excalibur.datasource.JdbcConnection to the pool
   SQLTransformer: SQLTransformer executing query nr 1
   SQLTransformer$Query: EXECUTING SELECT ....
   DefaultPool: Retrieving a 
org.apache.avalon.excalibur.datasource.JdbcConnection from the pool
   JdbcConnectionPool: JdbcConnection was closed, creating one to take its 
place
   JdbcConnectionFactory: JdbcConnection object created
   DefaultPool: Returning a 
org.apache.avalon.excalibur.datasource.JdbcConnection to the pool
   SQLTransformer$Query: NullPointer while closing the resultset.
   java.lang.NullPointerException
       at oracle.jdbc.driver.ScrollableResultSet.close(ScrollableResultSet.
java:143)
       at 
org.apache.cocoon.transformation.SQLTransformer$Query.close(SQLTransformer.
java:1009)
       at 
org.apache.cocoon.transformation.SQLTransformer.executeQuery
(SQLTransformer.java:294)
       at 
org.apache.cocoon.transformation.SQLTransformer.endExecuteQueryElement
(SQLTransformer.java:398)

Sometimes the "JdbcConnection was closed" message appears several times 
and the error does not occur, sometimes it appears several times and the 
error does occur. In this case it appeared once and the error occured. I 
have not seen the error occurring unless that message has appeared at 
least once.

It looks to me like the SQLTransformer is checking if the ResultSet is 
null, finding it is not null so trying to close it, but by the time it 
tries to close it, something else has already removed it so it gets a 
NullPointerException. The SQLTransformer successfully catches the 
exception, but the Oracle ScrollableResultSet does not catch it and does 
not throw it, so the whole thing crashes.

I have modified the source of SQLTransformer to synchronize on the 
ResultSet like this:
Original code:
     if ( rs != null )
       try {
         //getTheLogger().debug("Trying to close resultset "+rs.toString())
;
         rs.close();
         rs = null;      // This prevents us from using the resultset again.
         //250getTheLogger().debug("Really closed the resultset now.");
       } catch ( NullPointerException e ) {
         getTheLogger().debug( "NullPointer while closing the resultset.", 
e );
     }

Modified code:
     if ( rs != null )
       try {
        synchronized (rs) {
           //getTheLogger().debug("Trying to close resultset "+rs.toString(
));
           rs.close();
           rs = null;      // This prevents us from using the resultset 
again.
           //250getTheLogger().debug("Really closed the resultset now.");
         }
       } catch ( NullPointerException e ) {
         getTheLogger().debug( "NullPointer while closing the resultset.", 
e );
     }

I am now waiting for my client to tell me if this fixes the problem (I do 
not have access to an environment where I can make the error occur).

Meanwhile, please can someone tell me what is happening here? Is my fix 
likely to work? Do I have an incorrect setting somewhere? What else can I 
try?

Thank you

William


---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <[EMAIL PROTECTED]>
For additional commands, e-mail: <[EMAIL PROTECTED]>

Reply via email to