Re: Exception XindiceCollection.checkOpen

Vadim Gritsenko <[email protected]> Tue, 11 Nov 2008 18:37:58 -0500
Newsgroups gmane.text.xml.xindice.user
Message-ID <[email protected]>
On Nov 11, 2008, at 3:51 PM, lunapolar wrote:

> I've uploaded my class DBConnection, then I use it like that:
>
> public final static String XMLDBAPIVERSION    = "1.0";
> protected static DBconnection connectionGuias = new DBconnection();
>
> col = connectionGuias.getCollectionInstanceGuias(request,response);

I have noticed that "DBconnection" can redirect if it catches an  
exception. In this case it will return null connection, so I hope you  
do have a check for null result here, before calling getService:

   if (col == null) {
      return;
   }


> XPathQueryService service =
> (XPathQueryService 
> )col.getService("XPathQueryService",XMLDBAPIVERSION);
>
> ResourceSet resultSet    = service.query(xpath);
> ...................................................................
> finally
>        {
>          if (col != null)
>          {
>            col.close();
>          }

This close() is the problem. If you take a look at the  
DBconnection.getCollectionInstanceGuias(), you will see that it calls  
DatabaseManager.getCollection() just one time, on very first call.  
After that, it always returns single collection instance  
(collectionGuias).

So if you close this collection here, it means you are closing that  
single collection instance, so any following calls to the  
DBconnection.getCollectionInstanceGuias() will be returning already  
closed collection - this is bad and will cause XMLDBException exception.

First, let's remove col.close() here and try the application without it.


>        }
>
> If I don`t use the col.close() when I close the browser and I use mi
> application also give me an exception.

What exception do you get in this case?


Vadim