java.io.FileNotFoundException

Help
connoryz
2006-10-20
2013-04-17
  • connoryz

    connoryz - 2006-10-20

    hi benjellr,

      I got the following errors when I run my program:

    Exception in thread "main" java.io.FileNotFoundException: H:\Files\AIMS\Code\OSSE\Index_Server\_1.fnm (The system cannot find the file specified)
        at java.io.RandomAccessFile.open(Native Method)
        at java.io.RandomAccessFile.<init>(Unknown Source)
        at org.apache.lucene.store.FSIndexInput$Descriptor.<init>(FSDirectory.java:430)
        at org.apache.lucene.store.FSIndexInput.<init>(FSDirectory.java:439)
        at org.apache.lucene.store.FSDirectory.openInput(FSDirectory.java:329)
        at org.apache.lucene.index.FieldInfos.<init>(FieldInfos.java:56)
        at org.apache.lucene.index.SegmentReader.initialize(SegmentReader.java:144)
        at org.apache.lucene.index.SegmentReader.get(SegmentReader.java:129)
        at org.apache.lucene.index.SegmentReader.get(SegmentReader.java:110)
        at org.apache.lucene.index.IndexWriter.mergeSegments(IndexWriter.java:702)
        at org.apache.lucene.index.IndexWriter.mergeSegments(IndexWriter.java:686)
        at org.apache.lucene.index.IndexWriter.optimize(IndexWriter.java:543)
        at IndexAll.IndexFile(IndexAll.java:80)
        at IndexAll.main(IndexAll.java:46)

    Do you know where the problem is?

    Follow is a segment of my program:

    private static void index(IndexWriter writer, LiusConfig lc, File f, File indexDir) throws IOException, LiusException{   
               
                MixedIndexer indexer = new MixedIndexer();
               
                indexer.setUp(lc);
               
                indexer.setMixedContentsObj(f);
                           
                System.out.println("Indexing " + f.getPath());
               
               
                List <Field> fields = new ArrayList<Field>();
               
                fields.add(new Field("filename", f.getName(), Field.Store.YES, Field.Index.TOKENIZED));//edit the contents of a document
                fields.add(new Field("filepath", f.getCanonicalPath(), Field.Store.YES, Field.Index.TOKENIZED));//get the file name and add it to a docuement
               
                indexer.index(indexDir.getCanonicalPath(), fields);
              
               
               
                Document luceneDoc = LuceneActions.getSingletonInstance().populateLuceneDoc(indexer.getPopulatedLiusFields());
               
                LuceneActions.getSingletonInstance().save(luceneDoc, writer, lc);

    Many thanks in advance!

     
    • Rida Benjelloun

      Rida Benjelloun - 2006-10-20

      Hi,
      You have to remove this 2 lines from your code :

      Document luceneDoc = LuceneActions.getSingletonInstance().populateLuceneDoc(indexer.getPopulatedLiusFields());

      LuceneActions.getSingletonInstance().save(luceneDoc, writer, lc);

       
      • connoryz

        connoryz - 2006-10-20

        hi,

        i understand it now. thanks a lot!

         
    • connoryz

      connoryz - 2006-10-20

      thanks benjellr,

        firstly, i tried to follow your instructions to remove these two lines. but the programs gives me the same error as well.

        secondly, could i ask if i remove these two lines. how the indexed fields stored in a document? i mean, where is the connect between the writer and indexer? i think we should use the line:

      LuceneActions.getSingletonInstance().save(luceneDoc, writer, lc);

      to create a Lucene document. isnt it?

      just very confused about these two sentences. could you explain it to me? many many thanks in advance!

       
    • Ekaterina Volkova

      Hi, benjellr,

      I have a similar problem - i just try to run a code from the tutorial, and get the same mistake.

      Here is the code:

      import java.io.File;

      import lius.LiusLogger;
      import lius.config.LiusConfig;
      import lius.config.LiusConfigBuilder;
      import lius.index.Indexer;
      import lius.index.IndexerFactory;

      public class LuisTest {

          public static void main(String[] args) {

              String indexDir = "path/index" ;
              String log4j = "path/log4j.properties";
              String toIndex = "path/test.pdf";
              String liusConfig = "path/liusConfig.xml";
              LiusLogger.setLoggerConfigFile(log4j);
              LiusConfig lc = LiusConfigBuilder.getSingletonInstance().getLiusConfig(liusConfig);
              Indexer indexer = IndexerFactory.getIndexer(new File(toIndex), lc);
              String text = indexer.getContent();
              System.out.print(text);

          }
      }

      the mistake I get is

      Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/log4j/Logger
          at lius.LiusLogger.<clinit>(LiusLogger.java:30)
          at LuisTest.main(LuisTest.java:17)

      I use eclipse, so I guess i can be sure the classpath and all are configured properly.
      I'm quite new to Java and to Lucene too, could you please help me to figure out what I'm doing wrong?

      Thanks in advance!

       

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks