Trying to use JWNL, getting NullPointerExcept

Help
2008-03-14
2013-04-29
  • savio spiteri
    savio spiteri
    2008-03-14

    Hi all,

    I am using JWNL 1.4, database backend (MySQL), wordnet 2.1, windows vista. After somehow managing to import the data into my database, I am trying to do the following code:

    try {
                //initialise jwnl
                FileInputStream properties = new FileInputStream(WNPROPFILE);
                if (!JWNL.isInitialized())JWNL.initialize(properties);
               
                IndexWord iw = Dictionary.getInstance().getIndexWord(POS.NOUN, "tank");
    } catch (Exception ex) {
                ex.printStackTrace();
    }

    JWNL is being initialised correctly but I am getting the following:

    Mar 14, 2008 10:17:03 AM net.didion.jwnl.util.MessageLog doLog
    INFO: Installing dictionary net.didion.jwnl.dictionary.DatabaseBackedDictionary@64ab4d
    java.lang.NullPointerException
            at net.didion.jwnl.dictionary.DatabaseBackedDictionary.getIndexWord(DatabaseBackedDictionary.java:77)
            at acrosstheweb.Main.testWordnet(Main.java:58)
            at acrosstheweb.Main.main(Main.java:107)

    I have searched all this forum, and found numerous fixes for wordnet 2.1 problems. However, my code already contains these fixes. Hence, I have no idea what is going wrong, but I am getting desperate!

    Thanks for all your help...

     
    • Brett Walenz
      Brett Walenz
      2008-03-18

      My initial guess would be that the database isn't populated correctly, as it looks like it's failing on a query being null, which shouldn't be the case (obviously).

      I'll look at this today and see if I can replicate...

       
    • savio spiteri
      savio spiteri
      2008-03-19

      Thanks a lot for your time.

      It certainly could be an error in the database population. In fact, I did not manage to import wordnet using JWNL itself, but did so using another project called WordnetSQLBuilder. Could it be that the schema database (or whatever) is somewhat different?

      Anyways, if you could give me instructions on how to import Wordnet using JWNL itself, I will try again.

      Thanks a lot for your help...