You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xindice-users@xml.apache.org by Joel Rosi-Schwartz <jo...@btconnect.com> on 2002/01/29 14:16:39 UTC

Collection No IndexManager

Hi,

I am moving from xmldb beta 4 to the current cvs Xindice 1.0rc1 and am
having some problems with the creation of collections that I did not see
previously. I am wondering whether something I am not aware of has
changed or if there is now a bug in the system.

I am creating the new collections thus:

      private boolean createCollection(String name, String path) {
       System.err.println("createCollection " + name + " " + path);

       Collection col = myServer.getCollection(path);

        if (col == null) return false;

        try {
         CollectionManager service = (CollectionManager)
     col.getService("CollectionManager", "1.0");

         // Build up the Collection XML configuration.
         String collectionConfig =
          "<collection compressed=\"true\" name=\""
           + name
           + "\">"
           + "   <filer class=\"org.dbxml.core.filer.BTreeFiler\"
     gzip=\"true\"/>"
           + "</collection>";

         service.createCollection(name,
     DOMParser.toDocument(collectionConfig));
         service.createIndexer(name);

         System.err.println("Collection " + name + " created.");
        }
        catch (XMLDBException e) {
         System.err.println("XML:DB Exception occured " +
     e.errorCode);
         return false;
        }
        catch (XindiceException e) {
         System.err.println("XML:DB Exception occured " +
     e.getMessage());
         return false;
        }
       }
       finally {
        myServer.closeCollection(col);
       }

       return true;
      }

When I try to add a new an exception if thrown:

     XML:DB Exception occured 1
     org.xmldb.api.base.XMLDBException: Collection No IndexManager
      at
     org.apache.xindice.core.FaultCodes.createXMLDBException(Unknown
     Source)
      at
     org.apache.xindice.client.xmldb.CollectionImpl.storeResource(Unknown
     Source)
      at
     com.xindice.proto.internal.core.internuncio.Mediator.addDocument(Mediator.java:134)

      at
     com.xindice.proto.internal.core.internuncio.Mediator.addDocument(Mediator.java:98)

      at
     com.xindice.proto.internal.core.internuncio.Mediator.main(Mediator.java:301)

I am using the following code to add the document:

      public boolean addDocument(DocumentDescriptor descriptor,
     boolean overwrite) {

       Collection col =
     myServer.getCollection(descriptor.getCollectionPath());

       if (col == null) {
        String error =
         "Collection \""
          + descriptor.getCollectionPath()
          + "\" not found, document \""
          + descriptor.getName()
          + "\" skipped";

        System.out.println(error);
        descriptor.setError(error);
        return false;
       }

       try {
        if (!overwrite) {
         // This code also throws an exception, but I believe
         // that it should simply return null
         try {
          Resource res = col.getResource(descriptor.getName());

          if (res == null) {
           System.out.println("Document \"" + descriptor.getName()
     + "\" skipped");
           return true;
          }
         }
         catch (XMLDBException ignore) {
         }
        }

        XMLResource document = (XMLResource)
     col.createResource(descriptor.getName(), "XMLResource");
        document.setContent(descriptor.getDocument());
        // throws exception here
        col.storeResource(document);
        System.out.println("Document " + descriptor.getName() + "
     inserted");
       }
       catch (XMLDBException e) {
        System.err.println("XML:DB Exception occured " +
     e.errorCode);
        e.printStackTrace();
        descriptor.setError("XML:DB Exception occured " +
     e.errorCode);
        return false;
       }
       finally {
        myServer.closeCollection(col);
       }

       return true;
      }

Any insights would be very appreciated.

Tia,
Joel



Re: Collection No IndexManager

Posted by Joel Rosi-Schwartz <jo...@btconnect.com>.
The line

     service.createIndexer(name);

does not belong in the example. I was starting to play around with the
possibility that  I needed to also create an Indexer, but stopped to
write the post before trying it out. Obviously the argument "name" is
not appropriate here, it was left over from the cut and paste on the
previous line.

Joel

Joel Rosi-Schwartz wrote:

> Hi,
>
> I am moving from xmldb beta 4 to the current cvs Xindice 1.0rc1 and am
> having some problems with the creation of collections that I did not
> see previously. I am wondering whether something I am not aware of has
> changed or if there is now a bug in the system.
>
> I am creating the new collections thus:
>
>       private boolean createCollection(String name, String path)
>      {
>        System.err.println("createCollection " + name + " " +
>      path);
>        Collection col = myServer.getCollection(path);
>
>         if (col == null) return false;
>
>         try {
>          CollectionManager service = (CollectionManager)
>      col.getService("CollectionManager", "1.0");
>
>          // Build up the Collection XML configuration.
>          String collectionConfig =
>           "<collection compressed=\"true\" name=\""
>            + name
>            + "\">"
>            + "   <filer class=\"org.dbxml.core.filer.BTreeFiler\"
>      gzip=\"true\"/>"
>            + "</collection>";
>
>          service.createCollection(name,
>      DOMParser.toDocument(collectionConfig));
>          service.createIndexer(name);
>
>          System.err.println("Collection " + name + " created.");
>         }
>         catch (XMLDBException e) {
>          System.err.println("XML:DB Exception occured " +
>      e.errorCode);
>          return false;
>         }
>         catch (XindiceException e) {
>          System.err.println("XML:DB Exception occured " +
>      e.getMessage());
>          return false;
>         }
>        }
>        finally {
>         myServer.closeCollection(col);
>        }
>
>        return true;
>       }
>
> When I try to add a new an exception if thrown:
>
>      XML:DB Exception occured 1
>      org.xmldb.api.base.XMLDBException: Collection No
>      IndexManager
>       at
>      org.apache.xindice.core.FaultCodes.createXMLDBException(Unknown
>      Source)
>       at
>      org.apache.xindice.client.xmldb.CollectionImpl.storeResource(Unknown
>      Source)
>       at
>      com.xindice.proto.internal.core.internuncio.Mediator.addDocument(Mediator.java:134)
>
>       at
>      com.xindice.proto.internal.core.internuncio.Mediator.addDocument(Mediator.java:98)
>
>       at
>      com.xindice.proto.internal.core.internuncio.Mediator.main(Mediator.java:301)
>
> I am using the following code to add the document:
>
>       public boolean addDocument(DocumentDescriptor descriptor,
>      boolean overwrite) {
>
>        Collection col =
>      myServer.getCollection(descriptor.getCollectionPath());
>
>        if (col == null) {
>         String error =
>          "Collection \""
>           + descriptor.getCollectionPath()
>           + "\" not found, document \""
>           + descriptor.getName()
>           + "\" skipped";
>
>         System.out.println(error);
>         descriptor.setError(error);
>         return false;
>        }
>
>        try {
>         if (!overwrite) {
>          // This code also throws an exception, but I believe
>          // that it should simply return null
>          try {
>           Resource res = col.getResource(descriptor.getName());
>
>           if (res == null) {
>            System.out.println("Document \"" +
>      descriptor.getName() + "\" skipped");
>            return true;
>           }
>          }
>          catch (XMLDBException ignore) {
>          }
>         }
>
>         XMLResource document = (XMLResource)
>      col.createResource(descriptor.getName(), "XMLResource");
>         document.setContent(descriptor.getDocument());
>         // throws exception here
>         col.storeResource(document);
>         System.out.println("Document " + descriptor.getName() + "
>      inserted");
>        }
>        catch (XMLDBException e) {
>         System.err.println("XML:DB Exception occured " +
>      e.errorCode);
>         e.printStackTrace();
>         descriptor.setError("XML:DB Exception occured " +
>      e.errorCode);
>         return false;
>        }
>        finally {
>         myServer.closeCollection(col);
>        }
>
>        return true;
>       }
>
>
> Any insights would be very appreciated.
>
> Tia,
> Joel
>
>

Re: Collection No IndexManager

Posted by Joel Rosi-Schwartz <jo...@btconnect.com>.
Okay, I figured this out ;-)  The configuration string needs to be:

        String collectionConfig =
         "<collection compressed=\"true\" name=\""
          + name
          + "\">"
          + "   <filer class=\"org.apache.xindice.core.filer.BTreeFiler\"
     gzip=\"true\"/>"
          + "</collection>";

Note that the filer class needs to be on the new package structure.  I guess that in
the bowls the InstantiationException is caught and passed back up as a generic NO
MANAGER. Kimbro, ever consider adding log4j into Xindice?  It would take a bit of
grunt work to get into place in a meaningful way, but I think in the end it will save
a lot of hours of frustration in looking for odd behaviour. Just a thought.

Cheerio,
Joel


Joel Rosi-Schwartz wrote:

> Kimbro Staken wrote:
>
> > On Tuesday, January 29, 2002, at 07:51 AM, Joel Rosi-Schwartz wrote:
> >
> > > Well, I finally realized that the creation code I was using is copied
> > > directly from the dbXML Developers Guide 0.5 and that the API for
> > > theCollectionManager has a simpler createCollection()  method that takes
> > > only a name as the parameter and then creates a default collection. Using
> > > this method clears all of my problems.
> > >
> > > I am still wondering about the original problem, however.  Is the Guide
> > > wrong, is the release broken or am I applying this wrongly? Is there more
> > > information on the usage of the collection configuration facility? Is
> > > this useful to pursue or is it best in general to stay with the default
> > > collection creation mechanism?
> > >
> >
> > There are two services you can use to create collections,
> > CollectionManager which is Xindice specific and
> > CollectionManagementService that is part of the XML:DB API. They're both
> > actually implemented by the same class and the simpler method that you're
> > calling is part of CollectionManagementService.
> >
> > CollectionManagementService just allows creation and deletion of
> > collections, but not indexes or XMLObjects. In theory it should work for
> > more then one database though. If you can get away with the limitations
> > you should use this service.
> >
> > CollectionManager is specific to Xindice and exposes all the other
> > management functionality, plus different methods for creating and deleting
> > collections. If you need more advanced functionality this is the only way
> > to get it.
>
> Thanks Kimbro, that clears up a lot.  I have taken a new look at the API and the
> separation of concerns between xmldb and Xindice are a bit clearer now.
>
> In fact, however, the limitations are not acceptable in my project, I will
> certainly need to take advantage of indexes and possibly XMLObjects. So this
> leaves me with wondering why the code that I copied does not work in my case.  Is
> the Developer's Guide behind the times or am I applying it wrongly? btw, the
> creation goes without any indication of a problem, it is not until I try to access
> the collection that I get the exception.
>
> > > Thanks,
> > > Joel
> > >
> > >
> > > Joel Rosi-Schwartz wrote:
> > >
> > > Hi,
> > >
> > > I am moving from xmldb beta 4 to the current cvs Xindice 1.0rc1 and am
> > > having some problems with the creation of collections that I did not see
> > > previously. I am wondering whether something I am not aware of has
> > > changed or if there is now a bug in the system.
> > >
> > > I am creating the new collections thus:
> > >
> > >  private boolean createCollection(String name, String path) {
> > >   System.err.println("createCollection " + name + " " + path);
> > >   Collection col = myServer.getCollection(path);
> > >
> > >    if (col == null) return false;
> > >
> > >    try {
> > >     CollectionManager service = (CollectionManager)
> > > col.getService("CollectionManager", "1.0");
> > >
> > >     // Build up the Collection XML configuration.
> > >     String collectionConfig =
> > >      "<collection compressed=\"true\" name=\""
> > >       + name
> > >       + "\">"
> > >       + "   <filer class=\"org.dbxml.core.filer.BTreeFiler\" gzip=\"true\
> > > "/>"
> > >       + "</collection>";
> > >
> > >     service.createCollection(name, DOMParser.toDocument(collectionConfig)
> > > );
> > >     service.createIndexer(name);
> > >
> > >     System.err.println("Collection " + name + " created.");
> > >    }
> > >    catch (XMLDBException e) {
> > >     System.err.println("XML:DB Exception occured " + e.errorCode);
> > >     return false;
> > >    }
> > >    catch (XindiceException e) {
> > >     System.err.println("XML:DB Exception occured " + e.getMessage());
> > >     return false;
> > >    }
> > >   }
> > >   finally {
> > >    myServer.closeCollection(col);
> > >   }
> > >
> > >   return true;
> > >  }
> > >
> > > When I try to add a new an exception if thrown:
> > >
> > > XML:DB Exception occured 1
> > > org.xmldb.api.base.XMLDBException: Collection No IndexManager
> > >  at org.apache.xindice.core.FaultCodes.createXMLDBException(Unknown
> > > Source)
> > >  at org.apache.xindice.client.xmldb.CollectionImpl.storeResource(Unknown
> > > Source)
> > >  at
> > > com.xindice.proto.internal.core.internuncio.Mediator.addDocument(Mediator.
> > > java:134)
> > >  at
> > > com.xindice.proto.internal.core.internuncio.Mediator.addDocument(Mediator.
> > > java:98)
> > >  at
> > > com.xindice.proto.internal.core.internuncio.Mediator.main(Mediator.java:301)
> > >
> > > I am using the following code to add the document:
> > >
> > >  public boolean addDocument(DocumentDescriptor descriptor, boolean
> > > overwrite) {
> > >
> > >   Collection col = myServer.getCollection(descriptor.getCollectionPath())
> > > ;
> > >
> > >   if (col == null) {
> > >    String error =
> > >     "Collection \""
> > >      + descriptor.getCollectionPath()
> > >      + "\" not found, document \""
> > >      + descriptor.getName()
> > >      + "\" skipped";
> > >
> > >    System.out.println(error);
> > >    descriptor.setError(error);
> > >    return false;
> > >   }
> > >
> > >   try {
> > >    if (!overwrite) {
> > >     // This code also throws an exception, but I believe
> > >     // that it should simply return null
> > >     try {
> > >      Resource res = col.getResource(descriptor.getName());
> > >
> > >      if (res == null) {
> > >       System.out.println("Document \"" + descriptor.getName() + "\"
> > > skipped");
> > >       return true;
> > >      }
> > >     }
> > >     catch (XMLDBException ignore) {
> > >     }
> > >    }
> > >
> > >    XMLResource document = (XMLResource)
> > > col.createResource(descriptor.getName(), "XMLResource");
> > >    document.setContent(descriptor.getDocument());
> > >    // throws exception here
> > >    col.storeResource(document);
> > >    System.out.println("Document " + descriptor.getName() + " inserted");
> > >   }
> > >   catch (XMLDBException e) {
> > >    System.err.println("XML:DB Exception occured " + e.errorCode);
> > >    e.printStackTrace();
> > >    descriptor.setError("XML:DB Exception occured " + e.errorCode);
> > >    return false;
> > >   }
> > >   finally {
> > >    myServer.closeCollection(col);
> > >   }
> > >
> > >   return true;
> > >  }
> > >
> > >
> > > Any insights would be very appreciated.
> > >
> > > Tia,
> > > Joel
> > >
> > >
> > >
> > >
> > Kimbro Staken
> > XML Database Software, Consulting and Writing
> > http://www.xmldatabases.org/

Re: Collection No IndexManager

Posted by Kimbro Staken <ks...@dbxmlgroup.com>.
On Tuesday, January 29, 2002, at 12:54 PM, Joel Rosi-Schwartz wrote:
>> .
>
> Thanks Kimbro, that clears up a lot.  I have taken a new look at the API 
> and the
> separation of concerns between xmldb and Xindice are a bit clearer now.
>
> In fact, however, the limitations are not acceptable in my project, I will
> certainly need to take advantage of indexes and possibly XMLObjects. So 
> this
> leaves me with wondering why the code that I copied does not work in my 
> case.  Is
> the Developer's Guide behind the times or am I applying it wrongly? btw, 
> the
> creation goes without any indication of a problem, it is not until I try 
> to access
> the collection that I get the exception.
>

I don't know, the XML in the example is exactly the same as that generated 
by the simpler createCollection call.

The one thing that did change in Xindice is that there aren't any default 
collections anymore. i.e. root and addressbook are gone. Don't know if 
this has any affect.

>>>
>>>
Kimbro Staken
XML Database Software, Consulting and Writing
http://www.xmldatabases.org/
>


Re: Collection No IndexManager

Posted by Joel Rosi-Schwartz <jo...@btconnect.com>.

Kimbro Staken wrote:

> On Tuesday, January 29, 2002, at 07:51 AM, Joel Rosi-Schwartz wrote:
>
> > Well, I finally realized that the creation code I was using is copied
> > directly from the dbXML Developers Guide 0.5 and that the API for
> > theCollectionManager has a simpler createCollection()  method that takes
> > only a name as the parameter and then creates a default collection. Using
> > this method clears all of my problems.
> >
> > I am still wondering about the original problem, however.  Is the Guide
> > wrong, is the release broken or am I applying this wrongly? Is there more
> > information on the usage of the collection configuration facility? Is
> > this useful to pursue or is it best in general to stay with the default
> > collection creation mechanism?
> >
>
> There are two services you can use to create collections,
> CollectionManager which is Xindice specific and
> CollectionManagementService that is part of the XML:DB API. They're both
> actually implemented by the same class and the simpler method that you're
> calling is part of CollectionManagementService.
>
> CollectionManagementService just allows creation and deletion of
> collections, but not indexes or XMLObjects. In theory it should work for
> more then one database though. If you can get away with the limitations
> you should use this service.
>
> CollectionManager is specific to Xindice and exposes all the other
> management functionality, plus different methods for creating and deleting
> collections. If you need more advanced functionality this is the only way
> to get it.

Thanks Kimbro, that clears up a lot.  I have taken a new look at the API and the
separation of concerns between xmldb and Xindice are a bit clearer now.

In fact, however, the limitations are not acceptable in my project, I will
certainly need to take advantage of indexes and possibly XMLObjects. So this
leaves me with wondering why the code that I copied does not work in my case.  Is
the Developer's Guide behind the times or am I applying it wrongly? btw, the
creation goes without any indication of a problem, it is not until I try to access
the collection that I get the exception.

> > Thanks,
> > Joel
> >
> >
> > Joel Rosi-Schwartz wrote:
> >
> > Hi,
> >
> > I am moving from xmldb beta 4 to the current cvs Xindice 1.0rc1 and am
> > having some problems with the creation of collections that I did not see
> > previously. I am wondering whether something I am not aware of has
> > changed or if there is now a bug in the system.
> >
> > I am creating the new collections thus:
> >
> >  private boolean createCollection(String name, String path) {
> >   System.err.println("createCollection " + name + " " + path);
> >   Collection col = myServer.getCollection(path);
> >
> >    if (col == null) return false;
> >
> >    try {
> >     CollectionManager service = (CollectionManager)
> > col.getService("CollectionManager", "1.0");
> >
> >     // Build up the Collection XML configuration.
> >     String collectionConfig =
> >      "<collection compressed=\"true\" name=\""
> >       + name
> >       + "\">"
> >       + "   <filer class=\"org.dbxml.core.filer.BTreeFiler\" gzip=\"true\
> > "/>"
> >       + "</collection>";
> >
> >     service.createCollection(name, DOMParser.toDocument(collectionConfig)
> > );
> >     service.createIndexer(name);
> >
> >     System.err.println("Collection " + name + " created.");
> >    }
> >    catch (XMLDBException e) {
> >     System.err.println("XML:DB Exception occured " + e.errorCode);
> >     return false;
> >    }
> >    catch (XindiceException e) {
> >     System.err.println("XML:DB Exception occured " + e.getMessage());
> >     return false;
> >    }
> >   }
> >   finally {
> >    myServer.closeCollection(col);
> >   }
> >
> >   return true;
> >  }
> >
> > When I try to add a new an exception if thrown:
> >
> > XML:DB Exception occured 1
> > org.xmldb.api.base.XMLDBException: Collection No IndexManager
> >  at org.apache.xindice.core.FaultCodes.createXMLDBException(Unknown
> > Source)
> >  at org.apache.xindice.client.xmldb.CollectionImpl.storeResource(Unknown
> > Source)
> >  at
> > com.xindice.proto.internal.core.internuncio.Mediator.addDocument(Mediator.
> > java:134)
> >  at
> > com.xindice.proto.internal.core.internuncio.Mediator.addDocument(Mediator.
> > java:98)
> >  at
> > com.xindice.proto.internal.core.internuncio.Mediator.main(Mediator.java:301)
> >
> > I am using the following code to add the document:
> >
> >  public boolean addDocument(DocumentDescriptor descriptor, boolean
> > overwrite) {
> >
> >   Collection col = myServer.getCollection(descriptor.getCollectionPath())
> > ;
> >
> >   if (col == null) {
> >    String error =
> >     "Collection \""
> >      + descriptor.getCollectionPath()
> >      + "\" not found, document \""
> >      + descriptor.getName()
> >      + "\" skipped";
> >
> >    System.out.println(error);
> >    descriptor.setError(error);
> >    return false;
> >   }
> >
> >   try {
> >    if (!overwrite) {
> >     // This code also throws an exception, but I believe
> >     // that it should simply return null
> >     try {
> >      Resource res = col.getResource(descriptor.getName());
> >
> >      if (res == null) {
> >       System.out.println("Document \"" + descriptor.getName() + "\"
> > skipped");
> >       return true;
> >      }
> >     }
> >     catch (XMLDBException ignore) {
> >     }
> >    }
> >
> >    XMLResource document = (XMLResource)
> > col.createResource(descriptor.getName(), "XMLResource");
> >    document.setContent(descriptor.getDocument());
> >    // throws exception here
> >    col.storeResource(document);
> >    System.out.println("Document " + descriptor.getName() + " inserted");
> >   }
> >   catch (XMLDBException e) {
> >    System.err.println("XML:DB Exception occured " + e.errorCode);
> >    e.printStackTrace();
> >    descriptor.setError("XML:DB Exception occured " + e.errorCode);
> >    return false;
> >   }
> >   finally {
> >    myServer.closeCollection(col);
> >   }
> >
> >   return true;
> >  }
> >
> >
> > Any insights would be very appreciated.
> >
> > Tia,
> > Joel
> >
> >
> >
> >
> Kimbro Staken
> XML Database Software, Consulting and Writing
> http://www.xmldatabases.org/

Re: Collection No IndexManager

Posted by Kimbro Staken <ks...@dbxmlgroup.com>.
On Tuesday, January 29, 2002, at 07:51 AM, Joel Rosi-Schwartz wrote:

> Well, I finally realized that the creation code I was using is copied 
> directly from the dbXML Developers Guide 0.5 and that the API for 
> theCollectionManager has a simpler createCollection()  method that takes 
> only a name as the parameter and then creates a default collection. Using 
> this method clears all of my problems.
>
> I am still wondering about the original problem, however.  Is the Guide 
> wrong, is the release broken or am I applying this wrongly? Is there more 
> information on the usage of the collection configuration facility? Is 
> this useful to pursue or is it best in general to stay with the default 
> collection creation mechanism?
>

There are two services you can use to create collections, 
CollectionManager which is Xindice specific and 
CollectionManagementService that is part of the XML:DB API. They're both 
actually implemented by the same class and the simpler method that you're 
calling is part of CollectionManagementService.

CollectionManagementService just allows creation and deletion of 
collections, but not indexes or XMLObjects. In theory it should work for 
more then one database though. If you can get away with the limitations 
you should use this service.

CollectionManager is specific to Xindice and exposes all the other 
management functionality, plus different methods for creating and deleting 
collections. If you need more advanced functionality this is the only way 
to get it.

> Thanks,
> Joel
>  
>
> Joel Rosi-Schwartz wrote:
>
> Hi,
>
> I am moving from xmldb beta 4 to the current cvs Xindice 1.0rc1 and am 
> having some problems with the creation of collections that I did not see 
> previously. I am wondering whether something I am not aware of has 
> changed or if there is now a bug in the system.
>
> I am creating the new collections thus:
>
>  private boolean createCollection(String name, String path) {
>   System.err.println("createCollection " + name + " " + path);
>   Collection col = myServer.getCollection(path);
>
>    if (col == null) return false;
>
>    try {
>     CollectionManager service = (CollectionManager) 
> col.getService("CollectionManager", "1.0");
>
>     // Build up the Collection XML configuration.
>     String collectionConfig =
>      "<collection compressed=\"true\" name=\""
>       + name
>       + "\">"
>       + "   <filer class=\"org.dbxml.core.filer.BTreeFiler\" gzip=\"true\
> "/>"
>       + "</collection>";
>
>     service.createCollection(name, DOMParser.toDocument(collectionConfig)
> );
>     service.createIndexer(name);
>
>     System.err.println("Collection " + name + " created.");
>    }
>    catch (XMLDBException e) {
>     System.err.println("XML:DB Exception occured " + e.errorCode);
>     return false;
>    }
>    catch (XindiceException e) {
>     System.err.println("XML:DB Exception occured " + e.getMessage());
>     return false;
>    }
>   }
>   finally {
>    myServer.closeCollection(col);
>   }
>
>   return true;
>  }
>
> When I try to add a new an exception if thrown:
>
> XML:DB Exception occured 1
> org.xmldb.api.base.XMLDBException: Collection No IndexManager
>  at org.apache.xindice.core.FaultCodes.createXMLDBException(Unknown 
> Source)
>  at org.apache.xindice.client.xmldb.CollectionImpl.storeResource(Unknown 
> Source)
>  at 
> com.xindice.proto.internal.core.internuncio.Mediator.addDocument(Mediator.
> java:134)
>  at 
> com.xindice.proto.internal.core.internuncio.Mediator.addDocument(Mediator.
> java:98)
>  at 
> com.xindice.proto.internal.core.internuncio.Mediator.main(Mediator.java:301)
>
> I am using the following code to add the document:
>
>  public boolean addDocument(DocumentDescriptor descriptor, boolean 
> overwrite) {
>
>   Collection col = myServer.getCollection(descriptor.getCollectionPath())
> ;
>
>   if (col == null) {
>    String error =
>     "Collection \""
>      + descriptor.getCollectionPath()
>      + "\" not found, document \""
>      + descriptor.getName()
>      + "\" skipped";
>
>    System.out.println(error);
>    descriptor.setError(error);
>    return false;
>   }
>
>   try {
>    if (!overwrite) {
>     // This code also throws an exception, but I believe
>     // that it should simply return null
>     try {
>      Resource res = col.getResource(descriptor.getName());
>
>      if (res == null) {
>       System.out.println("Document \"" + descriptor.getName() + "\" 
> skipped");
>       return true;
>      }
>     }
>     catch (XMLDBException ignore) {
>     }
>    }
>
>    XMLResource document = (XMLResource) 
> col.createResource(descriptor.getName(), "XMLResource");
>    document.setContent(descriptor.getDocument());
>    // throws exception here
>    col.storeResource(document);
>    System.out.println("Document " + descriptor.getName() + " inserted");
>   }
>   catch (XMLDBException e) {
>    System.err.println("XML:DB Exception occured " + e.errorCode);
>    e.printStackTrace();
>    descriptor.setError("XML:DB Exception occured " + e.errorCode);
>    return false;
>   }
>   finally {
>    myServer.closeCollection(col);
>   }
>
>   return true;
>  }
>
>
> Any insights would be very appreciated.
>
> Tia,
> Joel
>  
>  
>
>
Kimbro Staken
XML Database Software, Consulting and Writing
http://www.xmldatabases.org/


Re: Collection No IndexManager

Posted by Joel Rosi-Schwartz <jo...@btconnect.com>.
Well, I finally realized that the creation code I was using is copied
directly from the dbXML Developers Guide 0.5 and that the API for the
CollectionManager has a simpler createCollection()  method that takes
only a name as the parameter and then creates a default collection.
Using this method clears all of my problems.

I am still wondering about the original problem, however.  Is the Guide
wrong, is the release broken or am I applying this wrongly? Is there
more information on the usage of the collection configuration facility?
Is this useful to pursue or is it best in general to stay with the
default collection creation mechanism?

Thanks,
Joel


Joel Rosi-Schwartz wrote:

> Hi,
>
> I am moving from xmldb beta 4 to the current cvs Xindice 1.0rc1 and am
> having some problems with the creation of collections that I did not
> see previously. I am wondering whether something I am not aware of has
> changed or if there is now a bug in the system.
>
> I am creating the new collections thus:
>
>       private boolean createCollection(String name, String path)
>      {
>        System.err.println("createCollection " + name + " " +
>      path);
>        Collection col = myServer.getCollection(path);
>
>         if (col == null) return false;
>
>         try {
>          CollectionManager service = (CollectionManager)
>      col.getService("CollectionManager", "1.0");
>
>          // Build up the Collection XML configuration.
>          String collectionConfig =
>           "<collection compressed=\"true\" name=\""
>            + name
>            + "\">"
>            + "   <filer class=\"org.dbxml.core.filer.BTreeFiler\"
>      gzip=\"true\"/>"
>            + "</collection>";
>
>          service.createCollection(name,
>      DOMParser.toDocument(collectionConfig));
>          service.createIndexer(name);
>
>          System.err.println("Collection " + name + " created.");
>         }
>         catch (XMLDBException e) {
>          System.err.println("XML:DB Exception occured " +
>      e.errorCode);
>          return false;
>         }
>         catch (XindiceException e) {
>          System.err.println("XML:DB Exception occured " +
>      e.getMessage());
>          return false;
>         }
>        }
>        finally {
>         myServer.closeCollection(col);
>        }
>
>        return true;
>       }
>
> When I try to add a new an exception if thrown:
>
>      XML:DB Exception occured 1
>      org.xmldb.api.base.XMLDBException: Collection No
>      IndexManager
>       at
>      org.apache.xindice.core.FaultCodes.createXMLDBException(Unknown
>      Source)
>       at
>      org.apache.xindice.client.xmldb.CollectionImpl.storeResource(Unknown
>      Source)
>       at
>      com.xindice.proto.internal.core.internuncio.Mediator.addDocument(Mediator.java:134)
>
>       at
>      com.xindice.proto.internal.core.internuncio.Mediator.addDocument(Mediator.java:98)
>
>       at
>      com.xindice.proto.internal.core.internuncio.Mediator.main(Mediator.java:301)
>
> I am using the following code to add the document:
>
>       public boolean addDocument(DocumentDescriptor descriptor,
>      boolean overwrite) {
>
>        Collection col =
>      myServer.getCollection(descriptor.getCollectionPath());
>
>        if (col == null) {
>         String error =
>          "Collection \""
>           + descriptor.getCollectionPath()
>           + "\" not found, document \""
>           + descriptor.getName()
>           + "\" skipped";
>
>         System.out.println(error);
>         descriptor.setError(error);
>         return false;
>        }
>
>        try {
>         if (!overwrite) {
>          // This code also throws an exception, but I believe
>          // that it should simply return null
>          try {
>           Resource res = col.getResource(descriptor.getName());
>
>           if (res == null) {
>            System.out.println("Document \"" +
>      descriptor.getName() + "\" skipped");
>            return true;
>           }
>          }
>          catch (XMLDBException ignore) {
>          }
>         }
>
>         XMLResource document = (XMLResource)
>      col.createResource(descriptor.getName(), "XMLResource");
>         document.setContent(descriptor.getDocument());
>         // throws exception here
>         col.storeResource(document);
>         System.out.println("Document " + descriptor.getName() + "
>      inserted");
>        }
>        catch (XMLDBException e) {
>         System.err.println("XML:DB Exception occured " +
>      e.errorCode);
>         e.printStackTrace();
>         descriptor.setError("XML:DB Exception occured " +
>      e.errorCode);
>         return false;
>        }
>        finally {
>         myServer.closeCollection(col);
>        }
>
>        return true;
>       }
>
>
> Any insights would be very appreciated.
>
> Tia,
> Joel
>
>