Uploaded image for project: 'Apache Gora'
  1. Apache Gora
  2. GORA-428

Null pointer exception caused by incorrect handling of gora.mongodb.login values that don't validate

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 0.5
    • 0.6.1
    • gora-mongodb
    • None
    • Ubuntu, Nutch2

    Description

      A null pointer exception occurs when the gora.mongodb.login=nutch does not validate.

      Line 250 of the MongoStore class in method "private DB getDB(final String servers, final String dbname, final String login, final String secret) throws UnknownHostException" returns a null when the user is not validated.

      if (login != null && secret != null)

      { ****PROBLEM**** auth = db.authenticate(login, secret.toCharArray()); }

      This causes the method to return a null to :
      mongoClientDB = getDB(vPropMongoServers, vPropMongoDb, vPropMongoLogin, vPropMongoSecret);

      In line 173 of MongoStore "public void initialize(final Class<K> keyClass,
      final Class<T> pPersistentClass, final Properties properties)"

      The code attempts to use this null value
      ****PROBLEM***
      as mongoClientColl = mongoClientDB
      .getCollection(mapping.getCollectionName());

      The solution is to check for a null point for mongoClientDB prior to use or, better, write specific code to report when a login to MongoDB fails due to authentication.

      ERROR MESSAGE

      InjectorJob: org.apache.gora.util.GoraException: java.lang.NullPointerException
      at org.apache.gora.store.DataStoreFactory.createDataStore(DataStoreFactory.java:169)
      at org.apache.gora.store.DataStoreFactory.createDataStore(DataStoreFactory.java:137)
      at org.apache.nutch.storage.StorageUtils.createWebStore(StorageUtils.java:78)
      at org.apache.nutch.crawl.InjectorJob.run(InjectorJob.java:218)
      at org.apache.nutch.crawl.InjectorJob.inject(InjectorJob.java:252)
      at org.apache.nutch.crawl.InjectorJob.run(InjectorJob.java:275)
      at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:65)
      at org.apache.nutch.crawl.InjectorJob.main(InjectorJob.java:284)
      Caused by: java.lang.NullPointerException
      at org.apache.gora.mongodb.store.MongoStore.initialize(MongoStore.java:173)
      at org.apache.gora.store.DataStoreFactory.initializeDataStore(DataStoreFactory.java:104)
      at org.apache.gora.store.DataStoreFactory.createDataStore(DataStoreFactory.java:163)
      ... 7 more

      Attachments

        Activity

          People

            Unassigned Unassigned
            kevinfindlay Kevin Findlay
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: