I have written a Java Program using Lucene in Eclipse Juno. Whenever I try to run it, it is giving the following errors:
Exception in thread "main" java.lang.VerifyError: Cannot inherit from final class
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:634)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:277)
at java.net.URLClassLoader.access$000(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:212)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
at parser.BuildMainIndex.setUp(BuildMainIndex.java:339)
at parser.luceneDemo.main(luceneDemo.java:10)
and source of the error i.e. the line in BuildManinIndex.java is:
doc.add(new IntField("startTime1",startTime1,Field.Store.YES));
Here startTime1 is a field in document to be indexed. I was earlier using Lucene 3.6.0 and now I am using Lucene 4.3.0. I have not imported any thing from java.net.URL. I have no clue of the possible cause of this error. Please help.
EDIT: This following short program I have written.
writer=new IndexWriter(directory,new StandardAnalyzer(Version.LUCENE_CURRENT),IndexWriter.MaxFieldLength.UNLIMITED);
Document doc=new Document();
doc.add(new Field("title","XYZ",Field.Store.YES,Field.Index.ANALYZED));
doc.add(new Field("address","ABC Road",Field.Store.YES,Field.Index.ANALYZED));
doc.add(new Field("city","Mumbai",Field.Store.YES,Field.Index.ANALYZED));
doc.add(new IntField("startTime1",900,Field.Store.YES));
doc.add(new IntField("finishTime1",1000,Field.Store.YES));
doc.add(new IntField("startTime2",9999,Field.Store.YES));
doc.add(new IntField("finishTime2",9999,Field.Store.YES));
writer.addDocument(doc);
writer.close();