lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Terry Steichen" <te...@net-frame.com>
Subject Re: Lucene Search Applet
Date Wed, 18 Aug 2004 15:17:49 GMT
I suspect it has to do with the security restrictions of the applet, 'cause it doesn't appear
to be finding your Lucene jar file.  Also, regarding the lock files, I believe you can disable
the locking stuff just for purposes like yours (read-only index).

Regards,

Terry
  ----- Original Message ----- 
  From: Simon mcIlwaine 
  To: Lucene Users List 
  Sent: Wednesday, August 18, 2004 11:03 AM
  Subject: Lucene Search Applet


  Im developing a Lucene CD-ROM based search which will search html pages on CD-ROM, using
an applet as the UI. I know that theres a problem with lock files and also security restrictions
on applets so I am using the RAMDirectory. I have it working in a Swing application however
when I put it into an applet its giving me problems. It compiles but when I go to run the
applet I get the error below. Can anyone help? Thanks in advance.
  Simon

  Error:

  Java.lang.noClassDefFoundError: org/apache/lucene/store/Directory

  At: Java.lang.Class.getDeclaredConstructors0(Native Method)

  At: Java.lang.Class.privateGetDeclaredConstructors(Class.java:1610)

  At: Java.lang.Class.getConstructor0(Class.java:1922)

  At: Java.lang.Class.newInstance0(Class.java:278)

  At: Java.lang.Class.newInstance(Class.java:261)

  At: sun.applet.AppletPanel.createApplet(AppletPanel.java:617)

  At: sun.applet.AppletPanel.runloader(AppletPanel.java:546)

  At: sun.applet.AppletPanel.run(AppletPanel.java:298)

  At: java.lang.Thread.run(Thread.java:534)

  Code:

  import org.apache.lucene.search.IndexSearcher;

  import org.apache.lucene.search.Query;

  import org.apache.lucene.search.TermQuery;

  import org.apache.lucene.store.RAMDirectory;

  import org.apache.lucene.store.Directory;

  import org.apache.lucene.index.Term;

  import org.apache.lucene.search.Hits;

  import java.awt.*;

  import java.awt.event.*;

  import javax.swing.*;

  import java.io.*;

  public class MemorialApp2 extends JApplet implements ActionListener{

  JLabel prompt;

  JTextField input;

  JButton search;

  JPanel panel;

  String indexDir = "C:/Java/lucene/index-list";

  private static RAMDirectory idx;

  public void init(){

  Container cp = getContentPane();

  panel = new JPanel();

  panel.setLayout(new FlowLayout(FlowLayout.CENTER, 4, 4));

  prompt = new JLabel("Keyword search:");

  input = new JTextField("",20);

  search = new JButton("Search");

  search.addActionListener(this);

  panel.add(prompt);

  panel.add(input);

  panel.add(search);

  cp.add(panel);

  }

  public void actionPerformed(ActionEvent e){

  if (e.getSource() == search){

  String surname = (input.getText());

  try {

  findSurname(indexDir, surname);

  } catch(Exception ex) {

  System.err.println(ex);

  }

  }

  }

  public static void findSurname(String indexDir, String surname) throws Exception{

  idx = new RAMDirectory(indexDir);

  IndexSearcher searcher = new IndexSearcher(idx);

  Query query = new TermQuery(new Term("surname", surname));

  Hits hits = searcher.search(query);

  for (int i = 0; i < hits.length(); i++) {

  //Document doc = hits.doc(i);

  System.out.println("Surname: " + hits.doc(i).get("surname"));

  }

  }

  }

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message